Accepting data in form of column, converting to stringI'm trying to do the following:
Accept this input from user:
A1234965
A1233339
A1234736
A123494Z
A1233114
Convert it to the string: "A1234965,A1233339,A1234736,A123494Z,A1233114"
With no limit on how long the inputted "column" is. I want the user to paste the "column" into a popup window that asks for it, then store that data as the string above. My real problem is finding a way to accept that input from the user ("text edit box" won't let a column-format be pasted). Then, of course, I don't know how to convert that input into the string format I need. Any help would be appreciated. Thanks!
Automation and ScriptingRe: Accepting data in form of column, converting to stringUse the Concat Items() function
names default to here(1);
x={"aa","bb"};
y=concat items(x,",");Re: Accepting data in form of column, converting to stringYou will have to split the data first using Words() before using Concat Items(). Depending where the data is being pasted from, sometimes you might have to perform some substitutions before using Words(). These can be done with Regex() using GLOBALREPLACE or Substitute()/Substitute Into().
It also might be good idea to remove duplicates (Associative Arrays can be used for this, if it doesn't matter that they will be ordered alphabetically).
Re: Accepting data in form of column, converting to stringThank you, I'll definitely be using the concat function. My big problem is taking in the user input. They'd be copying a column from a datatable and pasting it into an edit box. In my current code (seen below), it'll only take the first cell of the copied column... I'm assuming this is because I'm using a "Text Edit Box" and the Text data type - is there an edit box and data type that could take data formatted like this?:
A1234965
A1233339
A1234736
A123494Z
A1233114
Here's my current code:
Lots = "abc";
w = New Window("Lot(s) of Interest",
Border Box(top(50), bottom(50), Left(50), Right(50),
V List Box(
H Center Box(Text Box("Lot(s) of Interest Input")),
Spacer Box(size(1, 30)),
H List Box(Text Box("Lots: "), b1 = Text Edit Box(Lots)),
Spacer Box(size(1, 10)),
H Center Box(
Button Box("Save",
Lots = b1 << get text;
w << closeWindow;
)
)
)
)
);Re: Accepting data in form of column, converting to stringHi @aidanweb ,
It sounds like you're set on how to parse the entry, but that the display of the entry is giving you issues. It may seem like the text edit box is only taking in one line when in fact all the lines are pasting just fine, but the height of the box isn't allowing you to see them (if you arrow up and down in the edit box you'll see the other lines).
What I would do is pre-size the edit box when making the dialog to roughly the expected size of the paste. You can do that by adding something like:
b1<<SETNLINES></SETNLINES>

I hope this helps!
@julian
Lots = "abc";
w = New Window("Lot(s) of Interest",
Border Box(top(50), bottom(50), Left(50), Right(50),
V List Box(
H Center Box(Text Box("Lot(s) of Interest Input")),
Spacer Box(size(1, 30)),
H List Box(Text Box("Lots: "), b1 = Text Edit Box(Lots)),
Spacer Box(size(1, 10)),
H Center Box(
Button Box("Save",
Lots = b1 << get text;
w << closeWindow;
)
)
)
)
);
b1<<SetNLines(10)<<set width(150);
Re: Accepting data in form of column, converting to string
Re: Accepting data in form of column, converting to stringLike I said earlier, use Words() to split it into a list. Then use Concat Items() to combine that list back to a string. It might be enough to use \!N as separator with Words() but sometimes it might not work correctly
Names Default To Here(1);
str = "abc
def";
lst = Words(str, "\!N");
str2 = "'" || Concat Items(lst, "','") || "'";
show(str, lst, str2);
Re: Accepting data in form of column, converting to stringThank you, this helps tons. I'm still having an issue converting the input into a list, formatted like so: {"aa", "bb", "cc"}. I would've thought the words function would work right away, as the input is just a long string.... but I'm probably doing something wrong. I attached a screenshot of my log.

Re: Accepting data in form of column, converting to stringYou missed including the appropriate delimiter in the Words() function. In your case you want an end of line character (or characters) as the delimiter. See the table of Escape Sequences for Quoted Strings in the JSL syntax rules.
Try this:
Names Default To Here( 1 );
Lots = "abc";
w = New Window( "Lot (s) of Interest",
Border Box( top( 50 ), bottom( 50 ), Left( 50 ), Right( 50 ),
V List Box(
H Center Box( Text Box( "Lot (s) of Interest Input" ) ),
Spacer Box( size( 1, 30 ) ),
H List Box( Text Box( ("Lots: ") ), b1 = Text Edit Box( Lots, <<SETNLINES></SETNLINES> //include the delimiters for carriage and new line in the Words() function
newlots = Words( Lots, "\!r\!n" );
Show( Lots );
Show( newlots );
)
)
)
)
);