Hi !
I have no real experience with PB programming, so maybe I'm doing something wrong.. anyway I'm having problems accessing an array (declared as STATIC and SHARED) from a SUB.
It seems I can't access more than 255 elements.
Maybe static arrays can't be shared ?? That is, they can't be global ??? The array has 512 elements.
If I remove the code from the SUB and put it in the global scope, I can access all the elements correctly.
If so, should I pass the memory pointer of the array to my SUB ?
Thanks for any help.
Here it is the source (it prints bitmap fonts on a dot-matrix display connected through parallel port) :
[This message has been edited by Franco Lazzarotti (edited August 19, 2006).]
I have no real experience with PB programming, so maybe I'm doing something wrong.. anyway I'm having problems accessing an array (declared as STATIC and SHARED) from a SUB.
It seems I can't access more than 255 elements.
Maybe static arrays can't be shared ?? That is, they can't be global ??? The array has 512 elements.
If I remove the code from the SUB and put it in the global scope, I can access all the elements correctly.
If so, should I pass the memory pointer of the array to my SUB ?
Thanks for any help.
Here it is the source (it prints bitmap fonts on a dot-matrix display connected through parallel port) :
Code:
'$COMPILE UNIT '$COMPILE EXE $CPU 80386 $LIB LPT OFF $LIB GRAPH OFF $LIB FULLFLOAT OFF $LIB IPRINT OFF '$ERROR ALL OFF $OPTION CNTLBREAK OFF DEFINT A-Z DECLARE SUB DisplayTextOut(StringToDisplay AS STRING) DECLARE SUB DoEnablePulse(BYVAL RegisterStatus AS BYTE) DIM STATIC BUFFER_FONT8x8(511) AS SHARED BYTE ' SPAZIO BUFFER_FONT8x8(0)=0 BUFFER_FONT8x8(1)=0 BUFFER_FONT8x8(2)=0 BUFFER_FONT8x8(3)=0 BUFFER_FONT8x8(4)=0 BUFFER_FONT8x8(5)=0 BUFFER_FONT8x8(6)=0 BUFFER_FONT8x8(7)=0 ' BUFFER_FONT8x8(488)=0 BUFFER_FONT8x8(489)=0 BUFFER_FONT8x8(490)=65 BUFFER_FONT8x8(491)=65 BUFFER_FONT8x8(492)=127 BUFFER_FONT8x8(493)=127 BUFFER_FONT8x8(494)=0 BUFFER_FONT8x8(495)=0 ' BUFFER_FONT8x8(496)=0 BUFFER_FONT8x8(497)=8 BUFFER_FONT8x8(498)=12 BUFFER_FONT8x8(499)=254 BUFFER_FONT8x8(500)=254 BUFFER_FONT8x8(501)=12 BUFFER_FONT8x8(502)=8 BUFFER_FONT8x8(503)=0 ' BUFFER_FONT8x8(504)=0 BUFFER_FONT8x8(505)=24 BUFFER_FONT8x8(506)=60 BUFFER_FONT8x8(507)=126 BUFFER_FONT8x8(508)=24 BUFFER_FONT8x8(509)=24 BUFFER_FONT8x8(510)=24 BUFFER_FONT8x8(511)=24 ' Display OFF 'OUT &H37A,7 'OUT &H378,&H3E 'CALL DoEnablePulse(7) ' Set the Initial Display Line 'OUT &H378,&HC0 'CALL DoEnablePulse(7) ' Set Page Address 'OUT &H378,&HB8 'CALL DoEnablePulse(7) ' Set Y Address 'OUT &H378,&H40 'CALL DoEnablePulse(7) CALL DisplayTextOut("A") ' Display ON 'OUT &H37A,7 'OUT &H378,&H3F 'CALL DoEnablePulse(7) SUB DisplayTextOut(StringToDisplay AS STRING) DIM i AS LOCAL BYTE DIM y AS LOCAL BYTE DIM Lenght AS LOCAL BYTE DIM Offset_Start AS LOCAL WORD DIM Offset_End AS LOCAL WORD Length=LEN(StringToDisplay) IF Length<17 THEN 'OUT &H37A,6 FOR i=1 to Length 'y=ASC(StringToDisplay,i) 'PRINT y Offset_Start=ASC(StringToDisplay,i)-32 SHIFT LEFT Offset_Start,3 Offset_End=Offset_Start+7 PRINT Offset_Start ' Write BitMap Data FOR y=Offset_Start TO Offset_End PRINT BUFFER_FONT8x8(y) 'OUT &H378,BUFFER_FONT8x8(y) 'CALL DoEnablePulse(6) NEXT NEXT END IF END SUB SUB DoEnablePulse(BYVAL RegisterStatus AS BYTE) DIM i AS LOCAL BYTE ' E=0 OUT &H37A,RegisterStatus-4 FOR i=0 to 1 NEXT i ' E=1 OUT &H37A,RegisterStatus END SUB
[This message has been edited by Franco Lazzarotti (edited August 19, 2006).]
Comment