On Variation Callback

In the Scripting Language Documentation, the callback “On Variation(oldVariation,newVariation)” states: “Called when you switch to another variation”.

I want to use this callback to notify me when the variation changes. It is confusing to me because I don’t have parameters I can pass to it … I just want to be notified when the variation changes. Can I pass null parameters?

For example, I tried using this code. It is looking for parameters to be passed and obviously I received a compile error:

On Variation ()
PutTriggerNotesInOrder(Trigger_Flat5AR, Flat5_Intervals)

The on variation callback has parameters which you can use or not.
You do not pass parameters to this callback as it is a callback which is called when a variation changes,
And the you can use the 2 parameters and do what you like.

Yes, I understand this :slight_smile: As you can see above, I tried this, but I got a syntax error on “On Variation()”. Can you give me a short code example of how to code it properly to avoid the syntax error?

Wanna share the syntax error???

Oooops, sorry … I should have included it in the original post. Here it is:

Scriptlet (Scriptlet) - - Syntax Error in “Main”: Line 658, Col 14: Unexpected or unrecognized token: ‘)’
Extraneous input ‘)’ expecting {Var, Identifier}

It’s perfectly documented in the language manual

Usage (Rackspace, Global Rackspace and Gig file scripts):

on variation ( oldVariation : integer, newVariation : integer)
// Called when you switch to another variation
// The parameters indicate which one you’re in now
// and from which one you came


Those “parameters” are not to be provided from you - they are just values which are “delivered” each time the callback is triggered, and they have to be defined as the manual states - if you’ll need them or not.
So an empty bracket must not be used with this callback!
You’ll always get two integer values for “oldVariation and newVariation” from this callback.

Correct. A callback is not the same as a function. You don’t call it. It calls you!

1 Like

Yep, I am expecting this callback to provide me the name of the old and new variations. So I tried this code in my Scriptlet and received a syntax error:

Example code:

OldVariation : Integer;
NewVariation : Integer;

on variation (OldVariation, NewVariation)
Print("OldVariation, NewVariation: “+OldVariation+” , "+ NewVariation)

SYNTAX ERROR: Scriptlet (Scriptlet) - - Syntax Error in “Main”: Line 663, Col 28: Unexpected or unrecognized token: ‘,’
Mismatched input ‘,’ expecting ‘:’

You miss the :integer after the parameters

The syntax is clear.

on variation ( oldVariation : integer, newVariation : integer)

I tried this exactly as you suggest, but still got a syntax error:

on variation ( oldVariation : integer, newVariation : integer)
Print("oldVariation, newVariation: “+oldVariation+” , "+ newVariation)

SYNTAX ERROR: Scriptlet (Scriptlet) - Semantic error in “Main”: Line 663, Col 4: Not valid in this script entity.

Are you writing a rackspace script or a scriptlet?


The Language Documentation states, “Available in
Rackspace scripts and scriptlets”

That’s the problem folks!!! the code works nicely in the Rackspace Script but gets an error in my Scriptlet!

I need this information while in my Scriptlet.

This is what I see in the documentation:

ScreenHunter 45

Not for Scriptlets.

Here is what I see:

Here is the ink to what I am looking at: List of Callbacks — GPScript 4.0 documentation

So, if I put this code in my Global Rackspace, how do I get notice of a Variation change down and into my Scriptlet?

What do you want to achieve?

1 Like

The answer to your question is irrelevant.

However, that being said, I know you are trying to help - so, I need to compute a variable in my Scriptlet that cannot be a parameter in the scriptlet. … and therefore when variations are changed, the Scriptlet does not remember the value of a variable. it only remembers the value of a Scriptlet parameter.

From where did you get that old link?

That’s a typo in an old version and was corrected for 4.5