First you shoudl really check if you don't have a typo there. Like you set variable and spelled the variablename a little bit wrong. I often see that problem with l (like lion) and I (like Idaho).
Second with variables, people often run into scope problems. Like one script is in one database file and defines a variable and other script in other database defines same variable name, but as they are in different files, you actually have two variables.
And third with our plugin we have possibility of global variables with a few functions. This way you can store values which are accessible from everywhere as long as Filemaker runs.
And if you need persistance, you can use preferences functions, so the values survive a Filemaker restart:
I hope this helps you.
PS: Sometimes it helps to take off sunday, enjoy it with family and when you come back to office on Monday, you see the problem in a few minutes.
Of course we cannot pinpoint your problem without seeing your file (or at least the scripts that fail) but, although FM12 may have bugs, if globals and variables were failing there would be much of an uproar about it and I haven't read about it anywhere else.
In addition to Christian's advice, how are you setting the global values? Are you using Set Field or Paste or Insert Calculated? Paste and Insert Calculated require the field be on the layout at the time the script runs; if not, it will fail. With FileMaker, context is king so if you are setting related fields, it may be the context/relationship which is not correct. If you could provide a specific example of a break, it would be easier to give you the reason for it.
If you cannot post your file for review publicly, I would suggest that you contact a Developer that you are comfortable with and have them take a quick look privately.
Allegro said, "This happens intermittently and unpredictably ... in the past, I have found variables to be less reliable than globals."
Both are very reliable if you know the rules. The next time something doesn't work as expected, post about it immediately with the exact situation which is failing and we can help you understand why. In this way, you will learn for the next time something strange happens. There are always reasons - when you get a break in a process, it is a golden opportunity to learn more about FileMaker. Bypassing these precious opportunities will lead you to false assumptions and unnecessary work.
We will always be here to help you with it.
Just a few more options that caught me by surprise in the past:
- you may have used Get ( ScriptParameter ) where you should have used Get ( ScriptResult ) , or vice versa
- you may have set a persistant global field by opening the file locally instead of hosted in a server
besides the options mentioned above, global variables are very reliable and no need to doubt their performance.
Open the dataviewer and run the debugger to see at which point your global changes, there is always a logical explanation.
Unfortunately, I have not been saving versions of solution files where something doesn't work. My primary concern until this point has been to fix the bugs in the builds that my clients are seeing every day.
With regard to the advice given on variables. I am sure that I am setting them, spelling them, and using their scope correctly. I have been developing databases for about 30 years and all of them except FileMaker (until recently) use variables.
My question was about global fields and calc fields that don't seem to release their values and the problem, if I have not made it clear, appears to be that scripts -- and, more frequently -- individual script steps seem to be getting corrupt (i.e. just ceasing to function.) A relatively simple script, written correctly, that yeilds the correct result with the same data, suddenly stops working correctly (either stops working completely, or begins to return unpredictable results).
Re-writing the script, or script step, exactly as it was written orginally seemes to solve the problem. Copying the step (or the script), even from an earlier build where the problem was not detected, does not. Since this is a new, clean system, that seems to have adequate specs to run FMP12, and I don't know what is causing this issue, the only way of dealing with it has been to let the script (or steps) fail and fix them when they do. Very frustrating, as well as time consuming and therefore costly, to the client.
I would thoroughly investigate corruption in the file(s).