Page 1 of 1

About that @@ feature

PostPosted: Wed Jan 21, 2015 8:58 pm
by claude.rivet
I think I need help with a small script, here goes an example:

Code: Select all
tblocator = 500
for 1 to 15
tbstring = textbox
tblocator+ = 1
VAdd,tbstring,tbstring,tblocator
tbstring+ = .text
WDCustomScriptText, for.index, @@tbstring
next


Rather than returning the value of textbox501.text for example, in returns the string "tbstring". AM I missing something in my macro for it to return the value of textbox501.text?

Thank you!
regards

Re: About that @@ feature

PostPosted: Wed Jan 21, 2015 11:20 pm
by malkuth23
to change the value of a variable use:
Code: Select all
varX += 1

not
Code: Select all
varX+ = 1

What is:
Code: Select all
tbstring+ = .text
supposed to do?

Also, I don't think you need the @@ blocking characters.
Also, lose the spaces after the commas in your scripts. I believe they interfere.
You did not really say what you trying to do...

Re: About that @@ feature

PostPosted: Thu Jan 22, 2015 8:24 pm
by claude.rivet
What is:
Code: Select all
tbstring+ = .text

supposed to do?


Append .text at the end of the variable value

let's say I want to create a loop that would change the name of a bunch of buttons according to what the user entered in textboxes. The button are numbered 1 to 15 and the textboxes are numbered 501 to 515

I need to

Code: Select all
WDCustomScriptText, 1, textbox501.text


for each button, but I chose to make this in a loop so I "build" the name using a string variable

Code: Select all
tblocator = 500
for 1 to 15
tbstring = textbox
tblocator+ = 1
VAdd,tbstring,tbstring,tblocator
tbstring+ = .text
WDCustomScriptText, for.index, @@tbstring
next


tbstring on the first iteration of the loop will be "textbox501.text", it is I verified, the @@ basically should return the value of textbox501.text rather than the string contained in tbstring which is "textbox501.text".

Somehow it doesn't and I was wondering if that feature was upcoming or if it was already implemented and if it's the case, what am I doing wrong?

Re: About that @@ feature

PostPosted: Fri Jan 23, 2015 12:04 am
by malkuth23
I think the += command only works with numeric values.

To append text I think you would need to use the VAdd script.

VAdd,VarName,Var1,Var2

So...

vadd,tbstring,tbstring,.text

But, I am not sure you will be able to use the period as that may be reserved for something else. This is why WD needs better blocking functions.
My solution in the past for things like this was to combine the text in nodes using the text combiner, then use the variable in a script.
I know it is ugly, but it did work.

Re: About that @@ feature

PostPosted: Fri Jan 23, 2015 5:28 pm
by claude.rivet
The problem isn't building the string, it works, it's easy to verify and I did, the resulting string IS textbox501.text on the first iteration and it is textbox502.text on the second and so on and so forth.

Code: Select all
WDCustomScriptText,1,textbox501.text


works, it does name the button according to what is located in textbox 501

What doesn't work is that using @@ before the string variable name (in this case tbstring) should return the value of the object referenced by the string rather than the string itself and it doesn't.

Re: About that @@ feature

PostPosted: Fri Jan 23, 2015 6:18 pm
by malkuth23
Gotcha. Sorry about that.
Hopefully someone from Germany responds then... Sounds like a bug.

Re: About that @@ feature

PostPosted: Tue Jan 27, 2015 1:31 am
by florian
If I understand correctly, you are attempting to use the contents of a string variable to refer to another variable, correct?

Are there other examples of this concept working? I ask because it seems kind of suspect to me. In most programming languages there is a distinction between variable keys (names) and their values, it doesn't quite make sense to me to say (in pseudocode):

Code: Select all
string foo = "Hello World!";
string bar = "foo";
print $bar; // <----Here you expect the command interpreter to access bar, retrieve "foo" and feed this to the print statement so that it will return "Hello World!" ????


The issue being that print doesn't know to handle the variable you are feeding it in this way. I would assume that WDScript's "WDCustomScriptText" function isn't expecting to have to parse out your variable in search of a string that points to another variable. It just grabs the string and does that one thing it does.

If I am wrong about this I'd really like to know. I haven't been paying too much attention to recent developments in WDScript world.

Cheers!

Re: About that @@ feature

PostPosted: Wed Mar 30, 2016 8:32 am
by schoissi
hi,
as florian wrote,
this is exactly what i'm currently looking for.

is it possible to "pass" the value of a variable into another?

thx,
Roman

Re: About that @@ feature

PostPosted: Wed Mar 30, 2016 3:29 pm
by florian
programming generally doesn't work this way, for a whole bunch of reasons.

if you create a new thread explaining what you want to do exactly it's likely that someone here could help you solve your problem in a saner way.

for example:
having several different variables in which you store data, and then being able to select which one you want to pull the string from at run-time usually means that rather than having a bunch of names you keep track of for variables, what you probably really wanted was an array. they're cleaner and don't have arbitrary names. integer indexing also means that you can programatically select the one you want instead of creating a lookup list of 'if' statements to pick the right one.

Re: About that @@ feature

PostPosted: Mon Apr 04, 2016 1:36 pm
by Thomas Mrozek
Hi All,
the @@ command is not processed in the way you are expecting, it is not processing the textbox contents. You'll have to use vgettextbox command as
Code: Select all
tblocator = 500
for 1 to 5
tblocator += 1
VGetTextboxText,gettext,tblocator
WDCustomScriptText, for.index,gettext
next

Is that what you wanted to do?
cheers
Thomas