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:

Sub error


Recommended Posts

Any one wanna take a guess at why I am getting this error?

 

RUN TIME -PST(2016)- 'subprg$' must be set to 1 (overwrite) or 2 (append) to open auxiliary file.

 

psubcall   # Sub Call

        force_wcs = one
        toolchng = one
        force_wcs = one
        toolchng = one
        while sreps < sub_out, pm98_call  # Output M98 Calls to Main
        subout$ = one
        subno_2 = subno
        *subno_2, e$   # Output program number for SUB --------------------------------------- Post line 2016
        scomm_str, no_spc$, "PN", snamenc$, scomm_end, e$
        scomm_str, no_spc$, "SUB PROGRAM", *subno_2, scomm_end, e$
        scomm_str, no_spc$, *strtool$, scomm_end, e$
        if scomm_sav <> snull,
        [
        scomm_str, no_spc$, *scomm_sav, scomm_end, e$
        scomm_sav = snull
        ]

 

I never explisitly change the subprg$ and subout$ never gets past one. The program its self looks fine. Just throws this warning every time I try to sub.

 

I'm stumped. :question:

  • Like 1
Link to comment
Share on other sites

You have to "tell" MP that the subprogram file "exists".

 

Changing the 'subout$' variable to '1', switches the "output stream" to the Sub file, but you first must initialize the subprogram file. The reason is that MP has two "modes" of writing to the subroutine file, and it wants you to choose which mode to use.

 

Setting 'subprg$' to '1' tells MP to create a new subprogram file. If one exists, it is overwritten. If no file exists, then one is created. Setting 'subprg$' to '2' tells MP to "append" the new stream data to the end of the existing file (or create a new one, if no file exists.)

 

So that is why you are getting the error. Note that you can simply set "subprg$ = 1" as a post line, as long as you use the line before you start writing any new characters to the sub file.



psubcall   # Sub Call

        force_wcs = one
        toolchng = one
        force_wcs = one
        toolchng = one
        while sreps < sub_out, pm98_call  # Output M98 Calls to Main
        subout$ = one
        subno_2 = subno

        subprg$ = one #Initialize sub file

        *subno_2, e$   # Output program number for SUB --------------------------------------- Post line 2016
        scomm_str, no_spc$, "PN", snamenc$, scomm_end, e$
        scomm_str, no_spc$, "SUB PROGRAM", *subno_2, scomm_end, e$
        scomm_str, no_spc$, *strtool$, scomm_end, e$
        if scomm_sav <> snull,
        [
        scomm_str, no_spc$, *scomm_sav, scomm_end, e$
        scomm_sav = snull
        ]

Hope that helps...

  • Like 1
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...