Is there a way to swap out the name of a constant using a variable?
for example, in the procedure below, can I change #String_partno_line0 to #String_partno_line+x?
so that I don't have to type the SetGadgetText(#string_partno_line... 100 times?
Procedure printgrid()
For x = 1 To 100
SetGadgetText(#String_partno_line0,partno1$(x))
Next x
EndProcedure
Thanks,
Mike...
Is there a way to swap out the name of a constant using a
Re: Is there a way to swap out the name of a constant using
Hi mikeschn,
welcome to the Pb-Forum. You gave the answer yourself:
Of course, this will only run, if all your constants are in ascending sequence.
P.S.: Please use the tags if you publish code-snippets.
Josh
welcome to the Pb-Forum. You gave the answer yourself:
Code: Select all
Procedure printgrid()
For x = 0 To 99
SetGadgetText(#String_partno_line0 + x, partno1$(x))
Next x
EndProcedure
P.S.: Please use the tags if you publish code-snippets.
Josh
sorry for my bad english
Re: Is there a way to swap out the name of a constant using
That worked! I made sure my constants were in some kind of order, and got the value of the first constant in the series...

Code: Select all
Procedure printgrid()
partno_control_number = #String_partno_line0
partname_control_number = #String_partname_line0
vol_control_number = #String_vol_line0
den_control_number = #String_den_line0
mass_control_number = #String_mass_line0
For k = 0 To 9
SetGadgetText(partno_control_number+k,partno1$(k))
SetGadgetText(partname_control_number+k, partname1$(k))
SetGadgetText(vol_control_number+k, StrF(volume1(k),2))
SetGadgetText(den_control_number+k, StrF(density1(k),8))
SetGadgetText(mass_control_number+k, StrF(mass1(k),3))
Next k
EndProcedure
Re: Is there a way to swap out the name of a constant using
I think this one is better:
Greetings - Thomas
Code: Select all
Enumeration
#String_partno_line0
#String_partname_line0
#String_vol_line0
#String_den_line0
#String_mass_line0
EndEnumeration
Procedure printgrid()
Protected k
For k = 0 To 9
SetGadgetText(#String_partno_line0 + k, partno1$(k))
SetGadgetText(#String_partname_line0 + k, partname1$(k))
SetGadgetText(#String_vol_line0 + k, StrF(volume1(k), 2))
SetGadgetText(#String_den_line0 + k, StrF(density1(k), 8))
SetGadgetText(#String_mass_line0 + k, StrF(mass1(k), 3))
Next k
EndProcedure
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
