Problem with custom M code

More
1 year 8 months ago #322100 by Leo90
Hi all. I need help with my custom M code I've started to write. I ran into a problem right at the beginning with an "if" statement. My M code should be M105 P100 and it seems the "P" value isn't transfered into the M code. 
​​​
Code:
#!/bin/bash operand="$1" if [[ "$operand" == 100 ]]; then     halcmd setp lcec.0.EL2008.dout-0 true     echo "ok" else     halcmd setp lcec.0.EL2008.dout-1 true     exit 1 fi exit 0
The M code always outputs "else" condition so "operand" isn't 100 as expected. 

I also wrote a similar M code with "case" and there the P value is recognised by bash. 

What did I do wrong here?

Please Log in to join the conversation.

More
1 year 8 months ago #322104 by Aciera
Replied by Aciera on topic Problem with custom M code
Problem is that $1 contains a float which bash can't handle, so try:
Code:
if [[ ${operand%\.*} -eq 100 ]]; then

Please Log in to join the conversation.

More
1 year 8 months ago #322243 by Leo90
Replied by Leo90 on topic Problem with custom M code
@Aciera thank you very much. It worked flawlessly. I knew I can count on you guys :)

Please Log in to join the conversation.

Time to create page: 0.078 seconds
Powered by Kunena Forum