Old 03-27-2020, 12:19 PM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default 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.
Thonex is offline   Reply With Quote
Old 03-27-2020, 01:22 PM   #2
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

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
J Reverb is offline   Reply With Quote
Old 03-27-2020, 01:42 PM   #3
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by J Reverb View Post
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.
Thonex is offline   Reply With Quote
Old 03-27-2020, 01:45 PM   #4
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

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.
Thonex is offline   Reply With Quote
Old 03-27-2020, 02:06 PM   #5
tufb
Human being with feelings
 
Join Date: Dec 2017
Posts: 152
Default

Quote:
Originally Posted by Thonex View Post
val[1] = “true”
With quotes, it's a string.
tufb is offline   Reply With Quote
Old 03-27-2020, 02:08 PM   #6
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Dunno if this might work ?


val=x

if reaper.HasExtState("") then
val = tonumber(reaper.GetExtState(""))
...

reaper.SetExtState("", tostring(val), false)
J Reverb is offline   Reply With Quote
Old 03-27-2020, 02:47 PM   #7
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by tufb View Post
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.
Thonex is offline   Reply With Quote
Old 03-27-2020, 02:50 PM   #8
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by J Reverb View Post
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.
Thonex is offline   Reply With Quote
Old 03-27-2020, 03:48 PM   #9
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Thonex View Post
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.
nofish is offline   Reply With Quote
Old 03-27-2020, 03:58 PM   #10
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by nofish View Post
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.
Thonex is offline   Reply With Quote
Old 03-27-2020, 04:03 PM   #11
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Quote:
Originally Posted by Thonex View Post
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...
Fabian is offline   Reply With Quote
Old 03-27-2020, 05:37 PM   #12
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by Fabian View Post
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.
Thonex is offline   Reply With Quote
Old 03-28-2020, 11:10 AM   #13
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Quote:
Originally Posted by Thonex View Post
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...
Fabian is offline   Reply With Quote
Old 03-29-2020, 04:31 PM   #14
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by Fabian View Post
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.
Thonex is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.