PDA

View Full Version : Using Eval() in query definition


ABC123

Graham Wickens
02-07-2005, 01:33 AM
The following script is to list one of the codes listed on a radio button. I get "error 0 occurred at line 18" which is the definition of the query filter. What am I doing wrong?
tia

dim r1 as c
r1 = ui_get_radio("Code Listing",1,"ICAO","IATA","FAA","ATI","Other")
IF r1 = "" THEN
goto done
END IF
r1=r1+"_code"
tbl = table.open("bases")
'' query.filter = ".not.(icao_code = '')"
'' query.order = "icao_code"
query.filter = ".not.("+eval(r1)+" = '')"
query.order = eval(r1)
indx=tbl.query_create()
rec_count=indx.records_get()
IF rec_count = 0 THEN
ui_msg_box("Code Listing",quote(r1)+" not found on file",UI_OK)
indx.close()
goto done
END IF
tbl.fetch_first()
done:
end

Stan Mathews
02-07-2005, 04:24 AM
Substituting a value in the interactive editor

r1 = "ICAO"
? ".not.("+eval(r1)+" = '')"
ERROR: ICAO not found.

Modified slightly

? ".not. " + r1 + " = \"\""
= .not. ICAO = ""

which should be the filter construct you want.