I'm trying to write a simple function:
function toDecimal(val : integer) : integer;
begin
val := val * (100/127);
toDecimal := val;
end;
this syntax, as suggested for pascal, isn't working--it wants parentheses, which would make an endless recursive loop, right??
RETURN is also unrecognized.
tips??
thanks!
-eric
script function syntax??
-
woodslanding
- Member
- Posts: 1327
- Contact:
I don't quite get this one; it's called toDecimal, but returns integer? Is it supposed to convert MIDI's 0~127 to 0~100? Anyway - here are two varieties, one integer and one single.
I'm not totally sure about this, but I think you have to use "Result :=" and not the function name within Usine scripts. It might depend on something syntatic that has escaped my attention. At least it didn't work with these two examples.
If you like to do it a little bit more "proper", you can typecast val in second example:
Code: Select all
function toDecimal(val : integer) : integer;
begin
result := val * 100 DIV 127;
end;Code: Select all
function toDecimal(val : integer) : single;
begin
result := val * 100 / 127;
end;If you like to do it a little bit more "proper", you can typecast val in second example:
Code: Select all
result := single(val) * 100 / 127;Bjørn S
-
woodslanding
- Member
- Posts: 1327
- Contact:
just needed to know the word RESULT.
yes, doDecimal is a misnomer. Just want to show midi values in two digits. I'll actually trunc the result....
Thanks!
yes, doDecimal is a misnomer. Just want to show midi values in two digits. I'll actually trunc the result....
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
Who is online
Users browsing this forum: No registered users and 80 guests
