Using a variable as default in a formtext


#1

I'm trying to use a variable as the default= to a formtext: command, but am having problems getting the correct syntax, if it's even possible. Any suggestions/thoughts would be great appreciated!

My actual snippet is more complex, but here is an example of what I'm trying to do and am having problems with:

{RawData={clipboard}}
{ListData=split(RawData, ",")}
{formtext: name=Item1; default={=ListData[1]}}

I'm trying to take raw data from the clipboard, parse it into a list, then present each item from the list in a text field to allow me to modify the list item if necessary before continuing. The formtext: command above results in an error: [Error - Invalid default value for form command.]
I've tried other variations on the default= parameter, but haven't had any success yet. Hopefully, I'm just missing something obvious that someone can point out to me.

Thanks in advance!


#3

Hi Chad,

Assigned variables can't be used as form value defaults currently.

You can do what you want if you inline the all the calculations directly into the default definition like the following:

{formtext: name=Item1; default={=split("a,b,c", ",")[1]}}
{formtext: name=Item1; default={=split({clipboard}, ",")[1]}}


#4

This also works

{Item1={=split("a,b,c", ",")[1]}}
{formtext: name=Item1}


#5

Here's another idea:

  1. Put your values in a spreadsheet
  2. Use the concatenate command to bring them all in one cell and separate them by a comma. Something like this: =CONCATENATE(C2,",",D2,",",E2)
  3. Copy the output of that cell into your clipboard
  4. Use the following snippet:

{Item1={=split({clipboard}, ",")[1]}}
{Item2={=split({clipboard}, ",")[2]}}
{Item3={=split({clipboard}, ",")[3]}}
{formtext: name=Item1}
{formtext: name=Item2}
{formtext: name=Item3}


#6

These are very good and workable solutions. My form is somewhat complex and I'm not sure exactly what I'll end up using, but these examples are exactly what I needed to get me moving forward again.

Thank you very much to all of you!


#7

I'm glad we were of some help. If you have more scenarios, do post them here and we'll try to figure them out together. Scott has some brilliant stuff under the hood of this ap he's built. I'm sure we're still just scratching the surface.