Subscribe Bookmark RSS Feed

using dialog input to populate query

I am trying to use a user dialog to choose some options, and then use those options in a sql query. So the dialog box would be something like:

_________________________________________________________
mydialog = Dialog(
title( "Query" ),
vlist(
"Start date",
startdate = EditText( "m/d/yy" ),
"End date",
enddate = EditText( "m/d/yy" ),
Name1 = Check Box( "Tom", 1 ),
Name2 = Check Box( "Bill", 1 ),
Name3 = Check Box( "Mary", 1 ),
Name4 = Check Box( "Sue", 1 ),

),
hlist( Button( "OK" ), Button( "Cancel" ), ),

);

__________________________________________________________

Then I want to use the choices in a sql query something like:

SELECT * from tEmployees WHERE (ColumnName LIKE 'Name1' OR ColumnName LIKE 'Name2' OR ColumnName LIKE 'Name3') etc. etc.

I can make it work if the choices in the dialog are always the same. What I'm struggling with is adapting it to account for the user just selecting one name vs. all four names. I've been trying to get a for-loop to work but haven't had much success. Does anyone have any tips?

Thanks.
Clark
6 REPLIES
djdaniel

Community Member

Joined:

Jun 23, 2011

Try using a Radio Box if you want the user to choose only one option.

Regards
pmroz

Super User

Joined:

Jun 23, 2011


style="font-size: 10pt; font-family: "Arial","sans-serif";">This
should work for you. 
I’m using NEW
WINDOW instead of DIALOG, which
is obsolete in JMP 9.





style="font-size: 10pt; font-family: "Arial","sans-serif";">

 





style="font-size: 10pt; font-family: "Arial","sans-serif";">Regards,





style="font-size: 10pt; font-family: "Arial","sans-serif";">Peter





style="font-size: 10pt; font-family: "Arial","sans-serif";">

 





style="font-size: 10pt; font-family: "Courier New"; color: green;">/*





style="font-size: 10pt; font-family: "Courier New"; color: green;">Build
a query from a checkbox:





style="font-size: 10pt; font-family: "Courier New"; color: green;">

 





style="font-size: 10pt; font-family: "Courier New"; color: green;">SELECT
* from tEmployees





style="font-size: 10pt; font-family: "Courier New"; color: green;">WHERE
(ColumnName LIKE 'Name1' OR
ColumnName LIKE 'Name2' OR ColumnName LIKE 'Name3') etc. etc.





style="font-size: 10pt; font-family: "Courier New"; color: green;">

 





style="font-size: 10pt; font-family: "Courier New"; color: green;">*/

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"SELECT
*
from tEmployees WHERE ("

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">

 





style="font-size: 10pt; font-family: "Courier New"; color: black;">name_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">
{

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Tom"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Bill"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Mary"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Sue"

style="font-size: 10pt; font-family: "Courier New"; color: black;">}

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">

 





style="font-size: 10pt; font-family: "Courier New"; color: black;">mywin

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">new
window

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Query"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">     

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">vlistbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">hlistbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">textbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Start
date"

style="font-size: 10pt; font-family: "Courier New"; color: black;">)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 
startdate

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">texteditbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"m/d/yy"

style="font-size: 10pt; font-family: "Courier New"; color: black;">
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">hlistbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">textbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"End
date"

style="font-size: 10pt; font-family: "Courier New"; color: black;">)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 
enddate

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">texteditbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"m/d/yy"

