Home Forums Macros Strange and random user variable behaviour

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #6242

    Hello,

    I have a macro with “Automatic Start” that declares a number of variables upon starting my project. Declaration is:
    ——
    Declare int $Looper1Locked$ = 1
    MidiSend “Launchpad MK2” 157 81 53

    Declare boolean $Loop1Selected$ = false
    MidiSend “Launchpad MK2” 157 71 41
    Declare boolean $Loop2Selected$ = false
    MidiSend “Launchpad MK2” 157 72 0
    MidiSend “Launchpad MK2” 157 82 0
    Declare boolean $Loop3Selected$ = false
    MidiSend “Launchpad MK2” 157 73 0
    MidiSend “Launchpad MK2” 157 83 0
    Declare boolean $Loop4Selected$ = false
    MidiSend “Launchpad MK2” 157 74 0
    MidiSend “Launchpad MK2” 157 84 0
    Declare boolean $Loop5Selected$ = false
    MidiSend “Launchpad MK2” 157 75 0
    MidiSend “Launchpad MK2” 157 85 0
    Declare boolean $Loop6Selected$ = false
    MidiSend “Launchpad MK2” 157 76 0
    MidiSend “Launchpad MK2” 157 86 0
    —–
    And when I open up Macro Variable Viewer I can see them there.
    However, suddenly a random number of macros that use the variables above are “red-marked” in the Macro list and will not therefore start. When opening them some show NO errors when clicking “Check” (which in itself is very strange). And some of them show below error even though variables are correctly declared in variable viewer:

    —–Macro content—-
    RepeatWhile {$Loop1Selected$ == false}
    If {$Looper1Locked$ == 0}
    MidiSend “Launchpad MK2” 157 81 53
    Set $Looper1Locked$ = 1
    Else
    MidiSend “Launchpad MK2” 157 81 0
    Set $Looper1Locked$ = 0
    EndIf
    MacroStop
    EndRepeat
    —–
    —–error —-
    Line: 1, Error in command: RepeatWhile Bad parameter $Loop1Selected$ == false:RepeatWhile: Incorrect condition: Syntax Error 1:17->19 : [==] : L’opérateur [==] ne peut pas être appliqué entre des objets de type [int] et [boolean] Line: 1, Error in command: EndRepeat Found EndRepeat but no structure RepeatWhile has been declared before
    —–

    Do you have any idea what is happening? Thanks!

    #6246
    Philippe OllivierPhilippe
    Keymaster

    Hi Daniel,
    I see something in french in the error repport :

    L’opérateur [==] ne peut pas être appliqué entre des objets de type [int] et [boolean]
    Which means “The [==] operator cannot be applied between objects of type [int] and [boolean]”
    We should fix this language confusion…

    Is there another macro using this $Loop1Selected$ variable?
    If yes, does it set the variable to 1 or 0, or any int?

    That could be the cuylprit.

    Also, you need to declare the variable in every macro that use it.
    So you should put :

    Declare Once boolean $Loop1Selected$ = false

    At the top of the second macro.
    That may fix the error…

    Philippe

    #6248

    Hello! Thanks again for a quick answer!

    A few things:
    1. No, I do not Set the boolean declared variables to an int in some other macros ( I just checked)
    2. It seems completely random which macros get red marked and which don’t. Some that do use the variables are not red and are working correctly and some are red and hence cannot be started. And some that are red marked do not get any error when I click “Check” in the macro itself
    3. These errors suddenly appeared today seemingly from nowhere. I had made no changes to haw the variables are declared and used in the macros. And at the same time the Setting I used to recall was emptied. So something seemed to have changed??
    4. I am using these variables as “Global” variables, basically to read values updated/states cross macros. If I declare them (and give them a value) in every macro this will overwrite value and defeat the purpose

    Thanks again!

    #6249

    Hi again,

    HELP again. Just now, out of nowhere, I got the same issues with the user variables again. And I haven’t changed or worked with any of these particular variables. So again a lot of random macros are red marked in the macro viewer. And also some validated macros will suddenly not work (they worked fine only 10 minutes ago) and Logelloop seems to freeze. It now seems to be having trouble using the Logelloop variables as well. This validated (not red marked) macro below gets stuck at the first If statement with $state_record$ and everything freezes.
    —–
    DoRepeat
    If {$state_record$ == true}
    Record
    Sleep 50
    RestartLoop
    MidiSend “Launchpad MK2” 146 31 122
    BreakRepeat
    EndIf
    If {$current_last_full_track$ == 0}
    BreakRepeat
    EndIf
    If {$state_mute$ == true}
    Mute
    RestartLoop
    MidiSend “Launchpad MK2” 146 31 122
    BreakRepeat
    EndIf
    If {$state_overdub$ == true}
    Overdub
    RestartLoop
    MidiSend “Launchpad MK2” 146 31 122
    BreakRepeat
    EndIf
    While true
    —-

    Right now I can basically not do anything. Thanks again!

    #6250
    Philippe OllivierPhilippe
    Keymaster

    Hi Daniel,
    Here it is not a variable issue.

    In any DoRepeat // While or RepeatWhile // EndRepeat loop, you need a sleep or waitDuration message like this :

    DoRepeat
    // Your code here
    WaitDuration 30
    While true

    If you don’t put a sleep time, the loop will go so fast that it will freeze Logelloop and even in certain situation, Logelloop may crash…

    Also regarding the variable error message issue, don’t forget to declare your variable in every macro that use it.

    Philippe

    #6251

    Hi,

    Ok. I will add the sleep in all my While/Repeat loops. Thanks!

    Regarding adding variable declaration in ALL macros, isn’t it mandatory to set a value when declaring a variable? I am using the variables to store a state between different macros. I.e. “Global” variables. So I can read the current value set by another macro. Or am I misunderstanding something here?

    #6252
    Philippe OllivierPhilippe
    Keymaster

    You can define the variable with the same value in all macro.
    Just put a once attribute in the variable declaration process so that it will only happen when the macro is loaded.

    So I can read the current value set by another macro

    Yes, you can with a global variable.

    #6253
    Philippe OllivierPhilippe
    Keymaster

    You can define the variable with the same value in all macro.
    Just put a once attribute in the variable declaration process so that it will only happen when the macro is loaded.

    So I can read the current value set by another macro

    Yes, you can with a global variable.

    #6254

    Aha, now I think I understand. So the declaration is only important for when all macros are initially loaded in the project, not for when triggering the macros. Ok, I will use the “once”. Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.