Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: mayhugh1 on December 18, 2009, 07:20:30 PM

Title: Is this a valid line of VB script?
Post by: mayhugh1 on December 18, 2009, 07:20:30 PM
I'm troubleshooting an OEM macro (that seems to work in version .029 but not in version .032) with little VB knowledge. It contains a line that I can't figure out:

"wait = GetOEMLED(11) = 0"

Is this line with two "=" symbols valid and if so can someone tell me what it is trying to do?

Thanks - Terry
Title: Re: Is this a valid line of VB script?
Post by: zealous on December 19, 2009, 12:40:36 AM
In VB "=" means this equals that

Code: [Select]
wait = 4
msgbox wait 'returns 4

or

Code: [Select]
this = true
that = true

if this = that then
msgbox "they are the same"
End If

You would have to provide more of the code to figure out what is meant to happen.

Spindle ON LED (CW or CCW) = GetOemLED(11)

Are you checking to see if the spindle is on and how long to wait for?

Code: [Select]
Wait = 1000
If GetOEMLED(11) = True Then
Sleep(wait)
End IF
Title: Re: Is this a valid line of VB script?
Post by: mayhugh1 on December 19, 2009, 04:26:41 AM
I'm still confused though about what the two equal signs on the same line are trying to do. It seems that a variable 'wait' is being assigned the boolean result of Get OEMLed(11), but what is the "=0" at the end doing? - Terry
Title: Re: Is this a valid line of VB script?
Post by: Hood on December 19, 2009, 04:37:29 AM
looks to me that its saying to wait if OEMLED 11  is equal to zero, ie off.

Hood
Title: Re: Is this a valid line of VB script?
Post by: HimyKabibble on December 19, 2009, 03:22:00 PM
I'm troubleshooting an OEM macro (that seems to work in version .029 but not in version .032) with little VB knowledge. It contains a line that I can't figure out:

"wait = GetOEMLED(11) = 0"

Is this line with two "=" symbols valid and if so can someone tell me what it is trying to do?

Thanks - Terry

It would be better written:  "wait = (GetOEMLED(11) = 0)".  It is valid, but perhaps poor coding practice.  GetOEMLED(11) = 0 will be evaluated as a boolean expression, returning TRUE if OEM LED 11 is Off (0).  So, wait will be set to TRUE (non-zero) if LED 11 is Off, and FALSE (zero) if LED 11 is on.

Regards,
Ray L.