0
 Followers
4
 Likes

Local variables for an assignment widget

Frontend
On our radar
It would be nice to have a "local" scope for an assignment widget.

Sometime I have an assignment that ends up being a large expression (i.e. a lot of wrapped parsing functions to break a string down). 

Instead of making it one large expression I will usually break the bits down and do multiple "assignments" in one assign widget. 

To avoid redundant function calls I have to declare local parameters at the action level.

It would be nice if I could create "local/temp" variables that are only scoped within the assign widget to avoid polluting the actions local variables.
Created on 15 Nov 2010
Comments (2)
18 Nov 2010
Would a User-defined function be adequate to concatenate these values together?  This also makes the code reusable in other areas of your espace.
19 Nov 2010
A lot of times that would work.

But for some smaller little parsing things it's overkill.

For example, if I wanted to split the string "mypath/mypage" and assign the entries into the variables "path,page".  I would either have to do the split action twice and reference the index:

path = string_split(URL,"/")[0]
page = string_split(URL,"/")[1]

or create a temp record variable:

splitpath = string_split(URL,"/")
path = splitpath[0]
page = splitpath[1]


To me, the second way is more efficient. However, it forces me to create splitpath at the action level.  It would be nice if it could just exist at the assignment level.

views
222
Followers
0