|
Post by Psycho on Sept 1, 2009 18:52:08 GMT -5
In the following code example, I can have a static string variable equal a number utilizing the "using" command to format but when I use the same code for an array string variable, RB shows an error If you comment out the "test$(1)=...." line, it will run fine. x=3 y=7 dim test$(2) this$=using("##",x)+" | "+using("##",y) test$(1)=using("##",x)+" | "+using("##",y) print this$ print test$(1) John "Psycho" Siejkowski
|
|
Core
Junior Member
Posts: 54
|
Post by Core on Sept 1, 2009 21:46:17 GMT -5
That is interesting. No matter how you wrap it you get the error. What else is interesting is that if you add: test$(1) = this$
It works fine. Respectfully, Core
|
|
|
Post by rich357 on Sept 1, 2009 22:03:15 GMT -5
The purpose of "using" is to format a number in a manner suggested by the # string. That does not mean to say the formatting is allowed for use in strings. For instance if you have the format of (##,###.##) then technically the number 12345 would print showing as "12,345.00". When ever I tried using strings as you are, it generates an error.
|
|
|
Post by JackWebb on Sept 2, 2009 0:15:13 GMT -5
Interestingly enough, my old DOS compilers won't even allow this. Not QB or PB. Still tho.. if the first case worked in RB then the second case should also work. I say it's a bug. x = 3 y = 7
dim test$(2)
this$ = using("##", x) + " | " + using("##", y) test$ = using("##", y) + " | " + using("##", x)
test$(1) = test$
print this$ print test$(1)
|
|
|
Post by StefanPendl on Sept 2, 2009 3:08:48 GMT -5
RB is a bit picky about how you fill a string array.
The following is working x=3 y=7 dim test$(2) this$=using("##",x)+" | "+using("##",y) test$(1)=""+using("##",x)+" | "+using("##",y) print this$ print test$(1) end
Below find another thing, which is not recognized as a correct right-hand side for a string array, if you remove the leading empty string.
x=3 y=7 dim test$(2) that$ = x;" | ";y this$ = using("##",x)+" | "+using("##",y)
test$(1) = "";x;" | ";y test$(2) = ""+using("##",x)+" | "+using("##",y)
print that$ print this$ print test$(1) print test$(2) end
|
|