Jump to content
Salesforce and other SMB Solutions are coming soon. ×

exit inner loop not working and exits main loop


alienandra
 Share

Recommended Posts

Hi,

 

I have a portal in which I would like to have 90 rows. The first rows should have a field (Entradas::IDespecie) with one value, the next 30 with value+1 and the last with value+1+1.

 

I have a nested loop that goes through 30 rows setting the value field, it should exit after 30 and go to the main loop, where the values changes to value+1 and then goes to the nested loop 30 to set the field and so on. The problem is that the sript exits after the first 30 rows; it doesn't go on to the main loop. Here is my Script

 

Go to Object [ Object Name: "Talla" & Get ( ScriptParameter ) ] Go to Portal Row[ Select; Last ]

Set Variable [ $IDespecie; Value:1 ]

Set Variable [ $trans; Value:GetRepetition ( Filtros::transecto ;Get ( ScriptParameter ) ) ] Loop

....Exit Loop If [ GetAsNumber ($IDespecie) > 3 ]

....Loop

........Exit Loop If [ Get (ActivePortalRowNumber) = 31 ]

........Set Field [ Entradas::Trans; $trans ]

........Set Variable [ $IDespecie; Value:$IDespecie ]

........Set Field [ Entradas::IDespecie; $IDespecie ]

........Go to Portal Row[ Select; Next ]

....End Loop

....Set Variable [ $IDespecie; Value:$IDespecie + 1 ]

End Loop

Go to Portal Row[ Select; First ]

Link to comment
Share on other sites

That is not your script; that is a snippet of your script (you're already in mid-loop or you left some script steps out).

 

What you posted looks like you've got your Exit Loop statement before the loop even begins. I first posted that that is your problem, then realized you have a second Exit Loop statement after the loop starts. That's when I realized you're already in mid-loop.

 

 

Please post your entire script. We can't easily tell you what's causing the behavior if we don't see the entire script.

Link to comment
Share on other sites

The loop is before the exit loop, but when I copied the script I didn't press enter and the Loop is in the same sentence as Get (Script Parameter), so that is my entire script. However, I adapted that script form another one in which I have more steps (that I don't need) and that one is working perfectly. I can post the first script, from which I adapted the second one:

 

FIRST SCRIPT

Go to Object [ Object Name: "Cuenta" & Get ( ScriptParameter ) ]

Go to Portal Row

[ Select; Last ]

Set Variable [ $IDespecie; Value:1 ]

Set Variable [ $trans; Value:GetRepetition ( Filtros::transecto ;Get ( ScriptParameter ) ) ]

Loop

...Exit Loop If [ GetAsNumber ($IDespecie) > 3 ]

...Set Variable [ $metro; Value:-1 ]

...Loop

.......Exit Loop If [ GetAsNumber ($metro) > 48 ]

.......Set Field [ Entradas::Trans; $trans ]

.......Set Variable [ $metro; Value:$metro + 2 ]

.......Set Field [ Entradas::Metro; $metro ]

.......Set Variable [ $IDespecie; Value:$IDespecie ]

.......Set Field [ Entradas::IDespecie; $IDespecie ]

.......Go to Portal Row[ Select; Next; Exit after last ]

...End Loop

...Set Variable [ $IDespecie; Value:$IDespecie + 1 ]

End Loop

Set Variable [ $Botijona; Value:"Botijona" ]

Go to Portal Row[ Select; First ]

 

 

SECOND SCRIPT (BASED ON FIRST SCRIPT)

Go to Object [ Object Name: "Talla" & Get ( ScriptParameter ) ]

Go to Portal Row[ Select; Last ]

Set Variable [ $IDespecie; Value:1 ]

Set Variable [ $trans; Value:GetRepetition ( Filtros::transecto; Get ( ScriptParameter ) ) ]

Loop

....Exit Loop If [ GetAsNumber ($IDespecie) > 3 ]

....Loop

........Exit Loop If [ Get (ActivePortalRowNumber) = 31 ]

........Set Field [ Entradas::Trans; $trans ]

........Set Variable [ $IDespecie; Value:$IDespecie ]

........Set Field [ Entradas::IDespecie; $IDespecie ]

........Go to Portal Row[ Select; Next ]

....End Loop

