Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: donjordan on May 08, 2020, 03:24:56 AM

Title: Getting familiar with macros and cant get isMoving() to return right value
Post by: donjordan on May 08, 2020, 03:24:56 AM
Im diving into macros in Mach3 and trying to figure out why, when I run a program just to read the state of isMoving(), it returns the wrong value. Am I missing something here? I've got the documentation open but can't find anything in there that would indicate why its reporting the wrong value.

Code: [Select]
state = isMoving()
Message "Machine Moving = " & state

This values returns a 1, even though the machine is not moving (expecting a 0).

Title: Re: Getting familiar with macros and cant get isMoving() to return right value
Post by: TPS on May 08, 2020, 03:34:35 AM
just tested here in the VB Scripter window. working here.
Title: Re: Getting familiar with macros and cant get isMoving() to return right value
Post by: donjordan on May 08, 2020, 03:51:49 AM
Thank you for your response. When I put the code in the VB Scripter window I also get the expected 0. However when I load the code in a separate file (M801.M1S) and run M801 through the MDI input, it returns a 1. It is interpreting those two methods differently, not sure why.. or maybe im not loading it properly through MDI?
Title: Re: Getting familiar with macros and cant get isMoving() to return right value
Post by: Graham Waterworth on May 08, 2020, 12:26:15 PM
You would normally have it in a while loop, mach3 only updates ever 50ms to 100ms or in some cases a short sleep(50) after the call helps.

While isMoving()
Sleep(10)
Wend

or

state = isMoving()
Sleep(50)