GerryGerry Posted December 16, 2004 Posted December 16, 2004 Hi, I want to avoid long "If/ElseIf...ElseIf/EndIf" sections in ScriptMaker by dynamically set a field. Please, let me explain... I have (among other fields) un-editable date fields (simply called date_01, date_02, etc.) and I don't want the users to edit these fields manually (to avoid month/day vs. day/month errors). Each date field has a "calendar" button that calls a script (with the field number as parameter). This script stores the parameter value in a dummy field then goes to a calendar layout where the user clicks on a day button (user can change year/month of course). This will trigger another script that brings him/her back to the original layout and fills the appropriate date field with the selected date (from the dummy field). This works great (it's all transparent to the user), but I'm worried about the future. I have just 8 date fields and my "back from calendar" script have enough "ElseIf" lines, but eventually I could end up with 16 (or more) date fields and I will have a very long script... Here's the QUESTION: Is there a way to dynamically specify a field in a "Set Field" script step? In other words, can I "Set Field [calculated field name; calculated/stored result]"? Thanks, -GerryGerry
-Queue- Posted December 16, 2004 Posted December 16, 2004 No, but if you have all the possible fields to be set on a single layout and their tab order is set consecutively, then you can run a loop like Go to Layout [{layout with fields to be set}] Commit Records/Requests [ ] Loop Go to Next Field If [Get(ActiveFieldName) = selectedfield] {replace with your specific test} Set Field [ ; dummyfieldvalue ] Go to Layout [Original] Exit Script End If End Loop The trick is not to specify a target field under the Set Field step, so that it operates on the currently selected field.
GerryGerry Posted December 16, 2004 Author Posted December 16, 2004 Hi, Thanks for the prompt response... But don't think this is the best solution for me. I don't want to depend on the tab-order because (like most projects) this is a work in progress. Eventually the tab-order will change according to other criteria. Plus, new fields will be added and others will be deleted in time... I don't want future developers to be mad at me because they changed a seemingly innocent tab-order and the solution broke. Thanks for the idea though (I will use it for other solutions for sure) I guess I will keep my long "If/ElseIf" script for now... -GerryGerry
-Queue- Posted December 16, 2004 Posted December 16, 2004 The tab order is merely to ensure that all fields on the layout are tested. This should be a special layout containing only the fields to be tested/set and should neither be visible nor modifiable by a user, so the tab order should be irrelevant to them. It's also easy to add the text 'DO NOT MODIFY THIS LAYOUT OR ITS TAB ORDER - IT IS REQUIRED FOR <SUCH AND SUCH> SCRIPT' or something similar to the layout for future developers. A deleted field poses no problems either; it will simply be removed from the layout and not included in the test.
GerryGerry Posted December 16, 2004 Author Posted December 16, 2004 Hi, Now that you put it that way... Yeap, it will work! I probably look like an idiot, hehehe... Thank you very much I will modify my script right now... -GerryGerry
Recommended Posts
This topic is 7285 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