Browse Groups

• ## RE: [libertybasic] Re: Scrolling through variables with FOR......NEXT

(6)
• NextPrevious
• ... LB can help you here with the EVAL() function, see the following example: ---code start (watch for line wraps) fracts\$(1) = 1/4 fracts\$(2) = 1/2
Message 1 of 6 , Nov 7, 2008
View Source
>
> I've been working along a simular line trying to use the select
> option to integrate a value. I m using a combobox to bring in the
> value, changing it from a readable string to a numeric value.
> basically, here's what I have thus far....
>
> sw\$(1) = "1/2"
> sw\$(2) = "3/4"
> ....... 'continues in actual program
> sw\$(15) = "2 1/4"
>
---snip
>
> print #main.shotwgt,"Selection? shotwgt\$"
>
> for c = 1 to 15
> Select Case shotwgt
> Case 1
> shotwgt = .5
> Case 2
> shotwgt = .75
> Case 3
> shotwgt = .688
---snip
>
> my confusion comes when I attempt to conver the shotwgt\$ to something
> which I can associate the select modeule. Again, I may be
> overthinking this thing (it might just be easier to use the 15 if-
> then statements) but i feel there is a small something I am just not
> seeing. Any ideas?
>

LB can help you here with the EVAL() function, see the following example:

'---code start (watch for line wraps)
fracts\$(1) = "1/4"
fracts\$(2) = "1/2"
fracts\$(3) = "3/4"
fracts\$(4) = "1"
fracts\$(5) = "1 1/4"
fracts\$(6) = "2 1/2"

nomainwin

combobox #m.cb, fracts\$(, [showValue], 10, 10, 50, 100
statictext #m.st, "Select a value", 10, 40, 100, 20
open "Test" for window as #m
#m "trapclose [quit]"
wait

[showValue]
#m.cb "selection? callout\$"

if instr(callout\$, " ") then
callout\$ = word\$(callout\$, 1); "+"; word\$(callout\$, 2)
end if

#m.st callout\$; " = "; eval(callout\$)
wait

[quit]
close #m
end
'---code end

If the readable value consists of two parts separated by a space, you need to convert it to a formula inserting a plus sign to get
the correct value.
There is no need to create a bunch of conditions just to get the value of a formula hold by a string ;-D

---
Stefan Pendl
Your message has been successfully submitted and would be delivered to recipients shortly.
To: