2 Replies Latest reply on Feb 26, 2014 6:07 AM by philmodjunk

    Script to clear a variable number of fields.

    sgbotsford

      Title

      Script to clear a variable number of fields.

      Post

           I'm trying to write a script that clears 1,2, or 3 fields then positions the active field to the first one cleared.

            

           I tried this: 

            

           Set Variable [CurrentField] = GetFieldName( Self )

           But I cannot even get this done.  I get a message "This function cannot be used in this expression"  And the word Self is highlighted.

            

           Q1:  Why can't it be used?

           Q2: How do you find out this information. 

           Three hours later.

           Ok.  I found out that Self seems to be very restricted where it can be used.  No explanations why.

            

           So I'm doing with the following script, passing a single number as a parameter.

            

           Ah hell.  You don't seem to be able to cut and paste from a script window.

            

           This has been a tough day.  I finally got conditional lists licked.  But the simplest things are so hard.

            

           I wanted originally to clear fields on modification of one field.  I wanted the "On Modify" script to do this:

           $CurrentField=GetFieldName(Self)

           $Count=Get(ScriptParameter)

           For $i =0;$i++;$i<=$Count {

               GoTo NextField

               Clear [Select;]

           }

            

           You can't do that. 

           Self doesn't work there.

           It takes 3 lines, not 1 line and a } to make a loop.

           There is this involved Set Variable incredibly verbose syntax.  Indeed there is a lot of verbosity that doesn't add clarity.

           Everything takes a zillion clicks to do.  I can't just type.

           All the windows are modal.  This means you can't have your relationships window open, while designing a layout.   You can't have 3 layout windows open.  It takes 5 clicks to get from testing an entry in a layout to editing a script.  And then you can't leave the script window open, but it takes another 3 to get back to make another test.

           This is an environment that makes it tough to maintain code:  Tons of little files.  No way to bundle files into libraries.  No way to make functions.  Comments have to be on a line on their own, and I can't just type #, but I have find and double click comment.  Any form of abstraction is like walking through wet cement. 

           NONE of the places where I click "learn more" "help" "User Manual" work.

           Frame maker guys:  Clean up the syntax.  Give us something more like Perl, or php, and less like COBOL or FORTRAN.

           Give us non-modal windows.  Let me have a working view and a design view of a layout at the same time.  Reduce the number of clicks it takes to do something.  E.g. You have 3 layers of windows open when you edit a value list.

           I frustrated and tired.  I know this comes as a stage inlearning a new environment.

            

           But right now I'm quitting Filemaker, and am going to go look at what else is out there.

           I may be back.

            

        • 1. Re: Script to clear a variable number of fields.
          symbister

               "You can't have 3 layout windows open."  ...  "Let me have a working view and a design view of a layout at the same time"

               OK, this particular gripe is unfounded - yes you can have multiple windows open, edit layout in one, see the effect in the other (so long as you save changes, naturally)

               and I don't get your gripe about Set Variable - you specify a variable name and what you want that variable name set to, can't see how that is 'verbose'

               sounds like you need to get 'Filemaker - The Missing Manual' - should solve a number of your issues..

          • 2. Re: Script to clear a variable number of fields.
            philmodjunk

                 To reference the contents of the current field use: Get ( ActiveFieldContents )

                 

                      No way to make functions.

                 This is not the case. I create custom functions all the time. But you need FileMaker Advanced--which supplies a number of tools for developing databases not found in FIleMaker Pro, to do so.

                 

                      Comments have to be on a line on their own

                 That's not totally the case. Comments can be included in the calculations that make up many script steps, but you don't use #, you use // or /* */ to enclose the "in line" comment as part of the calculation.

                 It takes 5 clicks to get from testing an entry in a layout to editing a script.

                 This is not always the case. It's 5 if you count a double click on a button and a click on the edit layout button to "drill down" into the button's script, but a single menu pick of Manage | Scripts and a double click on a listed script name will take you to the same place.

                 

                      I can't just type #

                 I agree that a text editor type script editor would be a huge improvement of FileMaker.