Arrays Question

In the var section of my script, I have defined the following:

   Dexed1 : PluginBlock
   Dexed2 : PluginBlock
   Dexed3 : PluginBlock
   Dexed4 : PluginBlock
   Dexed5 : PluginBlock
   Dexed6 : PluginBlock
   Dexed7 : PluginBlock
   Dexed8 : PluginBlock

   PluginBlockArray    : PluginBlock Array = [Dexed1, Dexed2, Dexed3, Dexed4, Dexed5, Dexed6, Dexed7, Dexed8] 

   CurDexed : Integer = 3

Somewhere in my script, I am trying to load a GPPreset for Dexed3 as follows:  

    // LoadGPPreset (p : Block, presetName : String) autotype
    // GetWidgetLabel (w : Widget) returns String
    LoadGPPreset(GetWidgetLabel(PluginBlockArray[CurDexed]), PRESET)

However, I am getting the following error:

“012824 - DESIGN 28 (Rackspace) - Semantic error in “Main”: Line 1137, Col 33: Argument type mismatch”

May I please encourage you to refer more carefully to the documentation (aka RTFM) for system functions

The first parameter for LoadGPPReset is not a string and the issue has nothing to do with arrays.

I have read the definition of “LoadGPPreset”. That’s why I put the comment there in the code for you to see! I asked the question because I am trying to use an array to provide a PluginBlock to the statement. So, this issue certainly has to do with the use of Arrays.

I am obviously confused with SNTAX, so my question is: How can I use the Array “PluginBockArray” to provide the correct informtion?

I could have coded like this, but I am trying to avoid this voluminous code:

    CurDexed == 1 Do 
        LoadGPPreset(Dexed1, PRESET)
    CurDexed == 2 Do 
        LoadGPPreset(Dexed2, PRESET)
    CurDexed == 3 Do 
        LoadGPPreset(Dexed3, PRESET)
    CurDexed == 4 Do 
        LoadGPPreset(Dexed4, PRESET)
    CurDexed == 5 Do 
        LoadGPPreset(Dexed5, PRESET)
    CurDexed == 6 Do 
        LoadGPPreset(Dexed6, PRESET)
    CurDexed == 7 Do 
        LoadGPPreset(Dexed7, PRESET)
    CurDexed == 8 Do 
        LoadGPPreset(Dexed8, PRESET)

Yes, I know you’re trying to use an array ---- but you have two issues

  1. Your first parameter is a function GetWidgetLabel, that function returns a string but the first parameter for LoadGPPreset has to be a plugin block per the documentation

  2. Independently of that issue, the GetWidgetLabel function wants a widget as its parameter, but you are providing a plugin block

You probably meant to write

LoadGPPreset(PluginBlockArray[CurDexed], GetWidgetLabel(someWidget))

GP Script is strongly typed. You cannot pass parameters of the wrong type into function calls and that is why the compiler is correctly throwing the error:

Semantic error in “Main”: Line 1137, Col 33: Argument type mismatch”

1 Like

Thank you² You cleared up quite a bit for me :slight_smile: