String Funktion

Just starting out? Need help? Post your questions and find answers here.
Vater
User
User
Posts: 18
Joined: Fri Dec 17, 2004 8:52 am

String Funktion

Post by Vater »

Hello NG,

I try to use the String Function to fill a String Variable.
Here is my Code:

VName$ = String(255, Chr(0))
Serial$ = String(255, Chr(0))
FSName$ = String(255, Chr(0))

GetVolumeInformation_("C:\", VName$, 255, Serial$, 0, 0, FSName$, 255)
CallDebugger
Debug VName$
Debug Serial$
Debug FSName$
OpenConsole()
PrintN(VName$)
PrintN(Serial$)
PrintN(FSName$)
Input()

I get the Error String is not a function, an array or a linked list.
Any Ideas??
Thanks for all your help

Stefan
CloseConsole()
End
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

You get this error because, in fact, there is no such command in PB, check the help file(very useful sometimes!). However you can can use Space() to the same effect in the code you posted.
Vater
User
User
Posts: 18
Joined: Fri Dec 17, 2004 8:52 am

Post by Vater »

Thanks for the quick answer but (I Work with jaPBE) when i type the String() Command I get a quick reference saying
Stirng(Count, Char$) - Multiply char [Math and Strings.pbi]
I'm new to PB, do I need to link to this pbi File somehow??

Stefan
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Oh you are correct. JaPBe has some includes that one can use.
If you click Project -> project options and click the tab "Includes", you can see a list of some that comes with japbe. If you tick the box with "Math and Strings", you should be able to use this function.
Vater
User
User
Posts: 18
Joined: Fri Dec 17, 2004 8:52 am

String Funktion

Post by Vater »

That's it, thanks
Stefan
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: String Funktion

Post by PB »

> VName$ = String(255, Chr(0))

In addition to what thefool said, it also must be mentioned that you cannot
use Chr(0) in strings, as that is used to terminate a string. If you need to
fill a string, better to use something like Space(255) instead (to fill it with
255 spaces).

Code: Select all

a$=Chr(0)+Chr(0)+Chr(0)
Debug Len(a$) ; Returns 0, not 3.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply