Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to remove 1 segment from the "macro_path(0)"

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
ps
Contributor
465 Views, 5 Replies

How to remove 1 segment from the "macro_path(0)"

Hi

How do i remove the last part of a string if i dont no its lenght?

STRING mpt = macro_path(0) 

This prints D:\lokalt\1 folder\more projektes

If I want to remove all after the last \ so I get  D:\lokalt\1 folder

 

5 REPLIES 5
Message 2 of 6
rafael.sansao
in reply to: ps

STRING mpt = macro_path(0)
STRING LIST tk = tokens($mpt, '/')
$mpt = REPLACE($mpt, "/" + $tk[SIZE($tk)-1], "")

MESSAGE INFO $mpt

Rafael Sansão

EESignature

Message 3 of 6
LasseFred
in reply to: rafael.sansao

Take @rafael.sansao macro and edit / to \ and it works..

 

STRING mpt = macro_path(0)
STRING LIST tk = tokens($mpt, '\')
$mpt = REPLACE($mpt, "\" + $tk[SIZE($tk)-1], "")

MESSAGE INFO $mpt

 

______________________
Lasse F.
Message 4 of 6
rafael.sansao
in reply to: LasseFred

This depends on the language of the computer... / OR \

Rafael Sansão

EESignature

Message 5 of 6
richard.pedley
in reply to: ps

Hi PS,

 

The function dirname does this:

STRING $Test1 = macro_path(0)
$Test1 = dirname($Test1)

That should sort it for you.

 

Hope that helps

 

Richard



Richard Pedley
Research Engineer
Message 6 of 6
ps
Contributor
in reply to: richard.pedley

Thanks this works perfect Smiley Happy

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report