Jarvis Posted June 26, 2005 Posted June 26, 2005 I'm really intrigued with the GET(SCRIPTPARAMETER) function, but I can't figure out how to create the scriptparameter in order to GET it. The HELP files discuss how simple it is to Get and use the script parameter but they don't do such a good job of telling how to create the parameter. Can anybody aim me to a discussion of this concept? Thanks.
SlimJim Posted June 26, 2005 Posted June 26, 2005 For example. Define a button to run a script. When specifying the script one of the options is to insert a parameter as a calculation, so you can pass field values etc, or just simply text. You get exactly the same dialog if you run a script from within a script so you can pass parameters from one script to another.
Jarvis Posted June 26, 2005 Author Posted June 26, 2005 Thanks SlimJim! Now that I know how to to create a parameter, i just have to figure out how to make it useful. Jarvis
LaRetta Posted June 26, 2005 Posted June 26, 2005 Hi Jarvis, this visualization might help also. I too had a bit of difficulty *getting* it at first. It's like a clipboard. Data-strings (results of your specified calculations) get placed on this clipboard upon button click. This clipboard data can be re-used over and over within a script in any way you can conceive of; can be passed on to other scripts (much like passing the wand); and is lost upon script end. When a script is attached to a button, open Specify Button (right-click on button) and when you specify a script, the parameter is stored in the Parameter Edit box (which can open into calc box for easy manipulation of complex calculations). Script knows it has script parameter piggybacking along so it looks for Get(ScriptParameter) as it is firing and substitutes this held data instead. Example: You have one simple script called Find Alpha consisting of: Enter Find Mode [ ] Set Field [ CustomerName ; Get(ScriptParameter) ] Perform Find [] In the old days, if you wanted 26 alpha buttons, you'd have to store a find for each alpha. Now you only have one script - and one Find. You attach the script to your A button. You put "A" in its script parameter Edit box. Attach the same script to B button. Put "B" in it's Edit box. etc. If User clicks A button, script substitutes Get(ScriptParameter) for what is grabbed - or A. Script parameters defined in the Parameter Edit box can be quite complex multiple criteria calculations or a simple ID. You can capture ID and jump to an unrelated table to use it there - no need for relationships. They are extremely powerful and only Get(ScriptParameter) can retrieve these strings. So button click and Parameter Edit box is where the strings get stored. And Get(ScriptParameter) is the method of pulling that information back into the running script to use it. I hope that helps! LaRetta
LaRetta Posted June 26, 2005 Posted June 26, 2005 Okay Jarvis consider this: You have a layout (Main Menu) with 52 cabinets (graphics) on it. You have a layout detail for every cabinet name maybe listed as Detail: Cabinet Name. Maybe you have a Quote layout for each cabinet that you print to send also. These layouts are all as Quote: Cabinet Name. I'm trying to remember some of your past posts to give you more perspective. One script called Cabinet with: Go To Layout [ Layout name by calculation; "Quote: " & Get(ScriptParameter) ] Print [ ] New Window [ window name - yep (smile) Get(ScriptParameter) ] Go To Layout [ Layout name by calculation; "Detail: " & Get(ScriptParameter) ] Select your first graphic and insert its Cabinet name in the Parameter Edit box. Repeat for all cabinets - one script only - one printing only - each with a different parameter (cabinet name) attached. LaRetta
Jarvis Posted June 27, 2005 Author Posted June 27, 2005 LaRetta, I had just finished reading your first post and it was starting to enough sense that I wanted to practice it. I started to scroll down to thank you for your input & BOOM, you woke me up with the next one! I did a bunch of work with graphics about a year ago and it required about a million scripts. I shut it all down while angsting about separating interface from data. I've needed to get back to that project but wasn't really looking forward to all the code. Everything I ever come back to seems to be a complete re-write, so I guess I should learn the script-parameter stuff. Right now I'm still working with your last week's contribution about start-stop. I've come up with some really useful stuff because of it. So far I have managed to keep my business more interesting than my computer but sometimes it is a struggle.: Jarvis
LaRetta Posted June 27, 2005 Posted June 27, 2005 "I did a bunch of work with graphics about a year ago..." I recall it - your cabinet graphics 'pieces' as click & select - your layouts named for each of your cabinet styles. When vs. 7 first came out and I started playing with script parameters, what flashed into my mind was the power of selecting multiple objects (graphics, fields, whatever) ... I envisioned theatre seating - each box representing a seat and simply attaching the seat number as parameter. Oh, the time-savings are immense when specifying multiple same/similar button firings just by changing the parameter. Script parameter doesn't need to be static data you enter either ... it can be complex composite calculations (which you then parse within your script using Get(ScriptParameter); it can be multiline IDs, pipe arrays and Sum() figures. Click - grab - click - use within your script. Attach script parameter to that pop-up you're working on so when your script fires, it does a bunch of other things for you in one whack! And Jarvis? You can even store graphics in a script parameter. Now sir ... try keeping your mind on your business instead of the computer. It's exciting stuff - at least to me it is!!! LaRetta
Newbies Anthony Green Posted July 5, 2005 Newbies Posted July 5, 2005 I had a quick look at this. Apart from Laout is there any other of the built in functions able to access the parameter ? I tried with Goto Field and it seems you can only hard code the name of the field.
Søren Dyhr Posted July 5, 2005 Posted July 5, 2005 but they don't do such a good job of telling how to create the parameter. Might it be so, that the missing part is recursive scripting as such?: ...which deliberately wasn't endorsed particular before turning to 7.0. Previous versions were troubled with upper limits at 64K. Scripts calling itself pushes the point where the subscripting is called onto the stack in order to unwind correctly when the inner loops are finished. It was indeed posible from version 2.1 and upwards, but the measure to prevent overflows were the introduction of the Loop/Exit Loop/End Loop structure, to avoid developers unintended crashing a solution. Now is the stack made bigger, and recursions aren't disuaded in the same manner as earlier. But making use of recursive scripts more or less demand the debugger found in 7Dev, to trace the changes to the values given as scriptparameters, when developing the solution - before the client makes it crash. Read this thread to learn more: http://www.fmforums.com/threads/showflat...true#Post161682 --sd
Fitch Posted July 5, 2005 Posted July 5, 2005 Apart from Layout is there any other of the built in functions able to access the parameter ? I tried with Goto Field and it seems you can only hard code the name of the field. Go to field and Sort are two script steps that don't work directly with parameters; you have to do something like If [Get ( ScriptParameter ) = "Field A" ] ... Go to field [ Field A ] ... (or e.g. Sort[by Field A )]. Parameters work great with If[] steps and Set Field and any step where you can invoke a calculated result.
comment Posted July 6, 2005 Posted July 6, 2005 GetField(Get(ScriptParameter)) That's very neat - but the type of the result must match the selected field's type.
-Queue- Posted July 6, 2005 Posted July 6, 2005 Okay then, make the calc result text and use something like Let([ N = Get(ScriptParameter); F = GetField(N); T = MiddleWords( FieldType( Get(FileName); N ); 2; 1 )]; Case( T = "Date"; Year(F) & Right( "0" & Month(F); 2 ) & Right( "0" & Day(F); 2 ); T = "Time"; Right( "0" & Hour(F); 2 ) & Right( "0" & Minute(F); 2 ) & Right( "0" & Seconds(F); 2 ); T = "Timestamp"; Year(F) & Right( "0" & Month(f); 2 ) & Right( "0" & Day(F); 2 ) & "_" & Right( "0" & Hour(F); 2 ) & Right( "0" & Minute(F); 2 ) & Right( "0" & Seconds(F); 2 ); T = "Number"; Right( "0000000000000" & F; 13 ); F ) ) Just don't pass it a container field's name!
comment Posted July 6, 2005 Posted July 6, 2005 I don't want to really get into it here and now, but it is more complicated than that. Just to point out a few problems, numbers can be fractions, numbers can be negative (and these need to be sorted in the "opposite" direction, considering their absolute values), and FMP has this nasty habit of switching to scientific notation at 10^+/-9. On the bright side, dates, times and timestamps can be got as numbers, and these will always* be positive integers, so one size can fit all here. --- (*) OK, so not always = time can have a fractional element, but how many people know about that, and how many of those would actually use it?
-Queue- Posted July 6, 2005 Posted July 6, 2005 You are correct. But, this basically was just a response to Go to Field and Sort not being able to use Script Parameters, not a manual for making workarounds for every possible situation. I was merely showing that it can be done, if you think about it differently. If you want to make the end-all-be-all calculation for it (excluding containers), be my guest. I would gladly steal it from you.
Recommended Posts
This topic is 7082 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