- Posts: 5
- Thank you received: 0
Problem with custom M code
1 year 8 months ago #322100
by Leo90
Problem with custom M code was created 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.
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?
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
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.
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.
Time to create page: 0.078 seconds
