How to declare a size of a string

Just starting out? Need help? Post your questions and find answers here.
lhoaithu
New User
New User
Posts: 1
Joined: Sat May 21, 2022 7:51 am

How to declare a size of a string

Post by lhoaithu »

Hi all, want to use the API call:

GetVersionEx_()

What I have now is:
-snip-
Structure Version ; 0. The problem is how to allocate 128 byte for
CSDVersion.s and than use it in a structure.

Tryed CSDVersion.s[128] or the Dim command.
Also tryed to use a pointer to the variable but I don't get it.
Is there a possibility?



Have a nice day...
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: How to declare a size of a string

Post by STARGÅTE »

You have to use curly brackets.
As a variable:

Code: Select all

Define CSDVersion.s{128}
Or in a structure:

Code: Select all

Structure MyStruc
	CSDVersion.s{128}
EndStructure
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Quin
Enthusiast
Enthusiast
Posts: 282
Joined: Thu Mar 31, 2022 7:03 pm
Location: United States
Contact:

Re: How to declare a size of a string

Post by Quin »

Brackets are the syntax for arrays. In PureBasic, strings are their own type, so that won't work. You need curly braces "{" and "}". So something like the following should work:

Code: Select all

CSDVersion.s{128}
It works inside Structures, too! :)
PB v5.40/6.10, Windows 10 64-bit.
16-core AMD Ryzen 9 5950X, 128 GB DDR5.
Post Reply