Page 1 of 1

Optimizing variable declarations [SOLVED]

Posted: Fri Apr 04, 2014 9:44 am
by atout66
Hi to all,

I'm wondering if there is a way to optimize multiple variable declarations of the same type...
Let say I have to empty many fields with different names each; NOT like "fld01", "fld02", and so on, which I could instantiate by a repeat loop.
In few words, how can I avoid this:

Code: Select all

put empty into fld "myFld"
put empty into fld "myOtherFld"
put empty into fld "otherFld"
etc.
I tried this without success:

Code: Select all

put empty into fld "myFld" , "myOtherFld" ,  "otherFld"
Any idea around ?

Re: Optimizing variable declarations

Posted: Fri Apr 04, 2014 9:58 am
by Thierry
atout66 wrote:Hi to all,
I tried this without success:

Code: Select all

put empty into fld "myFld" , "myOtherFld" ,  "otherFld"
Any idea around ?
Bonjour,

what about this:

Code: Select all

put "myFld" , "myOtherFld" ,  "otherFld" into ListOfFieldsToEmpty

repeat for each item aField in ListOfFieldsToEmpty
     put empty into field aField
end repeat
Regards,

Thierry

Re: Optimizing variable declarations

Posted: Fri Apr 04, 2014 1:09 pm
by atout66
You've got it Thierry, merci beaucoup :wink:
It was the right approach, a loop...

Cheers

Re: Optimizing variable declarations [SOLVED]

Posted: Fri Apr 04, 2014 2:13 pm
by dunbarx
Hi.

What Thierry said.

if this is a significant task for you, I would consider keeping that list of fields in a custom property. You can add or subtract field names as required as you work your project, and anytime you need to:

Code: Select all

repeat for each item aField in ListOfFieldsToEmpty --this is now the custom prop name, as opposed to a variable that you manage
     put empty into field aField
end repeat
A small enhancement, but I bet it will be simpler.

Craig Newman

Re: Optimizing variable declarations [SOLVED]

Posted: Fri Apr 04, 2014 2:37 pm
by atout66
Really good idea Craig, I'll do that instead of to reinvent the wheal :wink: