Hello,
I would like to provide a list of parameters or variables from the window level (for example copied from excel) and pass this list (for example by clicking OK) further to create an another list for a SQL query. Can I do that with some type of List Box (something like in the picture below)? What other methods could be used to do that? Best regards.
Below is an example. Create function (parsePaste in example) to handle the input and do modifications you want to: remove duplicates, replace row changes with something, remove duplicated separators... After pressing OK this will return one string, then you can modify the returned string to fit in to your SQL (Words() and Concat Items() as examples).
Names Default To Here(1);
parsePaste = function({tempStr}, {Default Local},
tempStr = Regex(tempStr, "\r\n", ",", GLOBALREPLACE); //replace row changes with ,
tempStr = Substitute(tempStr, ",,", ","); //replace double ,, with one ,
tempStr = Regex(tempStr, ",$", "", GLOBALREPLACE); //remove , if last character
return(tempStr);
);
win2 = New Window("Example", << Modal,
V List Box(
Text Box("Add Serialnumbers:"),
teb = Text Edit Box("", << set width(200), << set nlines(3),
<< Set Function(Function({this},
this << set text(parsePaste(this << get text));
))
),
H List Box(
Button Box("OK", listStr = teb << get text),
Button Box("Cancel")
)
)
);
show(listStr);
temp = Words(listStr, ",");
temp = "'" || Concat Items(temp, "','") ||"'";
show(temp);
Couple of questions/ideas to get you going:
Check Scripting Index for: Modal (how to build modal window), List Box, Text Edit Box, Concat Items (how to convert JMP list into string)
Quick example with List Box which will set text box value below OK button and print selected values as list to log when ok is pressed:
Names Default To Here(1);
serialList = {"a1", "b2", "c3", "d4"};
win2 = New Window("Example",
V List Box(
lb = List Box(serialList, width(200), nlines(6)),
Button Box("OK", Show(lb << get selected); tb << Set Text(char(lb << get selected))),
tb = Text Box("");
)
);
Hello,
thank you for suggestions. I would like to be able to copy serial numbers from somewhere and then pass them further using parsing function, so the option 2 and together with modal window. I will try with Text Edit Box.
Best regards
Below is an example. Create function (parsePaste in example) to handle the input and do modifications you want to: remove duplicates, replace row changes with something, remove duplicated separators... After pressing OK this will return one string, then you can modify the returned string to fit in to your SQL (Words() and Concat Items() as examples).
Names Default To Here(1);
parsePaste = function({tempStr}, {Default Local},
tempStr = Regex(tempStr, "\r\n", ",", GLOBALREPLACE); //replace row changes with ,
tempStr = Substitute(tempStr, ",,", ","); //replace double ,, with one ,
tempStr = Regex(tempStr, ",$", "", GLOBALREPLACE); //remove , if last character
return(tempStr);
);
win2 = New Window("Example", << Modal,
V List Box(
Text Box("Add Serialnumbers:"),
teb = Text Edit Box("", << set width(200), << set nlines(3),
<< Set Function(Function({this},
this << set text(parsePaste(this << get text));
))
),
H List Box(
Button Box("OK", listStr = teb << get text),
Button Box("Cancel")
)
)
);
show(listStr);
temp = Words(listStr, ",");
temp = "'" || Concat Items(temp, "','") ||"'";
show(temp);
Hello, sorry for late response. This is exactly what I wanted to implement. Thank you very much. Best regards