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.

for (var i = 1;

Featured Replies

Hi all,

I have the following code in javascripts:

Can someone help to convert it into FMPRO 9 script?

Or is this possible in FMPro 9? :)


for (var i = 1; i <= controller.getMaxRecordIndex(); i++) 

   { 

		controller.setSelectedIndex(i);

		if ( i==1 )

		    {globals.Num1 = subj_num;

					

		}

		else if (i==2)

		   { globals.Num2 = subj_num;

					

		}

		

			

		

		else if (i==3)

		

		{

		    globals.Num3 = subj_num;

					

		}

		

		else if (i==4)

		{    

			globals.Num4 = subj_num;

							

		}

		

		

		else if (i==5)

		{

		

		    globals.Num5 = subj_num;

							

		}

		

		

		else if (i==6)

		

		{

		    globals.Num6 = subj_num;

		}







Thanks in advance,

A

I would think this would be possible in FMP script. But I'm not sure what you are trying to do. It looks like your setting six global values based on the value of i.

I description of what your trying to accomplish would be a great help. You can definitely loop through records in FMP script and set global values based on what is in the current record. In FMP 9 you can also set variables either locally (to the script) or globally.

  • Author

Hi,

Here is what I’m trying to do:

1. Search for a record

2. Assuming there was one or more than one record was fund.

3. View each record one after another every one second, and copy each record fields one after another in to the global fields that has been already created.

Let’s say there were 4 records was found, we want to view all the six records on the form at the same time such as following presenting them as horizontal rows:

ID_First_name: Jim :):) Alex :: Mary :: Michelle:

Subj_num :: 1 :: 2 :: 3 :: 4 ::

State :: CA :: NY :: TX :: OH

I have the following script to loop through the found records:


Loop

Pause/Resume Script[Duration (seconds):1]

Go to Record[Next; Exit after Last]

End Loop



I’m attaching .jpg file that is the screenshot of a form that is doing the same think that I’m trying to do in FM Pro.

This screen shot is not from FMPRO

Thanks in advance,

A

Screenshot.jpg

  • Author

I got it working. :yourock::yourock:

Attached is the screenshot of script:

Thanks to all the help.

A

Multi_Rec.jpg

Edited by Guest

Glad that you got it working but I have no idea what you were trying to achieve. What is with the 1 sec pause in between records?

I thought you wanted the layout to look like your attachment. :idunno:

  • Author

I guess is the one sec pause in between records, is to allowing for the script to finish coping all the fields.:laugh:

There will be so many of fields that need to be copied.

Please don't forget that I I’m a beginner and just start testing FileMaker Pro 9 on almost a week ago.

Regards,

A

Dont use copy and paste. It takes up your clipboard for no reason. Instead use variables to store the info.

Also there is no use of using a loop if you have your script like that.

In addition, anytime that you have field1, field2, field3, etc it usually means that your structure is off. There should be multiple records with one field.

Loop

Set Variable [ $subjectnum; DEM_REC_CHECKK_LIST::subj_num ]

Set Field [ YourField; $subjectname ]

Go to Record[Next; Exit after Last]

End Loop

  • Author

I’m little confuse about you script.


Loop

Set Variable [ $subjectnum; DEM_REC_CHECKK_LIST::subj _num ]

Set Field [ YourField; $subjectname ] 

Go to Record[Next; Exit after Last]

End Loop



So, if I have source and targeted fields copy and paste as:

For the first record we have:

Source record copy from: Subj_num, ID_Date, Id_FirstName

The targeted field paste to: Subj_num2 , ID_date2, Id_FirstName2

Then next record copy from: Subj_num , ID_Date, Id_FirstName

The targeted field paste to: Subj_num3 , ID_date3, Id_FirstName3

And keep going until there is no more record left.

So hwo do we use you script? :content:

Thanks in advance,

A

In addition, anytime that you have field1, field2, field3, etc it usually means that your structure is off. There should be multiple records with one field.

You are missing this.

See here on normalizing data.

http://en.wikipedia.org/wiki/First_normal_form

Edited by Guest

  • Author

Useful info, :)

Thanks,

A

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.