Skip 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.

Loop Trouble

Featured Replies

having some trouble with a loop i created...

im running the loop to find a sertain varible. if it finds the varible i want it to break on the record the varible is in, and if it doesnt find the variable i simply want it to create a new record with the new variable in it... as of right now i get it to find the variable, and break, but i cant get it to create new a record!

help please...

It would help if you can post the script that you have. I would be intrigued how you determine a record with a variable attached

Phil

  • Author

k.. here we go...

setvariable[$$rmail; report::report_mail]

goto layout["people"(people)]

setvariable[$$count; Count(people::people_id)]

goto record[first]

setvariable[$$j; 1]

loop

setvariable[$$pmail; people::people_mail]

exit loop if[$$pmail=$$rmail]

exit loop if[$$count=$$j]

goto record[next]

setvariable[$$j; $$j + 1]

end loop

if[$$pmail=$$rmail]

setvariable[$$id; people_id]

goto layout["report"(report)]

new record

setfeild[report::report_people_id; $$id]

exit script[]

end if

new record

setvariable[$$id_new; people_id]

setfield[people::people_mail; $$rmail]

goto layout[report]

new record

setfield[report::report_id; $$id_new]

thats what im getting... its not working though. i cant get the darn thing to fill in the new email and create a new record (for the new person that doesn´t already exists). everything else works fine...

Edited by Guest

  • Author

i should explain a little...

the report_mail thing is the variable, this is where i enter my diffrent values. thats the value i want to compare to the existing values in the people table. ya c, folks?

When you go to each record what is it precisely that you want to check?

  • Author

i want to check if the email adress is the same as in the mail i got sent to me. it does that all fine and well, the thing is that as my people tabel grows larger its gonna slow down this search. thats why i need to find a faster model...

Ah - so you are looking to go faster.

Try this

Establish a relationship between a global and the field in the table that you wish to check.

Then set the global to the email that you are looking for

Then use the Count()function to check if a record (or records) exist for that relationship. Set a variable with it

If variable is more than 0 (ie person exists) - do whatever

If not do whatever

1 global, 1 relationship, 1 variable. A short script. No loops. Done.

That way no matter how big your file gets the find will be quick.

HTH

Phil

  • Author

will do, sounds greeat!

one thing though: "global"? how do i do that? i probably already know, im using a swedish copy though so the words might be mixed up...

A Global is a field where the storage is set (under storage options) to global ie one value for all records.

It acts like a variable but is set up through the define database>fields window.

You will have to set this up because you cannot base a relationship on a variable

Hope it does what you want

Phil

  • Author

thanks buddy! ill get to work with this right away... stay tuned for the thrilling concluesion...

I am all ears...... :zzz:

  • Author

k.. this is my code now: it cant find any of my old records, and it automaticly deletes the old emailadresses from all previous records?!? what am i doing wrong?

setvariable[$$rmail; report::report_mail]

setvariable[$$count; Count(report::report_mail; people::people_mail]

goto layout["people::people"(people::people)]

if[$$count>0]

setvariable[$$id; people_id]

goto layout["report"(report)]

new record

end if

if[$$count<=0]

new record

setvariable[$$id_new; people_id]

setfield[people::people_mail; $$rmail]

goto layout[report]

new record

setfield[report::report_id; $$id_new]

end if

Edited by Guest

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.