Home AMX User Forum NetLinx Studio

GOTO Statement

Is there any GOTO Statements or key words in Netlinx? Or else what keyword or logic will help me to go back to a particular line.

Comments

  • There are multiple ways to jump through code.

    Search for a specific word (cntrl+f) or use the following buttons that are found on the Edit toolbar:
    Goto Line to go to a specific line number
    Goto Section (define_event, define_variables, etc)
    Goto Subroutine (gives you a list of defined functions and calls in the current file)
    Add Bookmark (bookmarks the line the cursor is on, then use F2 to jump through the bookmarks)
    Clear Bookmarks

    I don't think any of these have keyboard shortcuts by default, but you can add your own shortcuts under Settings>Customize>Keyboard.
  • DHawthorneDHawthorne Posts: 4,584
    It's been so long since I've seen the default toolbar set in NS that I don't remember what's on it. But whether they are there by default or if I added them myself, you can have buttons on the toolbar to go to all the major sections, and another that will give you a function/call pulldown to g to a specific subroutine. I only wish they had the same for events.

    I find the bookmarks only nominally helpful, especially if you have more than 2 or 3 active, but they aren't entirely useless. But mostly, I just use good old ctrl-F to find a variable or a phrase, then F3 to find the next, etc.
  • I pretty much only use the bookmarks when I am debugging code. I find the offending Event, clear all bookmarks, and then bookmark the event and each subroutine that gets called as I follow the code.

    This makes it really easy to quickly jump from the event to function just by pressing F2.
  • arunmohan wrote: »
    Is there any GOTO Statements or key words in Netlinx? Or else what keyword or logic will help me to go back to a particular line.

    To answer your actual question, no, there's not a GOTO statement. You can build loops and branching logic using FOR, WHILE, IF, and BREAK. If you're in a function, you can also use RETURN for an early exit. If you need help translating your idea into code, let me know what you're trying to accomplish.
  • Joe HebertJoe Hebert Posts: 2,159
    arunmohan wrote: »
    Is there any GOTO Statements or key words in Netlinx? Or else what keyword or logic will help me to go back to a particular line.

    When you asked about a GOTO keyword and line numbers I assumed you are talking about the Neltinx language itself and not the editor.

    Netlinx is not like BASIC and you don’t navigate though code by referencing line numbers. Netlinx is event driven. You can’t jump to a line with a GOTO or branch to labels. Those types of keywords don’t exist.
    Your code will get triggered by events like CHANNEL_EVENT, BUTTON_EVENT, DATA_EVENT, and TIMELINE_EVENT. If you want to call some specified code you can branch to a function that is setup with DEFINE_FUNCTION.

    If you are indeed questioning the editor then please ignore everything I said.
  • Thank u all
Sign In or Register to comment.