1. #1
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    476

    Default ZScript Window button path

    I am trying to IGetStatus of a ISwitch in the Zscript window. I feel stupid but is their a path for buttons in the script window?

    I have ran into this before. I really hate creating a sub-palette just to check if something is enabled or disabled...
    Last edited by Nyx702; 06-04-12 at 01:47 PM.

  2. #2
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,597

    Default

    You can do it two ways. You can use "zscript:" for the path, adding the switch name. Or you can use the numerical position relative to the button you are using, so one place to the left is -1, one place to the right is 1, etc.


    [CODE][ISwitch,"Left",0,"Popup info Text",,,,]

    [IButton,"Get States from paths","Get switch states",
    [Note,[StrMerge,"Left state is ",[IGet,"zscript:Left"]," Right state is ",[IGet,"zscript:Right"]],,2]
    ]

    [IButton,"Get States from relative position","Get switch states",
    [Note,[StrMerge,"Left state is ",[IGet,-2]," Right state is ",[IGet,1]],,2]
    ]

    [ISwitch,"Right",0,"Popup info Text",,,,][/CODE]


    Note - I've used [IGet] in my example to test if the switch is pressed/unpressed as it is a simpler way to demonstrate the code. [IGetStatus] will show whether the switch is enabled or not just as well.

  3. #3
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    476

    Default

    Fantastic! I never knew about the relative positions! Thanks so much Marcus. Once again you always have the answer I am looking for I just assumed the path "Zscript:" was for the toolbar menu only.

    Will the relative position way work in other menus too?

  4. #4
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    8,597

    Default

    Quote Originally Posted by Nyx702 View Post
    Fantastic! I never knew about the relative positions! Thanks so much Marcus. Once again you always have the answer I am looking for I just assumed the path "Zscript:" was for the toolbar menu only.

    Will the relative position way work in other menus too?

    If I remember correctly, the relative position way will work in plugin menus, though I don't use it as I often move stuff around when I'm writing a plugin. It's also easier to read and manage the code if the paths are there.

    Cheers,

  5. #5
    Senior Member User Gallery
    Join Date
    May 2007
    Location
    Raleigh NC
    Posts
    476

    Default

    Ah interesting. Yea I agree it would be easier to manage with the paths. I was just curious.

    Thanks again.

Posting Permissions

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