izmatic Posted June 9, 2007 Posted June 9, 2007 Hello! Is it possible to define a "Set Field" script by a calculation? I have a button with an array of data. And one of the pieces of information I would like to put in the array is what data to set in which field. But sometimes this button will place this data in a different field. I would like to tell the array which field to put the data in. Is this possible? Thanks for the help in advance!
DikkeHenk Posted June 9, 2007 Posted June 9, 2007 Hi Just looked for the same trick. Could not find it but figured out another (better solution for me) Put an extra field (_ArrayField) in the same table as your original target fields are in. Load your array in this field with the 'Set Field' script step. The array has to be seperated by 'returns' before you 'set' it in this field. If it isn't, use the substitute function in the 'Set Field' scriptstep. In your original target fields use the auto-enter option by calculation. Code in each original target field: Get value ( _ArrayField ; 'Array RowNR. of your targetdata corresponding to your single targetfield') Att. Do not forget to UNlock the replace data button The _ArrayField will always trigger your targetfields when the _ArrayField is entered with the Array. It has to be in the same table and you can use globals also. You only have to use the 'set field' script step once in this case. The auto-enter in your original target fields will do the rest. Henk
izmatic Posted June 9, 2007 Author Posted June 9, 2007 Thanks for the reply. I should have mentioned that I am trying to set fields in other tables. For example, I wanted to send a primary key from table 1 to a foreign key field in table two, using a script. (Along with other data in the array) The way I have it set up right now is that each button sends a script parameter in the array. Then that script parameter is then looked up using If and Else statements. For example: If [GetValue(Get(ScriptParameter );1="button1"] Set Field [table2::foreign_ID ; GetValue(Get(ScriptParameter );2)] And this continues using "Else If" statements. I have many tables (40+ tables, mainly for data tunneling) and would like to reuse the script with out making the script too long, using If and Else statements. Maybe this is not good database/script practice?
izmatic Posted June 9, 2007 Author Posted June 9, 2007 I guess, basically, I wanted to make my buttons dynamic, and being able to change what happens, not in the script, but in the script parameters I send through my buttons. Again, I'm not sure if this is good practice.
Søren Dyhr Posted June 10, 2007 Posted June 10, 2007 Take a look here: http://fmforums.com/forum/showtopic.php?tid/179836/post/219571/hl/%22Set+field%22+indirection/ --sd
izmatic Posted June 10, 2007 Author Posted June 10, 2007 This is a GREAT tip for future reference. But this will not work in my situation because the fields I want to set are not in the layout. But I really like that example, and will definitely use it with other things
Søren Dyhr Posted June 10, 2007 Posted June 10, 2007 Then make an extra layout, the overhead required is next to none, alternatively use an invisible tab on the same layout where you then make a series of Go To Object's, instead of the cascades of Go To Next field. --sd
comment Posted June 11, 2007 Posted June 11, 2007 There might be plenty of other solutions available (or not). Unfortunately, the problem is not very clear. What does "a button with an array of data" mean? If there are multiple fields into which the same piece of data can go, that would, in most cases, indicate a bad data structure.
Søren Dyhr Posted June 11, 2007 Posted June 11, 2007 If there are multiple fields into which the same piece of data can go, that would, in most cases, indicate a bad data structure. Should we take turns, I have a seat in the balcony ready for you! http://en.wikipedia.org/wiki/Statler_&_Waldorf --sd
Søren Dyhr Posted June 11, 2007 Posted June 11, 2007 As long as you issue, at least one question mark for each question you reply, can you sit there comfy and without worrying, if the railings of the balcony will keep. --sd
Recommended Posts
This topic is 6435 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