Bank
BlitzPlus Forums/BlitzPlus Programming/Bank
| ||
Hello, i want put a couple of nullterminated Strings into a BANK. I need this for passing a bank variable to a DLL. Any Ideas ? I have found PokeString and PeekString$ in the code archive, but i have no success. Here is my testcode : ; Bank - Routinen bank1 = CreateBank(5000) a$ = "Hello" b$ = "World !" c$ = "How are you ?" mystr$ = a$ + Chr$(0) + b$ + Chr$(0) + c$ + Chr$(0) PokeString(bank1, 0, mystr$) ges$ = PeekString$(bank1, 0, ges$) Print ges$ ;location = Instr(ges$, Chr$(0), 3) d$ = Input$("Press RETURN to end...") FreeBank bank1 End Function PokeString(bank,offset,s$) PokeInt bank,offset,Len(s$) For i = 1 To Len(s$) PokeByte(bank,offset+i+3, Asc(Mid$(s$,i,1))) Next End Function Function PeekString$(bank,offset,s$) l = PeekInt(bank,offset) s$ = "" For i = 1 To l s$ = s$ + Chr$(PeekByte(bank,offset+i+3)) Next Return s$ End Function |
| ||
I thought Mark had changed to handeling of strings so that they were the same as C? In which case try passing the string to the DLL as it should be a pointer to a null terminated string. |
| ||
If you want to pass them in a bank, I believe you might get better results using PokeByte, cycling through each ASC("character") in your string, and manually adding 0 at the end. |
| ||
Hi, Thank you for your tips. i have solve my problem. It works with PeekByte() Code : ; Bank - Routinen bank1 = CreateBank(5000) ; a$ + Chr$(0) b$ + Chr$(0) c$ + Chr$(0) -> not works a$ = "Hello" b$ = "World !" c$ = "How are you ?" PokeString(bank1, 0, a$) slen = Len(a$) + 1 PokeString(bank1, slen, b$) slen = slen + Len(b$) + 1 PokeString(bank1, slen, c$) Print PeekString$(bank1, 0, Len(a$)) Print PeekString$(bank1, Len(a$) + 1, Len(b$)) Print PeekString$(bank1, Len(a$) + Len(b$) + 2, Len(c$)) d$ = Input$("Press RETURN to end...") FreeBank bank1 End Function PokeString(bank,offset,s$) z = 0 For i = 1 To Len(s$) PokeByte(bank,offset + z, Asc(Mid$(s$,i,1))) z = z + 1 Next z = z + 1 PokeByte(bank, offset + z, Chr$(0)) End Function Function PeekString$(bank,offset, slen) s$ = "" z = 0 For i = 1 To slen s$ = s$ + Chr$(PeekByte(bank,offset + z)) z = z + 1 Next Return s$ End Function |
| ||
Hi, is there a way to pass a bank with adresses of strings to a DLL ? the above functions works fine. i have changed the declares in my .decls - file. like : myfunc(a%) to myfunc(a*) but it works with one string only. or can i pass an array (dim myarray$(3) ) as a pointer (@) ? |