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:

Trimming Leading And Trailing Spaces From A String


Recommended Posts

I've tried and tried to figure out how to go about this but am banging my head against a wall. I'm trying to strip any empty spaces from the beginning and ending of a string. Does anyone have any pointers here? I've looked at strstr, scan, and brksps. I've got the strstr working as far as telling me if the string contains a space but I was wondering if there is a way of doing a substring function on a loop possibly? Any help would be greatly appreciated. Thanks.

 

Link to comment
Share on other sites

What string are you working with? Is this for something like outputting Comment Strings?

 

The reason I ask is because MP will automatically output a space character between the open and close parenthesis characters, and the string being output. This 'auto space output' behavior is controlled by the value of the 'spaces$' variable. You might try this before the string:

 

spaces$ = zero

.

.

Pbld, n$, sopen_prn, swhatever, sclose_prn, e$

.

.

spaces$ = one

Link to comment
Share on other sites

I am modifying the spaces$ variable when modifying comments like this:

sav_spc = spaces$
spaces$ = 0

#Do some some stuff here

spaces$ = sav_spc

But the reason I'm doing this is that the company I work at has a LARGE custom tooling

library and a lot of the tool descriptions have been entered incorrectly and have anywhere

from 1 to 5 empty spaces before and after the actual description. Causing the tool comments

and the tool header coming out looking all wonky. I know it's just fluff stuff, but the operators

on the shop floor complain to no end about it, asking us to take them out and pretty them up.

So I'm getting real tired of having to modify comments every time I post something. The only

way I have found to get around this is to modify the description on every new toolpath I create,

but I would like to be able to post and go. And nobody has the kind of time to go into the tool

databases and modify every tool in those databases.

Link to comment
Share on other sites
  • 7 years later...

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