3 Replies Latest reply on Nov 19, 2009 10:05 AM by philmodjunk

    New to FM and need help with updating script

    ChronicD

      Title

      New to FM and need help with updating script

      Post

      Hello all,

       

      Very new to FM and have hit a brick wall... what a surprise

       

      I am trying to build a database that will facilitate the managing of shift workers for a small business, it is very much run off of a calender and i wish to retain that feel and effectively end up with a month calender as my start page user interface. from there different days can be picked etc... anyway i started building my tables for employee, client and job information - no problem. then i tried to figure out how to build this calender gui. Well i got a bit stuck here as it is not actually a calander i want but the feel of a calander. In any case i realised i would probably have to make my own and started hunting around for a guide on how to do this.

       

      i found this http://my.advisor.com/doc/17166 by John Mark Osborne and thought that it looked simple enough i could do it. anyway i got to building the script for the repeating of the records for the days of each year and made a mistake and cant for the life of me work ut what. hoping someone will spot my error and push me in the right direction again :)

       

      here is the script i wrote in fm 10 (oh thats right the script i am working off of was for 7/8)

       

      Generate Days
      Show Custom Dialog [ Title: "Year ( Date )"; Message: "Enter the value you wish to create"; Buttons: “OK”, “Cancel” ]
      Set Variable [ $Date; Value:"Date" ]
      Go to Layout [ “Days” (Days) ]
      Freeze Window
      Loop
        New Record/Request
        Set Field [ Days:: Dates; $Date ]
        Perform Script [ “Generate Days”; Parameter: Days:: Dates ]
        Exit Loop If [ Year(Days:: Dates + 1) = Year($Date) + 1 ]
        Set Variable [ $Date; Value:$Date + 1 ]
      End Loop

       

      Oh and i welcome any ideas for other ways i can go about this

       

      thanks

      dan






        • 1. Re: New to FM and need help with updating script
          philmodjunk
            

          It's the litte details that trip us up. :smileywink:

           

          I spotted this script step: Set Variable [ $Date; Value:"Date" ]

          Notice the quotes. You are storing the word date in the variable $Date--not the contents of a field named date--which is what I assume you meant to do here.

           

          Thus, Set Field [ Days:: Dates; $Date ] is storing this same word into the Days:: Dates field instead of a date value.

           

          Replace "Date" with a reference to the field, presumably the input field you designated in your custom dialog, and it should work for you.

           

          PS. To eliminate the pesky emoticons from your post, insert a space after the colon. If you see an emoticon after you post a message, you can use the edit option from the options menu just above the Kudos control to edit a message after you have posted it.

          • 2. Re: New to FM and need help with updating script
            ChronicD
              

            Oh dear dear dear what ever will i do...

             

            my god... what a head ache! i have sat with this for about 3 hours now and i know what i want to do but not why it wont work. I have a problem the script i entered creates new records but i do not know if it populates them as the script wont end once i have started it - it just carries on popping up and i have have to force quit fm to stop it. therefor it is not creating the records for the whole year but rather record by record.

             

            i tried tweaking around as you have explained but to no avail.

             

            please would you look at the mans original script which was for fm 7/8 and help pin point what i have missed in trying to update it to fm 10.

            sigh

             

            thanks

            dan

            • 3. Re: New to FM and need help with updating script
              philmodjunk
                

              This expression looks a bit odd:

               

              Exit Loop If [ Year(Days:: Dates + 1) = Year($Date) + 1 ]

               

              If Days:: Dates were to store the date 5/1/2009 (MM/DD/YYYY), Year(Days:: Dates + 1) = Year ( 5/2/2009 ) = 2009

              In otherwords Days:: Dates + 1 is adding one day to this date and that may not be what you want here.

               

              If that's not the issue:

              You need to post the subscript as well as the script. There's no way to tell from your first script how the script "Generate Days" is modifying the data. Assuming you've modified your script as I suggested, you should post the updated version of that script also.