Hello Guest it is March 28, 2024, 07:54:49 AM

Author Topic: Msgbox function...  (Read 11119 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #20 on: January 29, 2016, 02:38:21 PM »
Ok, must be missing something.
I put this in M6start.m1s

CurrentTool = SelectedTool

IF CurrentTool = 1 then
   SetVar(1000,GetToolParam(1,1))
   Message("" & GetToolDesc(1)) &"  Offset> " & GetToolParam(1,1)
end if

Changed my IHS to use var 1000.

I have 1 tool in my table T1

Stick M6 T1 in the MDI and nothing happens, should i see some feedback??

I dont understand the If CurrentTool = 1 line, what if current tool =2 ??

This is not on the machine CNC, I have a test setup of Mach without the port drive installed on my laptop.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #21 on: January 29, 2016, 03:01:13 PM »
Ok, moved on an inch...

Google told me I needed to go Config > General and turn on auto tool change, did that.

Try M6 T1 and get scripter/compile error in the msg line??

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #22 on: January 29, 2016, 03:15:41 PM »
Another half an inch...

Seems i need Config > General "Stop Spindle, Wait for Cycle Start"

That got rid of the scripter/complie error but now all i get is a "change tool,press cycle start" message in the msg line, its not triggering the Message instruction in the M6start macro???

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #23 on: January 29, 2016, 03:34:05 PM »
You want auto tool change selected.  The error measage you got was to tell you the script had a problem when it ran, The Script in this case is M6start.

In this CASE I am BAD as I cannot read my own notes (;-)

Try this script

SetCurrentTool(GetSelectedTool())

If GetCurrentTool = 1 Then
   SetVar(1000,GetToolParam(1,1))
   Message"" & GetToolDesc(1) & "  Offset> " & GetToolParam(1,1)
End If  



The tool#1 code is just one example of 1 tool. If you have 6 tools then you add in teh script for all 6 tools

« Last Edit: January 29, 2016, 03:38:04 PM by BR549 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #24 on: January 29, 2016, 03:50:32 PM »
I would also add in some error checking of teh values to ensure they were usable and if not cancell the program . I would also go back to use your original #var as it was cross linked to the DRO and would SHOW teh offset value each time it changed.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #25 on: January 29, 2016, 03:53:23 PM »
Ok so i now have

SetCurrentTool(GetSelectedTool())

msgbox(CurrentTool)

If CurrentTool <> 1 Then
   SetVar(1000,GetToolParam(1,2))
   Msgbox"" & GetToolDesc(1) & "  Offset = " & GetToolParam(1,2)
End If  

If CurrentTool <> 2 Then
   SetVar(1000,GetToolParam(2,2))
   Msgbox"" & GetToolDesc(2) & "  Offset = " & GetToolParam(2,2)
End If  

The code is not setting CurrentTool, I added the msgbox on line 2 so i could verify this and it shows a blank message, the reason i checked it was because when the macro runs it shows two messages sequentially - tool 1 then tool 2 regardless of tool chosen in the M6 line

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #26 on: January 29, 2016, 04:05:29 PM »
SetCurrentTool(GetSelectedTool())


If GetCurrentTool = 1 Then
   SetVar(1000,GetToolParam(1,2))
   Msgbox"" & GetToolDesc(1) & "  Offset = " & GetToolParam(1,2)
End If 

If GetCurrentTool = 2 Then
   SetVar(1000,GetToolParam(2,1))
   Msgbox"" & GetToolDesc(2) & "  Offset = " & GetToolParam(2,2)
End If   

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #27 on: January 29, 2016, 04:08:30 PM »
Put that in teh M6start macro. Then call teh M6t1 from teh MDI and the Message will show up in teh Message bar when it runs.

The reason it ran both message before because the logic was wrong. It would see everything as <> so it did both tool#s

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #28 on: January 29, 2016, 04:11:36 PM »
Briiliant, I just about got there at the same time by plastering it with message boxes and changing code etc to see what results i got.

Its getting there.

I went back to original var 1045 but it does not update the DRO, do i need to add some SetOEMDRO commands in there???

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #29 on: January 29, 2016, 04:17:51 PM »
 I thought you had used a #var that was linked to a  DRO ?