585,973 active members*
4,165 visitors online*
Register for free
Login
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2015
    Posts
    4154

    if statements...

    Hy, can i use "and" , "or" operators ?
    someone has a full list of operators of "IF" function ?
    also, a list of available comands, as "IF", "While" ?

    kindly ! za kitten )

  2. #2
    Join Date
    Aug 2011
    Posts
    419

    Re: if statements...

    Here is document
    Attached Thumbnails Attached Thumbnails User Task 1.pdf   User Task 1.pdf  

  3. #3
    Join Date
    Apr 2009
    Posts
    1262

    Re: if statements...

    AND format example:

    IF [[[V181 EQ 1] AND [PP EQ 2]] EQ 1]NHOME

    OR could be used in place of AND in this example.


    Best regards,

  4. #4
    Join Date
    Jun 2015
    Posts
    4154

    Re: if statements...

    hello again, please i don't understand something in your example :

    IF [[[V181 EQ 1] AND [PP EQ 2]] EQ 1]NHOME
    IF [[[true] AND [false]] EQ 1]NHOME // supose conditions are true and false
    IF [[false] EQ 1]NHOME // how does this work ? [false eq 1] ?
    and what means NHOME ?

    kindly !

  5. #5
    Join Date
    Apr 2009
    Posts
    1262

    Re: if statements...

    Quote Originally Posted by deadlykitten View Post
    hello again, please i don't understand something in your example :

    IF [[[V181 EQ 1] AND [PP EQ 2]] EQ 1]NHOME This one = if true and true, goto line NHOME
    IF [[[true] AND [false]] EQ 1]NHOME // supose conditions are true and false Since this is an AND statement, both need to be true or EQ 1 in order to jump to line NHOME. if it were an OR statement, only one of them would need to be true in order to goto NHOME
    IF [[false] EQ 1]NHOME // how does this work ? [false eq 1] ? IF the statement is false, it does not goto NHOME, but goes to the next line in the program following the IF statement.
    and what means NHOME ? Just a line name vs a line number to jump to. Nice to use names since they mean more and using the sequence renumber sill not change them if used.

    kindly !
    Best regards,

  6. #6
    Join Date
    Jun 2015
    Posts
    4154

    Re: if statements...

    hello mr. Wizard nice to hear from you again

    i am missing something :

    v1=1
    IF [[v1 eq 2] eq 1] = IF [ false eq 1] // i dont undersand how can "false" be compared with "1" ?
    This comparation is between a boolean (or logical) expresion with a numeric expresion.
    IF [ false eq 1] GOTO N100 >>> false=1 and will go to N100, or false<>1, and will skip to next line ?

    or is it "false=0" and "true=1" ?

    and another thing, about NHOME ... until now i used only numerical adreses, N100, etc, but NHOME is more human ... please, is there a condition for this adresses, like Nxxx, all begin with N, and word should be 7caracters long, and xxxx can be letter or number ? something like that ? ...

    For example, i would like to code like this :

    drill14 call OS01
    drill6 call OS02
    reamer call OS03

    but i think i can not, so can i use this :

    Ndrill14 call OS01
    Ndrill6 call OS02
    Nreamer call OS03 ?

    kindly

  7. #7
    Join Date
    Dec 2008
    Posts
    3109

    Re: if statements...

    Quote Originally Posted by deadlykitten View Post
    and another thing, about NHOME ... until now i used only numerical adreses, N100, etc, but NHOME is more human ... please, is there a condition for this adresses, like Nxxx, all begin with N, and word should be 7caracters long, and xxxx can be letter or number ? something like that ? ...

    For example, i would like to code like this :

    drill14 call OS01
    drill6 call OS02
    reamer call OS03

    but i think i can not, so can i use this :

    Ndrill14 call OS01
    Ndrill6 call OS02
    Nreamer call OS03 ?

    kindly
    This is taken from a programming manual,
    format is Nxxxxx ......x can be any number or letter only, maximum of 5 characters after the N

    some programmers use NA1 or NB1
    where this "label" style may be used to indicate an A or B turret restart line on a lathe

    Code:
    Sequence Name
    All blocks in a program are assigned a sequence name that begins with address character “N”
    followed by an alphanumeric sequence.
    Functions such as a sequence search function, a sequence stop function and a branching function
    can be used for blocks assigned a sequence name.
    A sequence name that contains only alphabetic characters is called a sequence label and the one
    that contains only numbers is called a sequence number. In this manual, both of them are referred
    to as a sequence name.
    Sequence Name Designation
    • Enter letters of the alphabet (A to Z) or numbers (0 to 9) following address character “N”.
    • Up to five characters can be entered in succession to the address.
    • Both alphabetic characters and numbers may be used in a sequence name. If an alphabetic
    character is used in a sequence name, however, the sequence name must begin with an
    alphabetic character.
    • Although a sequence name must be specified at the beginning of a block, an optional block skip
    code may be placed before a sequence name.
    • Sequence numbers may be specified in any order.
    • Since sequence names are handled in units of characters, the following names are judged to be
    different sequence names.
    • N0123 and N123
    • N00 and N0
    • When a sequence label is used, place a space or a tab after the sequence label

  8. #8
    Join Date
    Apr 2009
    Posts
    1262

    Re: if statements...

    Superman is spot on with the rules. Where you are having trouble or not understanding is how the AND statement is being used. If you look at the example:

    IF [[[V181 EQ 1] AND [PP EQ 2]] EQ 1]NHOME
    IF TRUE AND TRUE EQ TRUE NHOME

    A normal IF statement would be:
    IF [V1 EQ 1]NJMP1
    IF TRUE NJMP1

    If either example is FALSE then the next line will be executed in stead of the jump.

    Hope this helps to clarify.

    Best regards,

  9. #9
    Join Date
    Jun 2015
    Posts
    4154

    Re: if statements...

    Quote Originally Posted by OkumaWiz View Post
    Superman is spot on with the rules. Where you are having trouble or not understanding is how the AND statement is being used. If you look at the example:

    IF [[[V181 EQ 1] AND [PP EQ 2]] EQ 1]NHOME
    IF TRUE AND TRUE EQ TRUE NHOME

    A normal IF statement would be:
    IF [V1 EQ 1]NJMP1
    IF TRUE NJMP1

    If either example is FALSE then the next line will be executed in stead of the jump.

    Hope this helps to clarify.

    Best regards,
    so, If [ false eq 0] = IF true ?

  10. #10
    Join Date
    Apr 2009
    Posts
    1262

    Re: if statements...

    Yes,

    But I'm not sure you are getting it yet. Because we are checking a variable we can either check to see of the variable is true or false depending on what we are checking.

    IF [V1 EQ 1]NJMP1 = IF variable #1 is = 1 goto line NJMP1, if it is not = 1 goto the next line
    IF [V1 EQ 0]NJMP2 = IF variable #1 is = 0 goto line NJMP2, if it is not = 0 goto the next line
    IF [V1 EQ 128]NJMP3 = IF variable #1 is = 128 goto line NJMP3 if it is not = 128 goto the next line

    Now we can change the logic by changing the criteria;

    NE = NOT EQUAL
    LE = LESS THAN OR EQUAL
    LT = LESS THAN
    GT = GREATER THAN
    GE = GREATER THAN OR EQUAL


    Just about anything you want to accomplish can be done using these logical codes. Perhaps you should tell us what you are trying to do rather than get caught up in boolean logic. We may be able to better help you.

    For example, here is a panel switch check routine that is commonly used on a twin turret, twin spindle LT200MY. It is used to verify that the operation panel switched are correct for normal operation of the machine. We can check to make sure coolant is ON, Feed rate override is at 100%, and more as shown. We can even generate our own alarm messages:

    G13 (WRITTEN FOR LT200MY WITH P200 CONTROL)
    G140
    (TURN FEED TO 0 AND SINGLE BLOCK ON FOR RESTART.)
    ( SWITCHES CAN BE ADJUSTED AFTER CHECK HAS OCCURED.
    INDIVIDUAL MODE CAN ONLY BE USED DURING RESTART.)
    G50S500
    CALL OCHKA (OR OCHK1 FOR NO BARFEED)
    G14
    G141
    G50S500
    CALL OCHKB
    M2
    OCHKA
    IF[VORD[0016]EQ 1]NRTS (IF MACHINE LOCK ON)
    (IF[VTOFZ[2]EQ 0]NCK0
    VUACM[1]='T-A2 NOT AT Z0.0'
    VDOUT[992]=1)
    NCK0 IF[VORD[0015]EQ 0]NCK1
    VUACM[1]='DRY RUN ON'
    VDOUT[992]=1
    NCK1(IF[VORD[0014]EQ 0]NCK2
    VUACM[1]='BLOCK DELETE ON'
    VDOUT[992]=1)
    NCK2 IF[VORD[0022]EQ 1]NCK4
    VUACM[1]='SPINDLE OVERIDE'
    VDOUT[992]=1
    NCK4 IF[VORD[0031]EQ 1]NCK5
    VUACM[1]='COOLANT OFF'
    VDOUT[992]=1
    NCK5 IF[VORD[011A]EQ 1]NCK6
    VUACM[1]='R-SPNDL OVERRIDE'
    VDOUT[992]=1
    NCK6 IF[VRSTT NE 0]NCK7 (IF RESTART)
    NCK IF[VORD[0011]EQ 0]NCK7
    VUACM[1]='A INDIVIDUAL ON'
    VDOUT[992]=1
    NCK7 IF[VORD[001C]EQ 1]NCK8
    VUACM[1]='LOAD MONITOR OFF'
    VDOUT[992]=1
    NCK8 IF[VORD[0110]EQ 1]NCK9
    VUACM[1]='MA OVERRIDE'
    VDOUT[992]=1
    NCK9 IF[VORD[0106]EQ 1]NCK10
    VUACM[1]='MB OVERRIDE'
    VDOUT[992]=1
    NCK10 IF[VORD[0143]EQ 0]NCK11
    VUACM[1]='SYSTEM LINK ON'
    VDOUT[992]=1
    NCK11 IF[VRSTT NE 0]NCK12 (IF RESTART JUMP)
    IF[VORD[0013]EQ 1]NCK12 (SINGLE BLOCK)
    IF[VORD[0023]EQ 1]NCK12
    VUACM[1]='FEEDRATE NOT 100'
    VDOUT[992]=1
    NCK12 IF[VRSTT EQ 0]NRTS (IF NOT RESTART JUMP)
    NCKR1 IF[[VIRD[0030]+VIRD[0031]+VIRD[0032]]EQ 0]NCKR2
    VUACM[1]='FEEDRATE TOO HI'
    VDOUT[992]=1
    NCKR2 IF[VORD[0013]EQ 1]NRTS
    VUACM[1]='SINGLE BLK OFF'
    VDOUT[992]=1
    NRTS RTS
    OCHKB
    IF[VORD[0016]EQ 1]NRTS
    (IF[VTOFZ[2]EQ 0]NCK1
    VUACM[1]='T-B2 NOT AT Z0.0'
    VDOUT[992]=1)
    NCK1 IF[VRSTT NE 0]NRTS (IF RESTART)
    NCK13 IF[VORD[0012]EQ 0]NRTS
    VUACM[1]='B INDIVIDUAL ON'
    VDOUT[992]=1
    NRTS RTS
    OCHK1 (WITHOUT BARFEEDER)
    IF[VORD[0016]EQ 1]NRTS (IF MACHINE LOCK ON)
    IF[VORD[0015]EQ 0]NCK0
    VUACM[1]='DRY RUN ON'
    VDOUT[992]=1
    NCK0(IF[VORD[0014]EQ 0]NCK2
    VUACM[1]='BLOCK DELETE ON'
    VDOUT[992]=1)
    NCK2 IF[VRSTT NE 0]NCK3 (IF RESTART)
    NCK00 IF[[VIRD[0030]+VIRD[0031]+VIRD[0032]]EQ 0]NCK3
    NCK IF[VORD[0023]EQ 1]NCK3
    VUACM[1]='FEEDRATE NOT 100'
    VDOUT[992]=1
    NCK3 IF[VORD[0022]EQ 1]NCK4
    VUACM[1]='SPINDLE OVERIDE'
    VDOUT[992]=1
    NCK4 IF[VORD[0031]EQ 1]NCK5
    VUACM[1]='COOLANT OFF'
    VDOUT[992]=1
    NCK5 IF[VORD[011A]EQ 1]NCK6
    VUACM[1]='R-SPNDL OVERRIDE'
    VDOUT[992]=1
    NCK6 IF[VRSTT NE 0]NCK7 (IF RESTART)
    NCK IF[VORD[0011]EQ 0]NCK7
    VUACM[1]='A INDIVIDUAL ON'
    VDOUT[992]=1
    NCK7 IF[VORD[001C]EQ 1]NCK8
    VUACM[1]='LOAD MONITOR OFF'
    VDOUT[992]=1
    NCK8 IF[VORD[0110]EQ 1]NCK9
    VUACM[1]='MA OVERRIDE'
    VDOUT[992]=1
    NCK9 IF[VORD[0106]EQ 1]NCK11
    VUACM[1]='MB OVERRIDE'
    VDOUT[992]=1
    NCK10 IF[VORD[0143]EQ 0]NCK11
    VUACM[1]='SYSTEM LINK ON'
    VDOUT[992]=1
    NCK11 IF[VRSTT EQ 0]NRTS (IF RESTART)
    NCKR1 IF[[VIRD[0030]+VIRD[0031]+VIRD[0032]]EQ 0]NCKR2
    VUACM[1]='FEEDRATE TOO HI'
    VDOUT[992]=1
    NCKR2 IF[VORD[0013]EQ 1]NRTS
    VUACM[1]='SINGLE BLK OFF'
    VDOUT[992]=1
    NRTS RTS

    As you can see, the sky's the limit on what you can do, but don't let it intimidate you. Most of it is just basic yes/no logic.

    Best regards,

  11. #11
    Join Date
    Feb 2011
    Posts
    1

    Re: if statements...

    OkumaWiz can you send me your email on my PM.

Similar Threads

  1. Different Format Statements for different conditions?
    By slideleft in forum Post Processors for MC
    Replies: 4
    Last Post: 09-22-2011, 12:17 AM
  2. Format Statements
    By Xavior in forum Mastercam
    Replies: 5
    Last Post: 09-08-2011, 12:28 PM
  3. comment statements
    By compfranon in forum ArtCam Pro
    Replies: 0
    Last Post: 09-04-2011, 02:13 AM
  4. PRINT / MSG statements using AXIS front end
    By bogflap in forum LinuxCNC (formerly EMC2)
    Replies: 9
    Last Post: 03-16-2009, 02:43 PM
  5. If / Then Statements
    By Nanker in forum G-Code Programing
    Replies: 6
    Last Post: 10-23-2004, 06:11 AM

Tags for this Thread

Posting Permissions

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