Skip to main content
Jerimy_Brown1
September 28, 2023

We could use IF, ELSE IF, ELSE statements?

  • September 28, 2023
  • 24 replies
  • 5042 views

We could use IF, ELSE IF, ELSE statements… Many times in code you may want to do many different things based on different string values

For example, I might have three different landing pages based on 3 conditions, and upon button press I might want to say

IF “has-users”==0 goto empty landing
ELSE IF “has-users”==1 goto landing a
ELSE IF “has-users”==2 goto landing b
ELSE goto other

24 replies

Jerimy_Brown1
September 29, 2023

I did find that you can string a bunch of IF statements together and leave the ELSE blank, but that feels a bit hacky to me ;). It does work though, if others are looking for this capability.

gilgongo
September 29, 2023

I’m too lazy to test - if you string a load of IFs together, do they all get evaluated equally?

Jerimy_Brown1
September 29, 2023

Not sure if I am following you, but for my purposes I am checking for a string value of 0, 1, or greater than 1 and it’s doing what I want and going to the correct location based on that value. I haven’t attempted to see what happens if two or more items evaluate to true at the same time though.

gilgongo
September 29, 2023

I think I mean that if you have multiple IFs, does it stop evaluating at the first TRUE? Not sure what to expect.

Nate_G
Power Member
September 29, 2023

It would be great to have more “else if’s” and “while” conditionals. It can get a bit unwieldy.

For example, I worked on a swipe+loader that would show/hide elements if a variable was a certain number (this makes it look like it is spinning), I had to use a few if statements.

I’d love to be able to copy and paste conditionals/variables, so I wouldn’t have to retype everything if I am reusing a similar statement.

Nate G
claus.stadel
New Participant
October 31, 2023

We definitely need this. Not just is a bunch of if’s with blank else’s a bit tiresome hacky to do, but it is also a problem, that you can stop the following statements from being evaluated, so you have to add additional conditionals to your if’s to prevent it.

Shaul_Vainblat
November 15, 2023

The prototype renders the variables by order, from top to bottom, exactly like in javascript.
Behind the scenes it is javascript

November 15, 2023

Yup- definitely need this.

Peter_Kahoun1
November 15, 2023

Thank you! I was looking for any workaround for missing elseif and haven’t found anything until you pointed out this is possible. 🙂

Jerimy_Brown1
January 23, 2024

Agreed. It felt hacky even doing it, and it took me a while to even consider it as a possibility because I thought surely that wouldn’t work right, but once I got desperate enough for a solution I decided to just try it and see what happened. I was like “Oh, that does work” hahaha