Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Post edit to add comment


Recommended Posts

Good afternoon everyone. I am trying to edit our post, so that if a user says "yes" to a question it will output a certain comment. If they say "no" then it does nothing.

Below are the fields that i had done, but first off i was getting a error message each time i would post something, although it would still post out. The other problem was that it was putting in the comment whether they said yes or no. So i am not sure what i am doing wrong. I will post the different areas that i added stuff and what they were.

 

#questions

 

opStop_promp :" "

 

fq 8 opStop_promp "Is there an op stop yes, no"

 

This was all at the top of the post mainly where everything is declared, then down in the part where pheader$ is i had put this in

 

if opStop_promp = no, "(", "Op stop in use", ")", e$

 

i thought that would as if they typed "no" then do nothing but if they said yes put in the comment of op stop in use

with this way though it put in that comment no matter what they put in. also it would say errors while posting.

 

So i tried it a differnt way as below but still no go

 

if opStop_promp = no, e$

else, "(", "Op stop in use", ")", e$

 

 

Can anyone show me the error of my ways please. I was able to create a prompt that asked the user for a part name and then place that name they typed in, that works fine, but trying to do a "yes" "no" statment is giving me problems.

Link to comment
Share on other sites

In addition to changing your prompt return variable to a string variable, your boolean comparison can't just use the characters 'no' without making the comparison a string variable. You can certainly use 'no' if you make it a 'string literal'. To do that, encase the letters with double quote characters:

 

 if sopstop_promp = "no", e$
 else, "( Op stop in use)", e$

Link to comment
Share on other sites

Good catch, Colin. I missed that. But I did think of this:

 

Keep in mind that "no" is not the same as "No" is not the same as "NO". I would convert any input string to uppercase characters prior to comparing, and compare to "NO".

 


	 sopstop_promp = ucase (sopstop_promp)
	 if sopstop_promp = "NO", e$
	 else, "( Op stop in use)", e$

Link to comment
Share on other sites

That's also a good recommendation. You can combine the 'ucase' function in the boolean comparison line to save you some coding:

 

if ucase(sopstop_promp) = "NO", e$

 

The other thing this brings up is the use of 'if/else'. In this case, it looks like we don't want any output for the "NO" case, but the way the if/else is written, if the answer is "no", we end up with the potential to output a blank line (the e$).

 

The if condition could easily be set to detect "yes" instead of "no", and output the comment if "yes" is the answer. Since we wouldn't want a blank line output, we can just not add the 'else' case...

Link to comment
Share on other sites

Good catch, Colin. I missed that. But I did think of this:

 

Keep in mind that "no" is not the same as "No" is not the same as "NO". I would convert any input string to uppercase characters prior to comparing, and compare to "NO".

 


	 sopstop_promp = ucase (sopstop_promp)
	 if sopstop_promp = "NO", e$
	 else, "( Op stop in use)", e$

 

Instead of using a yes or no should i possibly just start the string out with

fq 8 sopstop_promp "Is there an op stop [1=no, 2=yes]

 

will that make it so if they put in 1 it would be no and so forth. Also do i need the " after the ] sign. In our other post for our woods it is written just as i have it with out the trailing "

Link to comment
Share on other sites

Ok well with your guys help i have got it to post out the comment when i put in "1" which is the yes and when i put in "2" which was the no it didnt. So it seems i am very close to wrapping this up, only thing i have now is when i post i get the msg box saying there was errors. I dont get this when i take out everything i just put in, so i am thinking something is amiss somewhere. I think it may be with what you just posted about the numeric variable init. Not real sure how to do that. Here is my code that i have so far

 
sopstop_promp   :""

fq 8  sopstop_promp  "Is there an op stop [yes=1 no=2]"
if sopstop_promp = "1", "(", "Op Stop in use", ")", e$

 

Like i said it is working, cause it outputs the comment op stop in use when i put in the 1, and it does not when i put in a 2......But im getting that dreaded error message box that i didnt get before.

Link to comment
Share on other sites

I will see if i can show you the line. May have to just post the whole part. Its not real long actully. I did change the sopstop_promp to opstop_promp tho.

 

<2> - Search for defined post variables, strings, postblocks was successful.
18 Jul 2013 02:30:04 PM - <2> - PST LINE (447) - The left side of the formula is the wrong type (var/string)
18 Jul 2013 02:30:04 PM - <2> - PST LINE (453) - The post question target variable/string is bad
18 Jul 2013 02:30:04 PM - <2> - PST LINE (2289) - The arguments for this operator/function are not the same type (var/string)[23]
18 Jul 2013 02:30:04 PM - <2> - PST LINE (447) - The math calculation/formula has an error
18 Jul 2013 02:30:04 PM - <2> - RUN TIME - PST(2289), NCI(98) - The math calculation/formula has an error
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (QUESTION) Enter Program Number - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (RESPONSE) 7788. - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (QUESTION) Enter Drawing Number - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (RESPONSE) 125125_0 - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (QUESTION) Enter Programmer Initials - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (RESPONSE) SC - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (QUESTION) Enter Part Name - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (RESPONSE) LEFT UPRIGHT - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (QUESTION) Is there an op stop [yes=1 no=2] - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (RESPONSE) 1. - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (QUESTION) Enter Setup note - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - RUN TIME (RESPONSE) USE SETUP 3 - OPERATION 1 NCI LINE 98.
18 Jul 2013 02:30:04 PM - <2> - Successful completion of posting process!

 

Those are the lines that showed an error, problem is they show pst line but in my cimco editor i dont have line numbers so not sure what is on the line its showing

 

EDIT: ok so after figuring out how to find by line it appears each one of those problems have to do with each of my statments.

 

opstop_promp :"" says something wrong here

 

fq 8 sopstop_promp "Is there an op stop [yes=1 no=2]"

if sopstop_promp = "1", "(", "Op Stop in use", ")", e$ and something wrong here

Edited by Gloves
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...