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:

Create and run VBS in PST


Recommended Posts

THe idea is to have the post write the vbs file, save it, and then run it. I'm working in X7 and have seperated the process into a build postblock and a call postblock.When I run the build by itself it creates the file fine. but the call does not recognize the file as exhisting. If I have the vbs file already created and do not run the build postblock, it runs the vbs correctly. I think it has something to do with the closing of the file in the build. Any help would be very appreciated!

 

 

pvbsbuild1

sextaux$ ="vbs"

spathaux$=spathpst$

snameaux$="DXFSCRIPT"

subout$ = 2

auxprg$ = 1

s_vbscript=spathaux$+snameaux$+"."+sextaux$

 

"Call Main()",e$

"Sub Main()",e$

"writeDXF(",no_spc$,s_quote,no_spc$,spathpst$,no_spc$,"Label.DXF",no_spc$,s_quote,no_spc$,")",e$

"If Not askValue (",no_spc$,s_quote,no_spc$,"Please input a diameter",no_spc$,s_quote,no_spc$, ", 0 , 1000, dblDiameter) Then",e$

"Exit Sub", e$

"End If", e$

"End Sub", e$

auxprg$ = 0

subout$ = 0

result = fclose(s_vbscript)

 

 

pvbscall1

sextaux$ ="vbs"

spathaux$=spathpst$

snameaux$="DXFSCRIPT"

s_vbscript=spathaux$+snameaux$+"."+sextaux$

if fexist(s_vbscript),result = runvbs(s_vbscript)

Link to comment
Share on other sites

Try moving the 'auxprg$ = 1' line before setting 'subout$ = 2'. You need to initialize the AUX file before attempting to switch the output stream.

 

Also, try testing the return value from 'fclose' in your 'pvbsbuild1' post block. You could just add the following:

 

~result, e$

 

That will output the value of result and tell you if it was successful in closing the file.

Link to comment
Share on other sites

Alright, I moved "augprg$=1" before "subout$=2" and added the *result,e$ so it would output. When I post, it does the same thing and the nc file shows that result = 0, which shows it has closed but it still doesn't run as a vbscript. I ran it through the debug and placed a breakpoint at the beginning of the call postblock. When the post execution stopped, I checked the file in the windows enviroment and it stated that mastercam was still using the file when I tried to delete it. This tells me that it is not truely closing the file. Is there another way to force it to close the file?

Link to comment
Share on other sites

I tried the clearaux$ and it deleted everything in the file. This got me wondering, I changed the build postblock so it would call a new aux after closing this one. Long story short, all the info that is suppost to go to the new one is going to this one. So it is definitely not closing the file even though it says it is.

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...