Author Topic: Static string type  (Read 1660 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Static string type
« on: August 04, 2013, 11:48:13 AM »
Charles
Do you can show us why this PowerBasic code in oxygen not work,
it complain about static type,or i translate in a wrong way ???
Code: [Select]
FUNCTION StringOfStrings() AS STRING
static STRING s
s=STRING(1024*4,CHR(0))
DIM ss(1023) AS STATIC STRING AT STRPTR(s)
ss(16)="Hello"
FUNCTION=s
END FUNCTION

FUNCTION pbf () AS LONG
DIM s AS STATIC STRING
DIM t AS STRING
s=StringOfStrings()
t=s 'tranferanferability test
DIM ss(1023) AS STRING AT STRPTR(t)
ss(16)+=" World!"
print ss(16)
END FUNCTION

Example is your from JoseRoca forum...

Charles Pegge

  • Guest
Re: Static string type
« Reply #1 on: August 05, 2013, 01:27:40 AM »
Hi Aurel,

It is not interpreting the 'at strptr(s) PB' style syntax as expected

If you like using dim statements, I would do it this way:

function StringOfStrings() as string
static as string s=nuls 1024*sizeof string
dim as string ss at (strptr s)
ss(16)="Hello" 'test
return s
end function

function pbf () as sys
static as string s,t
s=StringOfStrings()
t=s 'transferability test
dim as string ss(1023) AT (STRPTR t)
ss(16)+=" World!"
print ss(16)
end function

pbf