spankalee Posted March 9, 2004 Posted March 9, 2004 I hate creating a bunch of global fields as a replacement for script variables. I can be a real problem if two people run a script at the same time. I haven't seen any mention of this yet though... any one know? Looks like an awesome update though. I've been frustrated with FM for a long time, but I think they've fixed a lot of what bothered me.
andygaunt Posted March 9, 2004 Posted March 9, 2004 you can pass a variable with a script called from a button. eg, you want to have an address book and have 26 buttons (A-Z). No longer do you have 26 scripts Find A - Find B etc. You have one script and on each letter button you pass the variable you want to the script.
Colleen Posted March 9, 2004 Posted March 9, 2004 In addition to being able to pass a Script Parameter (variable) to a script via a button, you can also pass a parameter to another script. In both cases you can pass either a text string or the result of a calculation. [it is important to note that you need not create a calculated field, but rather the Script Parameter dialog includes a calculation dialog box.] Script Parameters are just one of the many new powerful features available in FileMaker 7. For more valuable info on the new product check out the following: http://www.filemaker.com/upgrade/techbriefs.html Colleen Hammersley DataWaves FileMaker Solutions Alliance Partner Member
spankalee Posted March 9, 2004 Author Posted March 9, 2004 Yeah, I read the techbriefs, but they don't shed too much light on what's new in ScriptMaker, other than most changes are innocuous. Passing parameters is a massive improvement, but variables are much needed too. (btw, I had intended my post to go into the "New FileMaker 7 Line" thread, but I changed the subject. oops. If a mod can merge them, this doesn't really need it's own thread) I also couldn't find out if FM could now to multiple table joins line in SQL. Getting rid of the "one table away" problem is great, now I want to be able to use three or four tables together to find certain records. It seems like relationships have been completely overhauled, so I wouldn't be surprised, but I can't find any detailed specifics.
Steven H. Blackwell Posted March 9, 2004 Posted March 9, 2004 Scripts can have local variables in the calculation area using the new "Let" function. Steven
Ocean West Posted March 9, 2004 Posted March 9, 2004 - The let function Format Let({[}var1=expression1{;var2=expression2...]};calculation) Parameters var = any variable name (see About naming fields for guidelines on naming variables) expression = any calculation expression, field, or constant calculation = any calculation expression, field, or constant Parameters in curly braces { } are optional. Data type returned text, number, date, time, timestamp, container Description Sets varX to the result of expressionX for the duration of calculation. Multiple variables are allowed when using a list syntax that is enclosed in square brackets [ ] and is separated by semicolons. For example: Let({[}variable=value{;variable2=value2]};calculation) The Let function sets the variables from left to right. You can use previously defined variables to define new variable values, and you can nest one Let function within another. If you use a previously defined variable within a nested Let function, the variable has scope only within the nested function (as if you had defined a completely unique variable). See the City example shown below. Duplicate variables are not allowed. Example Let(x=5;x*x) returns 25. Let([x=5;squared=x*x;cubed=squared*x];cubed) returns 125. Let(City="Paris";Let(City="San Francisco";City&"-")&City) returns San Francisco - Paris. The following example shows how to pass named parameters using the Evaluate, Let, and Get(ScriptParameter) functions, allowing access only to variable 'a' (the example returns 6): ScriptParameter = "a = 5; b = 10" Evaluate("Let([" & Get(ScriptParameter) & "]; a+1 )" ) The following example shows how to pass named parameters, allowing access to both variable 'a' and 'b'. The simplified first parameter makes the second parameter more complex (the example returns 6, 12): ScriptParameter = "a = 5; b = 10" Evaluate("Let( [" & Get(ScriptParameter) & "]; a+1 & ", " & b+2 )" ) The following example shows how to pass named parameters, while keeping the ability to check the syntax of the second parameter of the Let function (the example returns 6, 12): ScriptParameter = "a = 5; b = 10" Let([a = Evaluate("Let( [" & Get(ScriptParameter) & "]; a )"),
Henry Posted March 10, 2004 Posted March 10, 2004 Nice explanation, now i think everybody are work hard to study the new FM7 feqtures. I just keep on download and read all the technical infomations. Really will be very bussy this few days(weeks). Regards, Henry
dreamingmind Posted April 22, 2004 Posted April 22, 2004 Admittedly, I'm just starting to puzzle out this new feature (Let) but I'm not really seeing variables here. The examples, including the quoted section above don't accomplish (or imply) anything I can't do more simply. I can pass multiple parameters without names as a value list (or other delimited structure) and parse them as needed. No variable naming needed. Using a named variable, I would expect to control a loop by incrementing or decrementing the variable...but I don't see a way to do such a thing. Perhaps someone can offer some insight into how these named variables will improve things. Don
smorr Posted April 24, 2004 Posted April 24, 2004 dreamingmind said: Admittedly, I'm just starting to puzzle out this new feature (Let) but I'm not really seeing variables here. The examples, including the quoted section above don't accomplish (or imply) anything I can't do more simply. I can pass multiple parameters without names as a value list (or other delimited structure) and parse them as needed. No variable naming needed. Using a named variable, I would expect to control a loop by incrementing or decrementing the variable...but I don't see a way to do such a thing. Perhaps someone can offer some insight into how these named variables will improve things. Don The best way is to use a custom function if you have developer: Custom function: ParamByName(Name) = Let(ParamResult = Evaluate( " Let([" & Substitute(Get(ScriptParameter);[":";"="]) & "]; "&name&" )" ); If (ParamResult?"?";ParamResult;"")) Thus you can use the custom function in a script Call a function with parameters (firstParam: 1; secondParam 2) eg Set Field [gResult; ParamByName(firstParam)] Set Field [gResult; ParamByName(secondParam)] If you don't have developer, you can use this code in a calcuation eg Set Field [gResult; Let(ParamResult = Evaluate( " Let([" & Substitute(Get(ScriptParameter);[":";"="]) & "]; firstParam )" ); If (ParamResult?"?";ParamResult;"")) Set Field [gResult; Let(ParamResult = Evaluate( " Let([" & Substitute(Get(ScriptParameter);[":";"="]) & "]; SecondParam )" ); If (ParamResult?"?";ParamResult;"")) As you can see, developer is much cleaner.
Recommended Posts
This topic is 7522 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