style="font-size: 10pt; font-family: "Courier New"; color: black;">
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           
name_cb

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">Check
Box

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">name_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
set(

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: black;">)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
set(

style="font-size: 10pt; font-family: "Courier New"; color: teal;">2

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: black;">)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
set (

style="font-size: 10pt; font-family: "Courier New"; color: teal;">3

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: black;">)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
set(

style="font-size: 10pt; font-family: "Courier New"; color: teal;">4

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: black;">))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">     
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">     

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">hlistbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">Buttonbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"OK"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 
selected_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">
name_cb

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
get selected

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">for

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(i

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
i

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">nitems

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">selected_list)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
i

style="font-size: 10pt; font-family: "Courier New"; color: navy;">++,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                       

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(i

style="font-size: 10pt; font-family: "Courier New"; color: navy;">==

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: teal;">1

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                       

style="font-size: 10pt; font-family: "Courier New"; color: green;">//
then

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                            
sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">
sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"ColumnName
LIKE '"

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">
selected_list[i]

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"'"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                       

style="font-size: 10pt; font-family: "Courier New"; color: green;">//
else

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                       

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                             
sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">
sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"
OR
ColumnName LIKE '"

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">
selected_list[i]

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"'"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                       
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">

 





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 
sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">
sql_query

style="font-size: 10pt; font-family: "Courier New"; color: navy;">||

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">")"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">

 





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">                 
mywin

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
close window)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">           

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">Buttonbox

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Cancel"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
mywin

style="font-size: 10pt; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; font-family: "Courier New"; color: black;">
close window )





style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="">     
)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">)

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">

 

This is a code that I was using in JMP7. You can see some useful ideas here.
<-----------
Clear Globals();
dlg = Dialog(
Line Up( 2,
"Parameter Number", Parmnum = Edit Text("2"),
"Legend: ", "2=Rd,4=Amp,92=As,231=QS,1015=AsSD"
),"","Date Covered:","",
Line Up( 2,
"Start Date:", StartDate = Edit Text("'2008-04-11-00.00.00.000000'"),
"End Date: ", EndDate = Edit Text("'2008-04-17-00.00.00.000000'")
),
V List(
"Select Model",
Product = Radio Buttons( "BR", "DO","FA" )
),
Rawdata = Check Box( "Show raw data", 1 ),
SaveJourn = Check Box( "SaveJournal", 1 ),
H List( Button( "OK" ), Button( "Cancel" ) )
);
If( dlg["Button"] == -1, Throw( "User cancelled" ) );
Remove From( dlg ); Eval List( dlg );
if (
Parmnum=="2",ll=100;ul=800,Parmnum=="4",ll=3000;ul=25000,Parmnum=="92",ll=-50;ul=50,Parmnum=="231",ll=10;ul=60,Parmnum=="1015",ll=0;ul=20,
CAPTION("You entered a wrong parameter number.
Please try again. Right click to close this message.
>>rey :-)");
Throw( "User cancelled")
);
text1= "tb=open database(";
text2= "DSN=DB;UID=reynald;PWD=xxx;MODE=SHARE;DBALIAS=DB;";
text3 = "FRBQ";
SQL_string1="select * from table where column in (";

SQL_String2=char(Parmnum);
SQL_string3= ")and storets>=";
SQL_String4=char(StartDate);
SQL_String5="and storets<=";
SQL_String6=char(EndDate);


if(
Product == 1,SQL_String7 = "and HTM in (46,47,58,59)",
Product==2, SQL_String7 = "and HTM in (42,43,60,61)",
Product==3, SQL_String7 = "and HTM in (56,57,62,63)");

SQL_Command = SQL_String1 || SQL_String2 || SQL_String3 || SQL_String4 || SQL_String5 || SQL_String6 || SQL_String7;

command = text1 || "\!"" || text2 || "\!"" || ",\!"" || SQL_Command || "\!"" || ",\!"" || text3 ||"\!")";

dlg = Dialog(
"NOTICE:",
"You are about to start downloading a huge volume of data, this may take time. Please be patient.",
"Do you want ot continue?",
H List( Button( "OK" ), Button( "Cancel" ) )
);

If( dlg["Button"] == -1, Throw( "User cancelled" ) );
eval(parse(command));
---------->
SQL_String6=char(EndDate);


if(
Product == 1,SQL_String7 = "and HTM in (46,47,58,59)",
Product==2, SQL_String7 = "and HTM in (42,43,60,61)",
Product==3, SQL_String7 = "and HTM in (56,57,62,63)");

SQL_Command = SQL_String1 || SQL_String2 || SQL_String3 || SQL_String4 || SQL_String5 || SQL_String6 || SQL_String7;

command = text1 || "\!"" || text2 || "\!"" || ",\!"" || SQL_Command || "\!"" || ",\!"" || text3 ||"\!")";

dlg = Dialog(
"NOTICE:",
"You are about to start downloading a huge volume of data, this may take time. Please be patient.",
"Do you want ot continue?",
H List( Button( "OK" ), Button( "Cancel" ) )
);

If( dlg["Button"] == -1, Throw( "User cancelled" ) );
eval(parse(command));
---------->
Thanks to both of you. I took some ideas from each of your scripts and got something working. I appreciate the help.