|
|
|
03-27-2020, 12:19 PM
|
#1
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
How to get a Boolean to recognize val[1] = “true”
Hi gang,
When val[1] = “true”
And I’m using Lokasena’s GUI library, I’m having a tough time getting the Checklist GUI.Val(“Checklist1”,val[1]) to behave like it does when I use the actual word ‘true’ .
This works: GUI.Val(“Checklist1”,true)
But not this: GUI.Val(“Checklist1”,val[1])
What am I missing?
Thanks.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Last edited by Thonex; 03-27-2020 at 01:46 PM.
|
|
|
03-27-2020, 01:22 PM
|
#2
|
Human being with feelings
Join Date: Jul 2009
Posts: 1,071
|
Looks like your accessing the first value in a table ?
1 is tru and 0 is false
so if
val = {0,1} was your table then
val[1] would be getting 0 and val[2] would get 1
|
|
|
03-27-2020, 01:42 PM
|
#3
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by J Reverb
Looks like your accessing the first value in a table ?
1 is tru and 0 is false
so if
val = {0,1} was your table then
val[1] would be getting 0 and val[2] would get 1
|
Hi J Reverb,
As far as I can tell, a value of 1 doesn't satisfy the GUI.Val ()expression. IN other words, GUI.Val("Checklist1",1) doesn't work. Only a "true" Boolean statement works.
I'm splitting a reaper.GET_EXT_STATE string into a table. One of the table values is the string "true" since you can only save a string in EXT_STATE.
So, when I split the string into a table, I (for example) a result of val[1]="true".
Any ideas?
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
03-27-2020, 01:45 PM
|
#4
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
This is my ugly work-around:
Code:
if vals[2] == "true" then GUI.Val("Checklist1",true) else GUI.Val("Checklist1",false) end -- applying persistent state to checklist
if vals[4] == "true" then GUI.Val("Checklist2",true) else GUI.Val("Checklist2",false) end -- applying persistent state to checklist
if vals[6] == "true" then GUI.Val("Checklist3",true) else GUI.Val("Checklist3",false) end -- applying persistent state to checklist
Still hoping there is a more elegant way of doing this... and that I just overlooked something.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
03-27-2020, 02:06 PM
|
#5
|
Human being with feelings
Join Date: Dec 2017
Posts: 152
|
Quote:
Originally Posted by Thonex
val[1] = “true”
|
With quotes, it's a string.
|
|
|
03-27-2020, 02:08 PM
|
#6
|
Human being with feelings
Join Date: Jul 2009
Posts: 1,071
|
Dunno if this might work ?
val=x
if reaper.HasExtState("") then
val = tonumber(reaper.GetExtState(""))
...
reaper.SetExtState("", tostring(val), false)
|
|
|
03-27-2020, 02:47 PM
|
#7
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by tufb
With quotes, it's a string.
|
Yes. I know. So I guess a more simplified way of asking would be:
How can a force a string”true” to equal a Boolean true. Keep in mind the value 1 doesn’t work in this GUI.Val() case.
Thanks.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
03-27-2020, 02:50 PM
|
#8
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by J Reverb
Dunno if this might work ?
val=x
if reaper.HasExtState("") then
val = tonumber(reaper.GetExtState(""))
...
reaper.SetExtState("", tostring(val), false)
|
I’ll look into that. May not be simpler than my work-around.
Right now my EXT_STATE had 6 pieces of data.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
03-27-2020, 03:48 PM
|
#9
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by Thonex
This is my ugly work-around:
Code:
if vals[2] == "true" then GUI.Val("Checklist1",true) else GUI.Val("Checklist1",false) end -- applying persistent state to checklist
if vals[4] == "true" then GUI.Val("Checklist2",true) else GUI.Val("Checklist2",false) end -- applying persistent state to checklist
if vals[6] == "true" then GUI.Val("Checklist3",true) else GUI.Val("Checklist3",false) end -- applying persistent state to checklist
Still hoping there is a more elegant way of doing this... and that I just overlooked something.
|
For a bit more elegance you could maybe loop through the table instead of doing it one by one, but in the end there's no way around somehow converting the saved string back to a boolean as you did I'd think.
|
|
|
03-27-2020, 03:58 PM
|
#10
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by nofish
For a bit more elegance you could maybe loop through the table instead of doing it one by one, but in the end there's no way around somehow converting the saved string back to a boolean as you did I'd think.
|
Thanks nofish!!
Nice to know I'm not totally nuts 😀 (Half nuts? Absolutely!)
Yeah... a loop would be nicer. I already declared everything and they were not sequential, so I'll leave it as is for now. But good to know in the future.
Be safe!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
03-27-2020, 04:03 PM
|
#11
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
|
Quote:
Originally Posted by Thonex
This is my ugly work-around:
Code:
if vals[2] == "true" then GUI.Val("Checklist1",true) else GUI.Val("Checklist1",false) end -- applying persistent state to checklist
if vals[4] == "true" then GUI.Val("Checklist2",true) else GUI.Val("Checklist2",false) end -- applying persistent state to checklist
if vals[6] == "true" then GUI.Val("Checklist3",true) else GUI.Val("Checklist3",false) end -- applying persistent state to checklist
Still hoping there is a more elegant way of doing this... and that I just overlooked something.
|
Are you saying that
Code:
GUI.Val("Checklist1", vals[2] == "true")
GUI.Val("Checklist2", vals[4] == "true")
GUI.Val("Checklist3", vals[6] == "true")
does not work?
I guess I'm misunderstanding something...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
03-27-2020, 05:37 PM
|
#12
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Fabian
Are you saying that
Code:
GUI.Val("Checklist1", vals[2] == "true")
GUI.Val("Checklist2", vals[4] == "true")
GUI.Val("Checklist3", vals[6] == "true")
does not work?
I guess I'm misunderstanding something...
|
BINGO!!!!
Ding ding ding....
I didn't realize I could use a true argument ("==") as a true in this case. Wow... why didn't I know this??!
Thanks a ton Fabian!
Cheers,
Andrew K
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
03-28-2020, 11:10 AM
|
#13
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
|
Quote:
Originally Posted by Thonex
BINGO!!!!
Ding ding ding....
I didn't realize I could use a true argument ("==") as a true in this case. Wow... why didn't I know this??!
Thanks a ton Fabian!
Cheers,
Andrew K
|
OK! So I didn't misunderstand.
Great that it works.
Have fun
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
03-29-2020, 04:31 PM
|
#14
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Fabian
OK! So I didn't misunderstand.
Great that it works.
Have fun
|
Yes!
You can see it in action here:
https://forum.cockos.com/showthread.php?t=233409
Thanks again fro your help!
Cheers,
Andrew K
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:12 AM.
|