@THB
Hello, welcome!
This will be a fairly detailed explanation, so bare with it if it's written for more of a novice. If you mean converting a string to an array, what you generally have to do is "parse" the array into chunks that you want to store in the array. Parse just means separate or break down.
So, in your example:
stringsomething = "1,23,64,20,11"
We'll assume that you want each number to go into it's own array index. The first thing to note is that a single string in DBC maximum length is 255 characters. Keep that in the back of your find.
So the first thing we need to do is determine how long the array should be. If you already know, then just
dimenion the array to the proper size:
dim myarray(100) or whatever size
If you don't know, then we'll have to figure it out based on the string. In your example, your string elements (the numbers) have a delimiter separating them - the comma ',' . A delimiter is a separator. It could be a space, a tab, a semicolon, really any character at all. It's your job to read the delimiters so you can figure out how to parse the string.
Back to the length of the array. Count the delimiters using the built in command MID$() and then dimension the array to the correct size. Based on the type of numbers (they look like integers) I'll create the array to hold integers.
stringsomething$ = "1,23,64,20,11"
rem get the string length
strln=len(stringsomething$)
rem look for commas
count=0
for n=1 to strln
if mid$(stringsomething$,n)=","
inc count
endif
next n
rem dimension the array
dim myintegers(count)
Anyway, once we have the array size, we can parse the string and store it. Here's the whole code:
stringsomething$ = "1,23,64,20,11"
rem get the string length
strln=len(stringsomething$)
rem look for commas
count=0
for n=1 to strln
if mid$(stringsomething$,n)=","
inc count
endif
next n
rem dimension the array
dim myintegers(count+1)
rem go through the string and store the values
position=0
for n=1 to strln
test$=mid$(stringsomething$,n)
rem if we hit a comma or the end of the string, we have our number and need to convert it
if test$="," or n=strln
inc position
rem an exception when the end of the string is reached to make sure the last value is read
if n=strln
num$=num$+test$
endif
myintegers(position)=int(val(num$))
rem clear the num$ holder
num$=chr$(0)
else
num$=num$+test$
endif
next n
rem print our new array of values
print "The original string was : ";stringsomething$
print "The array values are : "
for n=1 to position
print myintegers(n)
next n
This is a fairly straight forward way that should work most of the time depending on the complexity of your data. If you search the forums, you will find string libraries that others have made to make the handling of strings easier. There is no
Instr(pos,SUB$,BODY$) or
MID$(start,length)
natively in DBC, but they aren't too hard to make, and you will find lots of examples of them if you search through the forums.
Enjoy your day.