1. #1
    Senior Member Follow User Gallery
    Join Date
    Jul 2014
    Posts
    111

    Question Zscript Ternary operator

    Does ZScript have a ternary (contitional) operator?

    No. I asked this two years ago! D'oh!

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    zscript ternary ? no! : d'oh!

    :-)

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Jul 2014
    Posts
    111

    Default

    Well if fails else I'll ask again next year








    And yes Marcus, I appreciate that was the best answer ever!

  4. #4
    Senior Member Follow User Gallery
    Join Date
    Jul 2014
    Posts
    111

    Default

    Any hoops I did manage to get the Lazy Mouse toggle to work as a macro in the end:
    It tells you the status of the Lazy Mouse (I find it difficult to work out at low settings)

    // lazy Mouse switch
    // 21 March 2019
    [IButton, "lazy Mouse", "Toggle lazy Mouse",
    [VarDef, lazyState, ""]
    [VarDef, lazyBool, 0]
    // is it switched on?
    [VarSet,lazy,[IGet,Stroke:LazyMouse]]
    [If, [IGet, Stroke:lazy Mouse],
    [VarSet, lazyState,"OFF"]
    [VarSet, lazyBool, 0]
    // if it's ON, turn it OFF
    [IUnPress, Stroke:lazy Mouse]
    ,// else
    [VarSet,lazyState,"ON"]
    [VarSet, lazyBool, 1]
    // if it's OFF, switch it ON
    // press lazy mouse
    [IPress, Stroke:lazy Mouse]
    ]
    // Notebar
    [NoteBar, [StrMerge, "Lazy Mouse is ", lazyState], lazyBool]
    // [Note,[StrMerge, "Lazy Mouse is ", "\n", lazyState],, 1, 1]

    ]// End of ZScript

  5. #5
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Thumbs up

    You can simplify the code like this:

    [IButton, "lazy Mouse", "Toggle lazy Mouse",
    [VarSet, lazyState, "OFF"]
    [VarSet, lazyBool, 0]
    [IToggle,Stroke:lazy Mouse]
    [If, [IGet, Stroke:lazy Mouse],
    [VarSet, lazyState,"ON"]
    [VarSet, lazyBool, 1]
    ]
    // Notebar
    [NoteBar, [StrMerge, "lazy Mouse is ", lazyState], lazyBool]
    ]// End of ZScript


    (I always forget about IToggle!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •