scripts--converting to and from booleans
-
woodslanding
- Member
- Posts: 1327
- Contact:
I'd like to send the result of a boolean out a data port, but it requires a float. Are there conversions for this? I'm doing an if then else, but I always like clean code....
Nothing much out there on the web.
Thanks!
Nothing much out there on the web.
Thanks!
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
- Contact:
okay, I just wrote a custom function for it. no big deal.
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
- Contact:
agg. now I just want to print out the value of a boolean, and don't know how to do it....
my kingdom for a manual
my kingdom for a manual
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
- Contact:
geez, never mind AGAIN. :/
guess I'd still like to know how this is done, tho.
guess I'd still like to know how this is done, tho.
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Unlike in C (and derivatives) where binary 0 is FALSE and everything else is TRUE, you have to convert the booleans to integers. I suspect that the internal values are 0 and 1 just like in the Usine modules - here's a convertion function:
(...and once again I have to add begin...end in an if-else-statement where it shouldn't be needed...)
Code: Select all
function boolToInt(b : boolean) : integer;
begin
if (b) then begin
result := 1;
end
else begin
result := 0;
end;
end;Bjørn S
-
woodslanding
- Member
- Posts: 1327
- Contact:
Okay, that's what I did.
Just didn't want to have to put this in every script where I need to do the conversion....
Just didn't want to have to put this in every script where I need to do the conversion....
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Well, I don't I have anything better to offer, but you might consider from case to case whether storing booleans or integers (0 and 1) is the most effective. If you do a lot of testing on the values, I think boolean is the way to go, but if you're mostly storing and retrieving the data to send it out again, integers would often be better.
I tried some varieties of using typecasting to get integers from booleans without success. I wouldn't be at all surprised if there is a way that I don't know of. Olivier?
I tried some varieties of using typecasting to get integers from booleans without success. I wouldn't be at all surprised if there is a way that I don't know of. Olivier?
Bjørn S
Who is online
Users browsing this forum: No registered users and 47 guests
