5 Replies Latest reply on Apr 24, 2012 6:59 AM by jvankooy

    Script within a script

    jvankooy

      Title

      Script within a script

      Post

      Hello,

      I made a script to define a start and end date for a report and like to use that for several reports. One is aksed to enter a 'start date' and 'end date' and then click a button.

      Now I perform that sript from another sript and would like to know how to return back to the first script which I have left to perform the 'search a data range' sript. What do I put at the 'button setup'. 'Resume script' does not work.

      There is no explanation nor example about this 'simple' step in any manual or help file.

      Thanks.

        • 1. Re: Script within a script
          philmodjunk

          Can you describe in more detail what you want to do?

          If you store your dates in fields or global variables, multiple scripts can access them.Thus, a button might just start up a new script that can access the same data instead of trying to "resume" another script. ("Resume" is a button option that will resume a paused script after the button's script completes.)

          If you have this type of script structure

          step 1
          step 2
          step 3
          Perform Script ["script 2"]
          Step 5
          Step 6

          (each "step" would be a different script step you create in the script editor)

          Then control will return to step 5 in this script when "script 2" completes, provided a halt script in script 2 doesn't abort all script execution.

          • 2. Re: Script within a script
            jvankooy

            Thanks

            I am still a starter but with common sense I could create what I wanted. Now the reporting is challenging me as I get into scripts.

            I have a database where I need to pull reports with different search criteria but all based on a date range, which can be determined by the user. I do that via two global fields in the database start date end date. So far so good.

            I can enter dates via a script (1)
            -       got to layout
            -       enter browse mode
            -       set field ,”” (for both start date and end date)

            I created the report (2)
            -       go to layout
            -       enter find mode
            -       insert calculated result
            -       perform find
            -       go to layout
            -       sort records

            For the moment I get from a main menu with a button to script (1) and when the dates are filled in a button “perform script” to script (2).

            Ideally would be to start from script (2), make a side step to script (1), push the button “return to the script you came from” and return to script (2). That would mean that I could use script (1) for other procedures too.How do I do that?  

            Thanks, Jeroen

            • 3. Re: Script within a script
              philmodjunk

              Try it this way:

              Go To Layout [Layout with global date range fields]
              enter browse mode
              Set Field to clear the two fields
              Pause/Resume [indefinitely]
              Go To Layout [layout for report]
              Enter Find Mode[]
              Set field [YourReportTable::Datefield ; YourTable::GlobalDate1 & "..." & YourTable::Globaldate2 ]
              Set Error capture [on]
              Perform Find[]
              Sort [Restore, no dialog]

              With the script paused on your date range layout, the user can enter/select two dates and either press the enter key (numeric keypad enter on windows systems, click continue in the status area, or click a "resume" button on the layout.

              You can also just write two scripts without the pause. The first script would have all the steps above the pause. The second would have all the steps after the pause. Your resume button would then be a perform script button to perform the second script.

              PS. I try not to ever use the Insert steps if there is any way that I can use Set Field instead. Insert steps require that the specified target field be present on the current layout and will silently fail to work in your script if a future change to your layout removes the target field. Set Field does not have this limitation.

              • 4. Re: Script within a script
                jvankooy

                Tanks it worked! Great.

                Jeroen

                • 5. Re: Script within a script
                  jvankooy

                  Hi,

                  I am desperate ...

                  I have a script where a date range is determined and a laylout/report that gives the records fitting in that daterange (creation date). Works fine.

                  Now I have created an additional field in the database: 'payment date'. I want to make a similar report but based on the payment date fitting in the range.

                  I do not remember anymore how and it seems impossible to make a find request either "enter find mode or perform find" with the payment date, fitting in the date range. I copied the other script and changed several variables to specify the payment date. It won't work! I must forget something.

                  By the way, when I want to do a simple find in the payment date layout I cannot put values in all the fields on the layout, whereas I can in other layouts.

                  Who can help?

                  Thanks, Jeroen