Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 12:00:37 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  inputs and outputs not boolean why? help!!!!
Pages: 1   Go Down
Print
Author Topic: inputs and outputs not boolean why? help!!!!  (Read 403 times)
0 Members and 2 Guests are viewing this topic.
jorber
Active Member

Offline Offline

Posts: 7


View Profile
« on: September 28, 2010, 05: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? Huh
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 2,616



View Profile WWW
« Reply #1 on: September 28, 2010, 06:58:58 PM »

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.
Quote
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.
Logged

DaveCVI
V4 Screen Contributor

Offline Offline

Posts: 532



View Profile WWW
« Reply #2 on: September 28, 2010, 07:47:49 PM »

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:

Code:
‘ 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
Logged

Author of the MachStdMill Extensions for Mach3
www.CalypsoVentures.com
jorber
Active Member

Offline Offline

Posts: 7


View Profile
« Reply #3 on: September 29, 2010, 01:16:53 PM »

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  Sad
Logged
DaveCVI
V4 Screen Contributor

Offline Offline

Posts: 532



View Profile WWW
« Reply #4 on: September 29, 2010, 09:55:35 PM »

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


Logged

Author of the MachStdMill Extensions for Mach3
www.CalypsoVentures.com
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!