PDA

View Full Version : IFTHENGOTOlabel



shimpj@bellsouth.net
11-16-2002, 02:42 PM
If i go into FE and insert an INPUT command
how do i verify that the typed in response is corrtectly spelled? If not correctly spelled how do i insert another INPUT with "wrong-retry". Please give me a simple examle:Suppose you want your employee to insert a 1/8" bit.You want him to type "1/8 bit" as a response. How? Also,how is a label inserted in FE the proper way? Please show useses of IF THEN GOTO and a label insertion.
Thank you - Roy

bill.young
11-17-2002, 12:41 PM
Hi Roy,

Here's an example that I think does what you want. I couldn't use "1/8 bit" for the password phrase because it starts with a number, so I used the word "smallbit" instead.


I've written in some comments to try to explain how it works, but the important part starts at the line that reads TRYAGAIN: The only comment you really need to have is the one right before the PAUSE statement in the subroutine at the bottom of the page...it's the error message that the user sees if they type in the wrong thing.


Let me know if any of this doesn't make sense... it's kind of tricky to follow if you're not used to using the programming commands. The ShopBot programming manual gives a good intro to the commands that are available in the current software... there will be eventually be more as the Windows software develops.

Hope this helps,
Bill

****************************************

' User input example
'
' The start of your part file...
'
' yada...
' yada...
' yada.
'
' and now you're at the part when you're ready for the user input
'
' In the following section, if the password is typed correctly...
' it will continue with the rest of the file by going to...
' the CONTINUE: label
'
' If the password is typed incorrectly, it sends you to...
' the PASSERROR: subroutine, gives an error message, and...
' returns you to the TRYAGAIN: label to, well, try again.
'
' The password in this example is "smallbit". Choose a word that...
' doesn't start with a number or contain a special character.
'
'

TRYAGAIN:

INPUT "Type ( smallbit ) to continue" &password
&password = "&password"
IF &password = "smallbit" THEN GOTO CONTINUE

GOSUB PASSERROR

CONTINUE:


'
' when the password is correct it will continue with your part file
'
' yada...
' yada...
' yada.
'

END

' Make sure you put the END statement at the end of the body...
' of your part file and before your subroutines...
' or the program will execute the subroutines when the part file finishes


'and finally, here's the subroutine that handles typing errors

PASSERROR:
' incorrect password...hit any key and try again
PAUSE
GOTO TRYAGAIN

RETURN

Roy Shimp
11-17-2002, 02:12 PM
Bill - thanks a million. Roy

bill.young
11-18-2002, 01:45 PM
Hi Roy,

One thing to be careful of when you use these kind of statements... make sure that you don't cause the tool to move or do something un-expected if the operator types in the wrong keys.The following code gives the operator the option to go into keyboard control and reposition the tool if they hit the "Y" key. The comment and PAUSE statement after the IF test requires a keystroke to actually start the tool moving and adds one more level of safety, especially if you have someone else running the tool.

***********************************

INPUT "Would you like to reposition with keyboard control? (Y or N)" &keyboard
&keyboard = "&keyboard"
IF &keyboard = "Y" THEN SK

' hit any key to continue with the file
PAUSE

M2, 0, 0

************************************


If the movement command was immediately after the IF test like...


IF &keyboard = "Y" THEN SK
M2, 0, 0


... and the operator meant to hit the "Y" key but hit another one accidentally, the tool would start moving immediately.

Bill