String if else code block

Hi,everyone Im trying to input a string and make it output a number with “if else” function, for example I have two variables Top and Bottom with two control strings(note:only two), H_G and V_G If I input H_G It will give a top length 13 and bottom length 11, and if I input V_G, it will give a Top length 10 and Bottom length 8.
I’ve tried but It doesn’t seems to work, any suggestions?

Many thanks, best regards!!!1

You’re using && where you should be using ==, and V_G and H_G likely want to be in quotes so they are strings.

2 Likes

As @jacob.small said, the && is part of your problem. When you use a variable name without any operator/logic, it is basically asking if that variable is true or not a null. The && means And, in other words, both Top and H_G is true.

So in your example, you used H_G as a variable in the first code block, but not filled in. If you check, it is a null. And Top is also not filled in and is a null. Thus both Top and H_G are nulls, so the answer is false. This is the same for all of your IF statements.

badIf

1 Like

wow Thanks!! I thought && and == is same, thank you for the advise!!

thank you!!!

Hello Andy,

I’ve just given a talk at BILT EUR in Slovenia on DesignScript - feel free to have a look at the following content!

It may be of use in understanding some of the syntax and approach to the language.

5 Likes

Thx!!appreciated!

1 Like