PDA

View Full Version : Formatted Print before max 9?


scorpion007
06-20-2007, 03:36 AM
Hi,

Is it possible to zero-pad an integer to a given width, I.e. "00005", before max 9's formattedPrint function? I am using that at the moment, but I really don't like to cut backward compatibilty so harshly so my tool only works on the very latest version...

The manual mentions it was previously available through some "Avguard DLX Extensions" library. Is this free? And where can it be attained for max < 9?

Or is there a similar way to achieve the same outcome?

Thanks

PiXeL_MoNKeY
06-20-2007, 04:18 AM
Use <string>substring <string> <from_integer> <length_integer>. See the following example:substring ((100000+5) as string) 2 5
"00005" The Avguard are free maxscript extensions from Larry Minton of Autodesk. They can be found at scriptspot.com (http://www.scriptspot.com/search/node/avg).

-Eric

rdg
06-20-2007, 07:27 AM
the substring approach looks really fast!

I used a function for this:


fn pad inp ln ch:"0" = (
inp = inp as string
while inp.count < ln do inp = ch + inp
inp
)

inp is the number you want to pad
ln is the length of the needed string
ch is an optional padding character


pad 4 4 -- outputs: "0004"
pad 4 4 ch:"x" -- outputs: "xxx4"

Georg

scorpion007
06-21-2007, 03:57 AM
Ah, nice :) Thanks guys, really useful stuff.

CGTalk Moderation
06-21-2007, 03:57 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.