
-----------------------------------
joe333
Tue Apr 13, 2004 7:16 pm

Is there an easy way to make these if statements be one?
-----------------------------------
Is there an easy way to make these smaller? Like in a loop or something? i'm making a hex to dec convertor.

if input1 = "A" then
            input2 := intstr (A)
        end if
        if input1 = "B" then
            input2 := intstr (B)
        end if
        if input1 = "C" then
            input2 := intstr (C)
        end if
        if input1 = "D" then
            input2 := intstr (D)
        end if
        if input1 = "E" then
            input2 := intstr (E)
        end if
        if input1 = "F" then
            input2 := intstr (F)
        end if

-----------------------------------
omni
Tue Apr 13, 2004 7:42 pm


-----------------------------------
Right off the top of my head, you can make it like

if input1="A" then
'command'
elsif input1="B" then
...
...
so on
end if
That means ONLY ONE of those conditions can be true.
Not sure if intstr(A) will work, that converts an integer to a string. Unless
if 'A' is a variable of integer type, don't think that will work

-----------------------------------
EDEN-E
Tue Apr 13, 2004 7:57 pm


-----------------------------------
If you dont want to use 'IF' statement, you can use "CASE"

case input1 of
    label "A" : input2 := intstr(A)
    label "B" : input2 := intstr(B)
    label "C" : input2 := intstr(C)
    label "D" : input2 := intstr(D)
    label "E" : input2 := intstr(E)
    label "F" : input2 := intstr(F)
end case

-----------------------------------
Raugrist
Tue Apr 13, 2004 8:07 pm


-----------------------------------
I don't know why you're doing intstr, but whatever...


if ord (input1) >= 65 and ord (input2) 