AnsweredAssumed Answered

Multiple Else If's In Script

Question asked by user26728 on Sep 21, 2017
Latest reply on Sep 22, 2017 by user26728

Hi.

 

I’m having problems getting a script with multiple Else If statements to work. I’ve tried writing the script four different ways with no luck, can’t seem to figure it out.

I have an app that has 5 container fields for storing images.

On several of the layouts, I’ve put a button that triggers a script that inserts an image into one of the container fields. Each time the button is clicked,  the script is supposed to check the container fields and insert an image into the first empty field it finds.  But it only works twice. The third time the button is clicked, it doesn’t insert the image into the next empty field (the third container). Instead it inserts it into container 2, which already has an image in it.

 

Part of my confusion is that I thought that once an ELSE IF evaluates to TRUE it goes down to the END IF without evaluating any other steps in the script.

 

Here is the script I’m trying to get to work .. Can anyone see where I went wrong?

Thanks.

 

1 Go to Layout ["Insert Photo iPad" (Assets); Animation:None]

2 If [IsEmpty Assets::File 1 Container )]

3 Insert from Device [Assets: :File 1 Container; Type: Camera;Camera: Back; Resolution: Full]

4 Else If [not IsEmptyAssets::File 1 Container)]

5 Insert from Device [Assets: :File 2 Container; Type: Camera;Camera: Back; Resolution: Full]

6 Else If [not IsEmpty Assets: :File 2 Container)]

7 Insert from Device [Assets::File 3 Container; Type: Camera;Camera: Back; Resolution: Full]

8 Else If [not IsEmpty ( Assets: :File 3 Container )]

9 Insert from Device [Assets::File 4 Container; Type: Camera;Camera: Back; Resolution: Full]

10 Else If [not IsEmpty Assets: :File 4 Container )]

11 Insert from Device [Assets::File 5 Container; Type: Camera;Camera: Back; Resolution: Full]

12 Else If [not IsEmpty Assets: :File 5 Container)]

13 Show Custom Dialog ["To Insert More Images Create A New Record. "]

14 Else

15 Go to Layout ["Insert Photo iPad" (Assets); Animation:None]

16 End If

Outcomes