Welcome to %s forums

BrainModular Users Forum

Login Register

FastScript - TParameter of Array: How to do Callback

I need help on a Patch
Post Reply
sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 03 Mar 2015, 13:55

Hello Everyone!

Sorry for Topic confusion I meant to say Array of Tparameter:


So I am running into an interesting problem.

I have an Array of Tparameter , and I am wanting to control by a Callback event referring to the name.

As example:

var pad : array [0..15] of Tparameter;

procedure callback (n:integer);
Begin
Case n of

pad0 :
pad1 :
etc..

It seems like the compiler does not understand that pad0 is a real Tparameter, because the iteration to create happens in the init procedure.
At least this is what I am assuming.

I was hoping to refer by name, as in previous scripts I have always had problems where I had to add another parameter and had to adjust the
entire callback procedure respectively to match the IO number.

Am I doing something wrong? Is there a different way to approach?
If this is the case, I guess it would probably be beneficial to update the compiler to accept that a Tparameter is an array of a specified length.

-S
"Every act of creation is first an act of destruction." -Picasso

sm_jamieson
Member
Posts: 559
Contact:

Unread post by sm_jamieson » 03 Mar 2015, 14:23

In pascal, the options in the case statement have to be constants known at compile time, so you cannot use general purpose variables there. I think you could use values declared as "const" rather than "var".
Anyway, did you mean pad[0], pad[1], etc. unless you have declared "pad0" and "pad1" elsewhere.

If you want to use variables you will have to use "if" instead of "case", e.g.

var pad : array [0..15] of Tparameter;

procedure callback (n:integer);
Begin
if n = pad[0] then ...
else
if n = pad[1] then ...
end;

Simon.

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 03 Mar 2015, 14:37

Awesome Simon,

Thank you for your help!
My brain has not had enough coffee this morning...and still very dense :P

I was wondering the same thing, however looking at a script such as the MIDI Arpeggiator they seemed to just reference the Tparameter variable.

No you are correct about the pad[0], pad[1], etc... Interestingly enough if I put pad[0] etc...the compiler takes it and if I put another Tparameter it won't.

-S
"Every act of creation is first an act of destruction." -Picasso

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 03 Mar 2015, 15:14

Okay the coffee is finally working!

Seems now its working for me, yes I did have to define the label as an index....now it seems to take the other Tparameters I put.

I am going to chalk it up to me :)

Thanks for your help Simon!

-S
"Every act of creation is first an act of destruction." -Picasso

Post Reply

Who is online

Users browsing this forum: No registered users and 50 guests