Page 1 of 1 1
Topic Options
#209452 - 2014-09-07 08:22 AM variable names
Statler Offline
Fresh Scripter

Registered: 2004-09-25
Posts: 11
Hereīs a part of a script:

$text0 = $project.controls.label
$text0.text = "test 1"
...
$text1 = $project.controls.label
$text1.text = "test 2"
...
$text2 =$project.controls.label
$text2.text = "test 3"
...

My question is, if there is a possibility to increase the digits in $text... automatically

Something like that
for $x = 0 to 10
$text$x = ....
I know that this is not possible that way, itīs only to demonstrate what I mean. But perhaps there is another way to increase the names of These vairables automatically?

Thanks
Statler

Top
#209453 - 2014-09-07 01:56 PM Re: variable names [Re: Statler]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Use Execute:
 Code:
For $x = 0 To 9
  ; 'Assigning VTest_' $X ?
  $ = Execute("$$VTest_$X = 'Test number ' + $X") ; assign value to constructed var name
Next

;display a few to verify
$VTest_0 ?
$VTest_1 ?
$VTest_2 ?
Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209454 - 2014-09-07 03:42 PM Re: variable names [Re: Glenn Barnas]
Statler Offline
Fresh Scripter

Registered: 2004-09-25
Posts: 11
Great, Thank you :=))

Statler

Top
#209455 - 2014-09-07 11:22 PM Re: variable names [Re: Statler]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
How about just using arrays instead?
 Code:
dim texts[9]
for $counter=0 to 9
  $texts[$counter] = $project.controls.label
  $texts[$counter].text = "test "+$counter
Next
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.058 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org