586,075 active members*
3,937 visitors online*
Register for free
Login
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2011
    Posts
    21

    Help with Tricky VB script

    Have 2 vb script questions.

    1. Need to have a VB script (fired off by a wizard button)
    run an executable program outside of Mach3. Basically,
    I have a program.exe that I want to start.

    Since it is NOT a gcode program, most of the functions
    are not appropriate. I also tried Tricking PLAYWAVE into
    running it, but I can't get PLAYWAVE to even play a .wav file.

    2. I need to have a VB script READ in data from a file to fill out
    OEMDRO values for display purposes ONLY. Basically
    the opposite of CODE.

    Thanks,

    Gort

  2. #2
    Join Date
    Feb 2011
    Posts
    21
    Can't figure out #1

    Found an UGLY solution to #2
    Use a .m1s file in the /Mach3 directory.
    My C++ program writes to data_out.m1s, lines such as:

    ModuleDRO = 1020
    SetUserDRO(ModuleDRO, 1.234)

    Then, the VB button script has the following lines:

    If RunScript(“data_out”) < 0 then
    Msgbox “data_out returned an error”
    Else
    REM Msgbox “Script ran”
    End If

    Result is it takes data from the Data_out file, and
    the DRO #1020 displays the data, in this case displays 1.234

    Ugly, but works,

    GORT

  3. #3
    Join Date
    Mar 2003
    Posts
    35538
    Try asking on the Machsupport.com forum.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  4. #4
    Join Date
    Jun 2008
    Posts
    128
    This is the code I use to execute an EXE file "Pcb_Leveller.exe"
    I pass it the text file from a leveler program I run first

    Start of Code:

    Option Explicit
    Dim fName As String
    Dim pgmName As String
    Dim loadPgm As String


    fName = GetLoadedGCodeDir() + GetLoadedGCodeFileName()
    SetUserLabel(100,fName)
    pgmName = "C:\Mach3\Pcb_Leveller.exe " +fName
    Shell(pgmName )

    SetUserLabel(101,"Save digi as " + fName + "_digi.txt")

    End of Code

    If you do not need to pass info to the exe you just need

    Option Explicit
    Dim pgmName As String
    pgmName = "C:\Mach3\Pcb_Leveller.exe "
    Shell(pgmName )

    George

  5. #5
    Join Date
    Feb 2011
    Posts
    21
    GREAT !!!!! THANKS !!!!!!
    I used the bottom run only part, as I was already writing my input
    data to a text file.

    One question. The 4 lines at bottom run fine as a stand alone script
    but...When I put them in middle of my existing vb script, I have to take
    out the OPTION EXPLICIT line or it errors. Works fine with that line out.
    ?????

    THANKS SO MUCH, I wasted days searching for this solution.

    GORT

  6. #6
    Join Date
    Jun 2008
    Posts
    128
    I always use Option Explicit as it forces dim all variables and this can show up bugs caused by using wrong name for a variable.

    Re #2
    I don't use it but the code below should work depending on format of your data:

    Open "TESTFILE" For Input As #1 ' Open file.
    Do While Not EOF(1) ' Loop until end of file.
    Line Input #1, TextLine ' Read line into variable.
    Print TextLine ' Print to Debug window.
    Loop
    Close #1 ' Close file.

    George

Similar Threads

  1. i Script Design
    By jeroend in forum OpenSource Software
    Replies: 1
    Last Post: 11-04-2010, 02:38 PM
  2. tricky tooling question for you sinker EDM gurus
    By hkfanatic in forum EDM Discussion General Topics
    Replies: 19
    Last Post: 12-15-2008, 08:38 PM
  3. VB6,VB.net,VB script,What one???
    By hydrospin01 in forum Visual Basic
    Replies: 11
    Last Post: 05-25-2008, 02:09 AM
  4. Lookahead script
    By Rikard L in forum Visual Basic
    Replies: 2
    Last Post: 09-11-2007, 07:28 PM
  5. Backup Script..
    By Rekd in forum Mastercam
    Replies: 3
    Last Post: 09-11-2003, 03:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •