Sub programs?

Post Reply
pfunk
Frequent User
Frequent User
Posts: 45
Joined: Tue Aug 30, 2011 2:11 pm

Sub programs?

Post by pfunk » Tue Aug 30, 2011 5:13 pm

Is there a way to run a program from inside another program?

We have two CMMs and would like to have ONE part program to use for both. In WinCMES we made a $FRONT command that would bring the probe front and center. $Front would be different on each machine because they are different sizes. This would be called at the beginning of the program to get ready for manual touches.

I would like to do the same tihing in Manager. That way, if we edited the program, we would not have to remember to change the 'front and center" section and save a different copy.

I looked through the user manual from the ftp, but didn't see anything.

Thanks,
Paul

User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Re: Sub programs?

Post by US_Helpdesk » Thu Sep 01, 2011 3:29 pm

Paul

This can be done quite easily using VB Script. Below is an example of how you could do this, you could get more advanced and perform some data verification to check if the user actually entered an integer value of 1 or 2 or maybe use a drop down list instead. Google VB6 for more info on VB Scripting with CMM-Manager.

001 Program settings
002 Probe Assy 1
003 Get Tip (A0,B0)
004 VB Script

Code: Select all

myCMM = InputBox("Please select CMM, enter 1 or 2")
Select Case myCMM
Case 1
005 Add Move $$This is the move point for CMM 1
006 VB Script

Code: Select all

Case 2
007 Add Move $$This is the move point for CMM 2
008 VB Script

Code: Select all

End Select
009 ...
010 ...
... rest of program
I've migrated to a new user account, see my other posts here

pfunk
Frequent User
Frequent User
Posts: 45
Joined: Tue Aug 30, 2011 2:11 pm

Re: Sub programs?

Post by pfunk » Mon Sep 12, 2011 10:57 pm

What I was looking for is to have an external definition of the front position. The method you describe would still have hard-coded numbers in the program.

Originally I was thinking of a stand-alone Manager program that could be called from inside the part program. If this is not possible, would it be possible to read a FRONT.TXT file (or something) that just has the X, Y, and Z numbers listed? Then the part program would read three numbers and move to the defined position from these loaded numbers. This way the text file could change from CMM to CMM without having to edit the part program.

I hope I described this better.

Thank you for your time,
Paul

User avatar
US_Helpdesk
Moderator
Moderator
Posts: 1092
Joined: Wed Feb 23, 2011 7:26 pm

Re: Sub programs?

Post by US_Helpdesk » Tue Mar 27, 2012 11:39 am

I'm sorry for the delay on this response...

You can read variables into CMM-Manager by reading a text file. Below is an example of reading a file and saving each line to a variable array.

Code: Select all

Dim myArray(100)                                           ' Define Array
Dim i As Integer                                              ' Define index for loop
i = 0
Open "c:\sample.txt" For Input As #1                 ' Open File
    Do While Not EOF(1)		                           ' Loop until end of file.
        i = i +1
        TotalLines = i                                         ' Count total number of lines in file
	Line Input #1, TextLine	                           ' Read line into variable.
        myArray(i) = TextLine                              ' Save each TextLine into Array  
    Loop
    Close #1	' Close file.
You can then retrieve the Array values as such

Code: Select all

For i = 1 to TotalLines                                    ' For each line in file
   myVar = myArray(i)                                    ' Read variable from Array
Next
The myVar value could be used in CMM-Manager to define the nominal values of features, path data, reports, etc. Anytime you see a button called Set Variables you can pull a variable froma VB script into the CMM-Manager Program.
I've migrated to a new user account, see my other posts here

Post Reply