Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hi,

I am using FM to generate ical files that contain specific events that are read from a FM database. Have been doing this for about a year or so with excellent results and it has taken maybe 2 to 3 hours to generate the 3000 or so ical files that run the span of an academic year. The new Lion OS disrupted this because it needs a User ID field in the ics file in order for Lion to read it correctly. Without the UID each event gets imported into iCal twice. So the script below (parts were lifted from the internet) makes a UID and everything works fine except it now takes double the amount of time to run the script. Pretty sure I haven't been the most efficient at script writing across the board (I'm a beginner to intermediate at FM) and am looking to speed up this one script, although maybe there are other areas. Any help is appreciated. Ah, the UID has to be in the form... UID:3A7DD759-55A0-4906-8672-55F1FD3DA68B where the letter/number combo is "random" and/or "unique" (probably not, but iCal re-creates the UID once the event is imported)

dan

  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1="" ]
  • Loop
  • Commit Records/Requests [ No dialog ]
  • Exit Loop If [ Length(dates_EVENTS::UID1)=8 ]
  • #grab the character at random using the Middle() function below
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1& Middle ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Random * 62 ; 1 ) ]
  • End Loop
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1&"-" ]
  • Loop
  • Commit Records/Requests [ No dialog ]
  • Exit Loop If [ Length(dates_EVENTS::UID1)=13 ]
  • #grab the character at random using the Middle() function below
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1& Middle ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Random * 62 ; 1 ) ]
  • End Loop
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1&"-" ]
  • Loop
  • Commit Records/Requests [ No dialog ]
  • Exit Loop If [ Length(dates_EVENTS::UID1)=18 ]
  • #grab the character at random using the Middle() function below
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1& Middle ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Random * 62 ; 1 ) ]
  • End Loop
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1&"-" ]
  • Loop
  • Commit Records/Requests [ No dialog ]
  • Exit Loop If [ Length(dates_EVENTS::UID1)=23 ]
  • #grab the character at random using the Middle() function below
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1& Middle ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Random * 62 ; 1 ) ]
  • End Loop
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1&"-" ]
  • Loop
  • Commit Records/Requests [ No dialog ]
  • Exit Loop If [ Length(dates_EVENTS::UID1)=36 ]
  • #grab the character at random using the Middle() function below
  • Set Field [ dates_EVENTS::UID1; dates_EVENTS::UID1& Middle ("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Random * 62 ; 1 ) ]
  • End Loop

Ah, the UID has to be in the form... UID:3A7DD759-55A0-4906-8672-55F1FD3DA68B

Are you sure about this? The iCalendar standard requires only that the UID be globally unique, and suggests using something like:

[email protected]

to achieve it.

To address just your script optimizing question, I'd guess the biggest culprit is that you commit the record every single time through the loop. You're also having to calculate the length every time around. I'd do this all in variables and only set the field and commit it at the end. I also insert the hyphens at the end for simplicity:


Set Variable[ $counter ; "" ]

Loop

  Set Variable[ $counter ; $counter + 1 ]

  Exit Loop If [ $counter > 32 ]

  #grab the character at random using the Middle() function below

  Set Variable[ $random ; Middle("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; Random * 62 ; 1 ) ]

  Set Variable[ $uid ; $uid & $random ]

End Loop

Set Variable[ $uid ;

  Left( $uid ; 8 ) & "-" &

  Middle( $uid ; 9 ; 4 ) & "-" &

  Middle( $uid ; 13 ; 4 )  & "-" &

  Middle( $uid ; 17 ; 4 )  & "-" &

  Right( $uid ; 12 ) ]

Set Field [ dates_EVENTS::UID1; $uid ]

You can also calculate several random character at once, without looping, e.g.

Let ( [

alpha = "0123456789ABCDEF" ;

n = Length ( alpha ) + 1

] ;

Middle ( alpha ; Random * n ; 1 ) &

Middle ( alpha ; Random * n ; 1 ) &

Middle ( alpha ; Random * n ; 1 ) &

Middle ( alpha ; Random * n ; 1 ) &

Middle ( alpha ; Random * n ; 1 ) &

Middle ( alpha ; Random * n ; 1 ) &

Middle ( alpha ; Random * n ; 1 )

)

  • Author

Fantastic! Thanks for the suggestions. The let statement worked perfectly.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.