FM-Monster Posted February 5, 2007 Posted February 5, 2007 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...
Phillip Holmes Posted February 6, 2007 Posted February 6, 2007 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
FM-Monster Posted February 7, 2007 Author Posted February 7, 2007 (edited) 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, 2007 by Guest
comment Posted February 7, 2007 Posted February 7, 2007 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.
FM-Monster Posted February 8, 2007 Author Posted February 8, 2007 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.
comment Posted February 8, 2007 Posted February 8, 2007 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¶" ) & ....
Recommended Posts
This topic is 6500 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now