passing values between variables

Moderator: Moderator Group

passing values between variables

Postby schoissi » Wed Mar 30, 2016 9:29 pm

hi

here's some code i'm trying to run...

all variables are created prior the for loop runs, except the variables, na1, na2, na3,... which should be created on the fly during the for loop, see further down...
"undsc" is just a String Variable holding a " " to create a space between two entries...
Label9.text is just for visual reference of the for loop current state...

Code: Select all
For 1 to 999

Label9.text = for.index

// prepare for cell calc, cell1 FirstName and cell2 LastName
WDTextboxAppendTextOnly,991,b
WDTextboxAppend,991,for.index
VGetTextboxText,cell1,991

WDTextboxAppendTextOnly,992,c
WDTextboxAppend,992,for.index
VGetTextboxText,cell2,992

VGetExcelCellValue,npf1,C:\coolux\WD_Projects\excel test\TestWD.xlsx,tab1,cell1
VGetExcelCellValue,npl1,C:\coolux\WD_Projects\excel test\TestWD.xlsx,tab1,cell2

WDTextboxAppend,1,npf1
WDTextboxappend,1,undsc
WDTextboxAppend,1,npl1

VGetTextboxText,fullname,1


it works fine, pulls the values from the excel cells and stores it combined in variable "fullname"
i use the textboxes to create the "correct" values for my variable to pull the data from the correct excel cell.

because it's a for loop, it should work for up to 999 entries,
each entry (finally) of the for loop shall create a new variable called na1, na2, na3,... up to na999

so, continueing from the last line of code above,
in the same for loop

Code: Select all
// prepare for final string variable
WDTextboxAppendTextOnly,993,na
WDTextboxAppend,993,for.index
VGetTextboxText,namestr,993
WDWait,0.2
VString,namestr,fullname

//namestr = fullname
VValue,namestr,fullname
//VValue,na1,fullname

WDWait,0.2
WDTextboxClear,1
WDTextboxClear,991
WDTextboxClear,992
WDTextboxClear,993

Next


"namestr" should create, increasing with the for loop, the variables na1, na2,...
in each cycle of the loop, the current na... variable should get the value of "fullname", which represents the current data pulled from the excel cell.

i'm sure it's a basic thing i'm missing here, still new to programming...

all the best,
Roman
schoissi
 
Posts: 74
Joined: Thu Jan 01, 2009 9:48 pm
Location: Seattle, USA

Re: passing values between variables

Postby Dennis Kuypers » Wed Mar 30, 2016 10:37 pm

Hello,

that is what arrays are for. An array basically is a list of variable under one name. If you want to access a value you put varname[index], that will return the index'th entry in the list. You can use the VArray* scripts to resize, set and get the values.

Dennis
Dennis Kuypers
Product Developer, Software

Online Manual
User avatar
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm

Re: passing values between variables

Postby schoissi » Mon Apr 04, 2016 7:53 am

@ Dennis,
thx a lot.

it took some time to figure out that each new line in a textbox will create a new array entry,
however, now that i know it, the whole thing makes sense... :-)

all the best,
Roman
schoissi
 
Posts: 74
Joined: Thu Jan 01, 2009 9:48 pm
Location: Seattle, USA


Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 6 guests