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:

post question


Jeff2005
 Share

Recommended Posts

Jeff,

E-mail me the post you're using and I'll annotate the modificaton for you. I'd tell you how I change it on here, but I have only seen it done so I'll have to play. Basically you have to modify the format statements to give new variables and then write in a subroutine to calculate the conversion.

 

[email protected]

I can probably make the change quickly for you.

 

Thanks

Link to comment
Share on other sites

Time in AM-PM format.doc

 

If you wish to output the TIME that an NC file was generated in AM/PM format

(instead of the default 24-hour time format). You can use this method.

First, you must define the format statements for properly format the variables used in the ptime postblock 

code:

#============================================================

# Define the 'formats' to be used for the variables used 'ptime' postblock

# Proper formatting is IMPORTANT for this to work!

#============================================================

# These formats used only for 'Date' & 'Time'

fs2 25 2.2 2.2lt #Decimal, force two leading & two trailing (time2)

fs2 26 2 0 2 0t #Integer, force trailing (hour)

fs2 27 0 2 0 2lt #Integer, force leading & trailing (min)

#============================================================

# Now assign the 'format' to the variables used in 'ptime' postblock

#============================================================

# -------------------- Date & Time Formatting ------------------------------

fmt 25 time2 # Capture 24-hour time value into 'time2' variable

fmt 26 hour # Hour

fmt 27 min # Minutes

# Un-comment the 'fmt' for 'day' and/or 'month' if you only want 1-digit format

#fmt 26 day # Day (2 digit format)

#fmt 26 month # Month (2 digit format)

#============================================================

# This postblock will create AM/PM time stamp, like -> 8:15 AM

#============================================================

ptime #Turn 24-hour time format into AM/PM format

!spaces # Save current 'spaces' setting

spaces = zero # Turn OFF any extra spacing

if time >= 13, time2 = (time - 12)

else, time2 = time

hour = int(time2)

min = frac(time2)

*hour, ":", *min,

if time > 12, " PM"

else, " AM"

spaces = prv_spaces # Restore previous 'spaces' setting

#============================================================

# Then from somewhere like the 'pheader' (or 'psof') postblock, call 'ptime' ->

#============================================================

pheader

# This generates a comment block like -> ( CREATED ON 06-17-03 AT 8:15 AM )

" ( CREATED ON ", *month, "-", *day, "-", *year, " AT ", ptime, " )", e

# Note that if your 'spaces' setting is > 0,

# you will get additional spaces in this comment 

( CREATED ON 06 -17 -03 AT 8:16 AM )

# You can eliminate those using the same logic as in the 'ptime' postblock...

pheader

# This generates a comment block like -> ( CREATED ON 06-17-03 AT 8:15 AM )

!spaces # Save current 'spaces' setting

spaces = zero # Turn OFF any extra spacing

" ( CREATED ON ", *month, "-", *day, "-", *year, " AT ", ptime, " )", e

spaces = prv_spaces # Restore previous 'spaces' setting

Link to comment
Share on other sites

Jeff, Here are the changes I made.

 

First, I added these lines to the format statements.

 

# These formats used only for 'Date' & 'Time'

fs2 25 2.2 2.2lt #Decimal, force two leading & two trailing (time2)

fs2 26 2 0 2 0t #Integer, force trailing (hour)

fs2 27 0 2 0 2lt #Integer, force leading & trailing (min)

 

Then, I added these variable formats to the FMT statement list, commenting the date modifier

leaving the hour conversion operational:

 

# -------------------- Date & Time Formatting ------------------------------

fmt 25 time2 # Capture 24-hour time value into 'time2' variable

fmt 26 hour # Hour

fmt 27 min # Minutes

# Uncomment the 'fmt' for 'day' and/or 'month' if you only want 1-digit format

#fmt 26 day # Day (2 digit format)

#fmt 26 month # Month (2 digit format)

 

Finally, I changed the line in the post outputting the variable "time" to run a subroutine

instead called "ptime" which you could copy and paste below the subroutine that prints the

comment lines at the beginning of the NC file. When the post hits the line calling this

subroutine, it jumps down, runs this sub and prints the new time plus am or pm:

 

ptime #Turn 24-hour time format into AM/PM format

!spaces

spaces = zero

if time >= 13, time2 = (time - 12)

else, time2 = time

hour = int(time2)

min = frac(time2)

*hour, ":", *min,

if time > 12, " PM"

else, " AM"

spaces = prv_spaces

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