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.

Can you re-initialize a variable in a script?

Featured Replies

  • Newbies

I am trying to re-initialize a variable within a loop in a script. Basically I want to save several pdf files with different file names that relate to each record. Everything works fine except the variable "$pdf_file" retains the first value it is assigned first time through the loop - the pdf is saved but written over by each successive loop. I have spent a couple of hours scouring the net for a solution but no luck - can anyone offer an explanation or another possible solution?

Thanks

Here is the test script I have been working with.

Go to Layout [ “test” (Listing Data) ]

Enter Preview Mode

Go to Record/Request/Page [ First ]

Loop

Set Variable [ $pdf_file; Value:Listing Data::Company_Listing_Key & ".pdf" ]

Save Records as PDF [ File Name: “filemac:/G4 HD/Users/bob/Desktop/test pdf/$pdf_file”; Current record ] [ Restore; No dialog ]

Go to Record/Request/Page

[ Next; Exit after last ]

End Loop

It doesn't seem like it should make a difference but for some reason, the Data Viewer always shows the record value from the record before you entered preview mode. Therefore, the script variable never updates. Seems like a bug but maybe there is some explanation. Anyhow, if you remove the Enter Preview Mode step and run it while in browse mode, everything will work fine and produce the same results.

  • Author
  • Newbies

Thanks - You are right about the preview mode. I thought I had tried it without - obviously not. It is still giving me problems (FM quits on layouts with a lot of photos) but I'll look into that now.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.