DGStr::GetStrData(size)?

Previous topic - Next topic

Moebius

The help file under INLINE mentions this function, but whenever I try to use it the compiler tells me that "class __GLBASIC__::DGStr has no member named 'GetStrData'".
Does the help file list the wrong name?  or what should I be using here?  Thanks.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

MrTAToad

#1
Yes - it is wrong as that function no longer exists.

You get the string data by using something like :

Code (glbasic) Select

char *data=m_str.c_str();


Need to update the information at some time.

bigsofty

#2
Mr T. is correct, it looks like the manual needs a little edit.  ;/
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Moebius

Yep it's easy get a pointer to the data, but how then do I allocate a buffer?  without GetStrData the only way I can think of getting a specific size DGStr is:
FOR i = 1 TO Size
   INC Buffer$, " "
NEXT
... which I can't see working very nicely or quickly :\

@Gernot (well anyone who knows the internal DGStr definition) is there another way I can allocate a string of a variable size?  Some special constructor?

(Slightly related, could GLB get around strings "like \0 this" by having a constructor take a c-string and a length?  That would be a lot easier than "like " + CHR$(0) + " this")
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

MrTAToad

#4
There is an alloc() function, which will allow you to defined a string to a set size.  I dont know what it is initialise to initially though, so you should probably not depend on anything...

In addition there is also a setlength() function (which I think is the preferable one to use).

Moebius

Alright I couldn't get setlength() to work, but alloc(int,bool) does seem to work (where the second boolean parameter seems to specify whether to copy the old string across).
Thanks for that - hopefully things won't be broken by this!
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

MrTAToad

No - the only time anything would is if __GetPrpjectVersionGLB() got renamed :)