Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Another VB question


Recommended Posts

Hello all. I wrote a script based on some examples to read a text file. It uses common Windows Script Host functions. I worked with it in Notepad and ran it through cscript.exe in command prompt. However, when I run it with the Mastercam X Editor it doesn't recognize the WSH functions I used. I've included it on the FTP site called "Read_Text_File.vbs" and can include the text file it reads if you want to test it. I don't quite understand why the Mastercam editor doesn't recognize the WSH commands, when I have WSH 5.6 installed on my machine. Any ideas?

 

Thanks.

Link to comment
Share on other sites

arenner,

 

You can not use "WScript.Echo" in a Mastercam VBScript, instead use "ShowString()" to echo information back to the screen.

 

FYI, I noticed that all of the variables you are using are not declared, you need to declare all variables or Mastercam will raise an error when you try to execute the script.

Link to comment
Share on other sites

Thanks Mick. I realize that I usually declare variables as you mentioned. But my main question, is why the Windows Script Host commands don't work with the Mastercam Editor. If this isn't available to open a text file, is there another way without relying on Windows Script Host functions like:

 

CreateObject("Scripting.FileSystemObject")

 

Thanks again for chiming in. I appreciate the help.

Link to comment
Share on other sites

Hey, I forgot to mention: I was only using WScript.Echo to make sure that my arrays were setup correctly, and that my code was error free. What I plan on doing is using the stored arrays for use with the other neat functions like CreateArc, etc... I have data outputs in text files that I'm attempting to read.

 

Hope that makes it more clear, thanks.

Link to comment
Share on other sites

Hey Mick. I appreciate the help. I was able to figure out what I needed to add to get the Windows Script Host functions to work.

 

I took a second to create a commented example based on the script I created for my work. It creates an arc from the example text file I also uploaded to the FTP site. They're both named:

 

"CreateArc_FromTextFile"

 

I hope it will be of use to forum members. Without much trouble it can be edited for other text files, and create other geometries.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...