February 5, 200719 yr I want to write a script that will use the same criteria for a find (like ">0") but I want to use a parameter so that I can set the find to a different field each time I use the script. It seems like it would be very easy...I think I'm just overlooking something. But I can't figure out how to write the script so it keeps the criteria for the find but performs that find on a different field(that would be assigned by the parameter). Please help if you can...
February 6, 200719 yr Hello Are you thinking of something like this. Set Variable[$Field; Value:Get(ActiveFieldName)] Enter Find Mode[] Set Field[$Field;">0"] Perform Find[] If(Get(LastError)=401) do something EndIF
February 7, 200719 yr Author Phillip: I tried to use the script that you had but I couldn't get the set field to work... Any other ideas. Maybe there isn't a way to do it and I have to wirte 10 different scripts. It just seems that there has to be a way you can save a find in a script and apply it to different fields without having to write a new script every time you want to use the find. Edited February 7, 200719 yr by Guest
February 7, 200719 yr It's not possible to dynamically specify find criteria or which field to set. You COULD write one script along the lines of: If [ Get(ScriptParameter) = 1 ] Perform Find [ Specified Find Requests: Find Records; Criteria: Table::Field1: “>0” ] [ Restore ] Else If [ Get(ScriptParameter) = 2 ] Perform Find [ Specified Find Requests: Find Records; Criteria: Table::Field2: “>0” ] [ Restore ] Else If [ Get(ScriptParameter) = 3 ] ... There are other methods that involve looping between fields on the layout until the field name matches the script parameter - not pretty. Why should this be needed at all? Usually, such request indicates a problem in the data structure.
February 8, 200719 yr Author Thanks for the help... The finds are to locate errors or things that need to be done in the database--like items entered on an invoice but not billed ... I just created the finds. It didn't take long.
February 8, 200719 yr It's a rather sketchy description, but it seems you could do this with one ErrorCode field, like: Let ( [ error1 = IsEmpty ( Field1 ) ; error2 = Field2 > 100 ; error3 = something and not something else ; error4 = ... ... ] ; error1 + 2 * error2 + 4 * error3 + 8 * error4 + 16 * error5 ... ) And perhaps another field to decipher the code into human language, like: Case ( Mod ( ErrorCode ; 2 ) ; "Error1: Field1 is empty¶" ) & Case ( Mod ( Div ( ErrorCode ; 2 ) ; 2 ) ; "Error 002: Field2 is over the limit¶" ) & Case ( Mod ( Div ( ErrorCode ; 4 ) ; 2 ) ; "Error 003: something is orphaned¶" ) & Case ( Mod ( Div ( ErrorCode ; 8 ) ; 2 ) ; "Error 004: xyz¶" ) & ....
Create an account or sign in to comment