....Set Variable [ $IDespecie; Value:$IDespecie + 1 ]

End Loop

Go to Portal Row[ Select; First ]

Link to comment
Share on other sites

Yeah, I see the problem now. (It was there in front of me before but I got distracted by other stuff).

 

first iteration

Go to Object [ Object Name: "Talla" & Get ( ScriptParameter ) ]

Go to Portal Row[ Select; Last ]

Set Variable [ $IDespecie; Value:1 ]

Set Variable [ $trans; Value:GetRepetition ( Filtros::transecto; Get ( ScriptParameter ) ) ]

Loop

....Exit Loop If [ GetAsNumber ($IDespecie) > 3 ]

....Loop

........Exit Loop If [ Get (ActivePortalRowNumber) = 31 ]

........Set Field [ Entradas::Trans; $trans ]

........Set Variable [ $IDespecie; Value:$IDespecie ]

........Set Field [ Entradas::IDespecie; $IDespecie ]

........Go to Portal Row[ Select; Next ]

....End Loop

....Set Variable [ $IDespecie; Value:$IDespecie + 1 ]

End Loop

 

second iteration

 

Loop

....Exit Loop If [ GetAsNumber ($IDespecie) > 3 ]

....Loop

........Exit Loop If [ Get (ActivePortalRowNumber) = 31 ]

So we exit here immediately without doing any Set Field or any Go to Portal Row [Next], we're done here (already)

........Set Field [ Entradas::Trans; $trans ]

........Set Variable [ $IDespecie; Value:$IDespecie ]

........Set Field [ Entradas::IDespecie; $IDespecie ]

........Go to Portal Row[ Select; Next ]

....End Loop

....Set Variable [ $IDespecie; Value:$IDespecie + 1 ]

End Loop

 

Third iteration will exactly resemble second iteration (we're still on portal row number 31 so again it exits the inside loop immediately). Then because $IDespecie is now 3, we exit outer loop as well and we're done here. And you end up thinking it didn't do the outside loop; it did, but the inside loop had nothing to do except for the first time.

Link to comment
Share on other sites

By the way, another distraction: why are you doing this?:

 

........Set Variable [ $IDespecie; Value:$IDespecie ]

 

 

Why are you setting the variable $IDespecie to itself just before setting the field Entradas::IDespece to $IDespecie?

 

It isn't causing a problem but it doesn't accomplish anything.

Link to comment
Share on other sites

Yes, you are right! I was trying something to make it work and I forgot to remove it.

 

I see the mistake, but how can I say to Filemaker that after 30 rows I need to set $IDespecie to itself plus 1?

 

I don't see the difference between this script and the one that I did before (that is working)...

...Loop

.......Exit Loop If [ GetAsNumber ($metro) > 48 ]

Edited by alienandra
Link to comment
Share on other sites

I think you're missing the point.

 

You're looping through portal rows in your inner loop, and you have the inner loop exiting when portal row number is 31

 

Not some number of portal rows created during that iteration but the actual portal row being portal row 31.

 

When you go through the outer loop the first time, (when $IDespecie is 1), the inner loop generates portal rows from 1 to 31 and then exits, thus creating 31 portal rows with Entradas::IDespece set to 1.

 

Then you increment $IDespecie to itself + 1 (therefore up to 2) and start your inner loop but you're already on portalrow number 31 so it doesn't do anything, it exits immediately!

 

 

Try this:

 

Go to Object [ Object Name: "Talla" & Get ( ScriptParameter ) ]

Go to Portal Row[ Select; Last ]

Set Variable [ $IDespecie; Value:1 ]

Set Variable [ $trans; Value:GetRepetition ( Filtros::transecto; Get ( ScriptParameter ) ) ]

Loop

....Exit Loop If [ GetAsNumber ($IDespecie) > 3 ]

....Set Variable [$MaxPortalRow; 31* $IDespecie]

....Loop

........Exit Loop If [ Get (ActivePortalRowNumber) = $MaxPortalRow ]

........Set Field [ Entradas::Trans; $trans ]

........Set Field [ Entradas::IDespecie; $IDespecie ]

........Go to Portal Row[ Select; Next ]

....End Loop

....Set Variable [ $IDespecie; Value:$IDespecie + 1 ]

End Loop

Go to Portal Row[ Select; First ]

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use