Scripting error

JackOats
Posts: 54
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Tue May 21, 2019 10:48 am

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.
Attachments
SCRIPTINGerror.Screenshot 2019-05-21 at 11.26.15.png
SCRIPTINGerror.Screenshot 2019-05-21 at 11.26.15.png (24.03 KiB) Viewed 2797 times
Scripting.Screenshot 2019-05-21 at 11.25.43.png
Scripting.Screenshot 2019-05-21 at 11.25.43.png (157.48 KiB) Viewed 2797 times
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
terrymcg
Posts: 23
Joined: Mon Apr 08, 2019 12:35 am

Wed May 22, 2019 1:19 am

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
User avatar
Captain
Posts: 68
Joined: Sat Aug 25, 2018 11:12 am

Wed May 22, 2019 8:32 am

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! :D), looks much better without the space.
JackOats
Posts: 54
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Thu May 23, 2019 8:59 pm

@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. :)
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
terrymcg
Posts: 23
Joined: Mon Apr 08, 2019 12:35 am

Fri May 24, 2019 12:28 am

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
JackOats
Posts: 54
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Fri May 24, 2019 8:31 am

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".
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
User avatar
Captain
Posts: 68
Joined: Sat Aug 25, 2018 11:12 am

Fri May 24, 2019 2:52 pm

I'm happy to help with debugging, but I'd really need a screenshot (or ideally copy&paste) of the code... :)
JackOats
Posts: 54
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Fri May 24, 2019 5:03 pm

@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?
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
User avatar
Captain
Posts: 68
Joined: Sat Aug 25, 2018 11:12 am

Sat May 25, 2019 10:51 am

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 :D), 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.
JackOats
Posts: 54
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Sat May 25, 2019 7:23 pm

O.K. Thanks. Will try that. Away from home at the moment - but as soon as I get back tomorrow.☺
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
Post Reply