Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Describe function knightmare !!!

Status
Not open for further replies.

PANTLORD

Programmer
Aug 28, 2001
49
0
0
EU
Hi there,

Just can't get a handle on this at all I have taken over support of a program that evaluates some quite hefy strings using IF(b,t,f) structure and I can't seem to get them to evaluate correctly at all. For instance;

=if ("VS" = "AG", "ans_1", if ("VS" = "PCD", "ans_2", if ("VS" = "CB", "ans_3", if ("VS" = "CB2", "ans_4", if ("VS" = "CB3", "ans_5", "unknown")))))

any ideas what is wrong with this string when I try and verify in the filter window of a datawindow it gives me various messages including 'Expecting string expression' and 'Expression does not evaluate'. Can anyoneidentify how to evaluate these things or point out the flaw in this paticular structure. Many thanks for your help.

Mully
 
It it not correct to evaluate such expression in the Filter window of a DW. You can drop a compute object into de DW, and put your expression in the compute object and press the Verify column, but not in the filter window, because this window will wait a valid expression to build a filter to filter the rows.

Lenin.
 
Hi there and thanks for the answer so far,

I've been digging into this some more and have found out the following. This code utilises a generic datawindow lds_eval with 1 field called eval_exp.

1 row (dummy data) is then imported into the field

a string is set up in the form; ls_eval = "evaluate('" + as_exp + "', 1)"

where as_exp is like - if ("VS" = "AG", "ans_1", if ("VS" = "PCD", "ans_2", if ("VS" = "CB", "ans_3", if ("VS" = "CB2", "ans_4", if ("VS" = "CB3", "ans_5", "unknown")))))

this line is then decribed within the datawindow using the following
as_result = lds_eval.Describe (ls_eval)

The trouble is I can't seem to get the as_exp strings in the correct format as a ! is always returned and this method seems to give no debug facilities at all so I am unsure why the string is failing. Are there any rules or places with example strings for this method ? and can values be cast etc in the string ?

Many thanks,
Mully
 
why dont u use a select case statement in the computed field instead of this messy if(b,t,f) statement. That would make life lot easier
 
We had a situation like that and I used a case which was much easier to read and understand.

case( app_type when "Zoning" then "Zoning (242800 - 100-0740-4334-00000)"
when "Building" then "Building/Storm Drain (242800 - 100-0750-4374-00000)"
when "Storm Drain" then "Building/Storm Drain (242800 - 100-0750-4374-00000)"
when "Electric" then "Electric (242700 - 100-0750-4376-00000)"
when "HVAC" then "HVAC (242001 - 100-0750-4377-00000)"
when "Plumbing" then "Plumbing (242900 - 100-0750-4378-00000)")

A case is faster than an if also since it only reads it from memory once then compares it multiple times versus reading it from memory at every if.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top