Page 1 of 3
Scripting error
Posted: Tue May 21, 2019 10:48 am
by JackOats
Hi - I'm trying to create the Volume Knob given as an example in MD.
I've followed the written tutorial & double checked it several times but it isn't compiling.
I'm new to scripting in Java so, after moving/deleting & generally becoming more bewildered I have to admit I don't know what adjustments to make to the script to make it work.
Pathetic, I know, but any help would be much appreciated.
Many thanks.
Re: Scripting error
Posted: Wed May 22, 2019 1:19 am
by terrymcg
Hi JackOats...
JackOats wrote: ↑Tue May 21, 2019 10:48 am
I'm new to scripting in Java so, after moving/deleting & generally becoming more bewildered I have to admit I don't know what adjustments to make to the script to make it work.
Pathetic, I know, but any help would be much appreciated.
We all have to start somewhere... don't worry, it'll get clearer as you go along!
My guess, and I'm not a Java guru, is the variable declaration isn't allowed there 'cause it will only exist in the context of the
if statement. Consider this:
Code: Select all
boolean foo = true;
if (foo)
double bar = 1.0;
Log ("bar = " + bar);
What the compiler sees is this:
Code: Select all
boolean foo = true;
if (foo) {
double bar = 1.0;
}
Log ("bar = " + bar);
So it's objecting to the creation of a variable that's going to get thrown away as soon as it's set.
This, on the otherhand, compiles:
Code: Select all
boolean foo = true;
if (foo) {
double bar = 1.0;
Log ("bar = " + bar);
}
I hope that helps!
Cheers,
--
Terry McG
Re: Scripting error
Posted: Wed May 22, 2019 8:32 am
by Captain
What terrymcg said
It’s always a good idea to use the curly brackets with IF statements, otherwise it might not be super obvious what exactly is contained inside the IF block.
In addition, I spotted a couple of typos in the code: in the ProcessSample() function, there’s ”Getvalue()” and ”Setvalue()” with a lowercase ”value”. It should be ”GetValue()” and ”SetValue()” (case matters in Java).
Also, ”inputJack. GetValue()”, while it seems to compile (that was news for me!
), looks much better without the space.
Re: Scripting error
Posted: Thu May 23, 2019 8:59 pm
by JackOats
@terrymcg
@Captain
Hi Guys - Thanks very much for the messages & suggestions.
Well, I've corrected all the typos I can find & pored over the scripting example for most of yesterday & today
but I'm still getting the same error message. More studying required I think. Thanks anyway Guys.
Re: Scripting error
Posted: Fri May 24, 2019 12:28 am
by terrymcg
JackOats wrote: ↑Thu May 23, 2019 8:59 pm
Well, I've corrected all the typos I can find & pored over the scripting example for most of yesterday & today
but I'm still getting the same error message. More studying required I think. Thanks anyway Guys.
Now that I look more closely...
While the code that's causing you grief needs more braces, there's also a bigger issue...
Just to get the braces thing out of the way, something like this will compile:
Code: Select all
if(outputJack.IsConnected()) {
double signal = inputJack.GetValue();
signal *= mvolume;
}
The bigger issue is where you have it, in the "GetTooltipText" method (as well as in ProcessSample()). If you just delete lines 325 thru 329, your compile error should go away and, since you've got the code in ProcessSample (where it should be), it may even do what you want
Hang in there!
Cheers,
--
Terry McG
Re: Scripting error
Posted: Fri May 24, 2019 8:31 am
by JackOats
Hi Terry,
Thanks for the message:
If you just delete lines 325 thru 329, your compile error should go away and, since you've got the code in ProcessSample (where it should be), it may even do what you want
I deleted lines 325 - 329, as you suggested above, but instead of failing with 1 error it now has failed with 6 errors.
One reads: "double cannot be dereferenced" and the other 5 read: "cannot find symbol".
Re: Scripting error
Posted: Fri May 24, 2019 2:52 pm
by Captain
I'm happy to help with debugging, but I'd really need a screenshot (or ideally copy&paste) of the code...
Re: Scripting error
Posted: Fri May 24, 2019 5:03 pm
by JackOats
@Captain
"I'm happy to help with debugging"
That would be most kind - and very helpful, thank you.
Would you need the whole script or just the problematic part?
Re: Scripting error
Posted: Sat May 25, 2019 10:51 am
by Captain
JackOats wrote: ↑Fri May 24, 2019 5:03 pm
Would you need the whole script or just the problematic part?
If it's OK for you (meaning there are no trade secrets or anything
), the full code is of course the easiest. Then I could just copy&paste it into my MD, see what the problems are, try to fix them, and make sure it compiles OK. Maybe sending it through Google Drive or similar would be easiest, so that the forum post doesn't get overly long, but anything works for me! EDIT: Seems like you can attach files to forum posts, that's also a viable option.
Re: Scripting error
Posted: Sat May 25, 2019 7:23 pm
by JackOats
O.K. Thanks. Will try that. Away from home at the moment - but as soon as I get back tomorrow.☺