Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: jorber on September 28, 2010, 06:08:47 PM
-
I am trying to make this script:
‘ Show the user the state of the Y HOME input
If IsActive(YHOME) Then
MsgBox “Y HOME is active”
Else
MsgBox “Y HOME is inactive”
End If
But when I debugg it and I put the mouse over YHOME to see its value shows YHOME = "5" no matter if is active or inactive always the same then acts as always false the statement.
what wolbe happening here? ???
-
5 is the signal number for YHOME.
IsActive(YHOME) is the same as IsActive(5).
http://www.machsupport.com/MachCustomizeWiki/index.php?title=VB_Constants_for_Signal_Names
Here's what the manual says.This function returns a Boolean True if the current state of the specified input signal is its
active state. Note that in terms of actual signal level, the term “active” depends on how
the signal is defined. If the signal is defined in Config->Ports&Pins->InputSignals as
ActiveLow, then IsActive() will return True when that signal is being driven to a logic
low. If the signal is defined in Config->Ports&Pins->InputSignals as ActiveHigh, then
IsActive() will return True when that signal is being driven to a logic high.
-
As Ger21 said, what you are seeing is a side effect of the the slightly odd way the cypress basic script editor displays values.
This "editor feature" often leads me to write things differently - try this:
‘ Show the user the state of the Y HOME input
Dim B as Boolean
B = IsActive(YHOME)
If B Then
MsgBox “Y HOME is active”
Else
MsgBox “Y HOME is inactive”
End If
Yeah, I know that the above is not considered "good programming style"... but you can hover the cursor over the B variable and see if it is true or false... you get to choose between style and being able able to see the variable value while debugging.
Dave
-
thanks,
I did this as you said, now when I hover the mouse show always "false" I change the state but still never is "true"
the input in the diagnostics screen show me that the input is working :(
-
Uh, something about the phrasing you used made me think I should ask ...
The B variable gets set to a value when the line B = IsActive(YHome) gets executed.
You are coordinating when the signal changes vs when the code is executed as part of your debugging - right?
For example:
1) use the editor to step thru the code - you will get a value for the input from IsActive stored in B.
(we'll assume the value is true at this point)
2) change the state of the physical input
3) restart and rerun the code again - when stepping thru it this time you should then get the opposite value for B (since it was true, it would now be false).
I mean no offense by my question; I've just found that some mach users think that scripts are constantly being executed and expect the values to change while looking at things in the editor.
Dave