cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Nader Belal
Mentor

Format numbers with leading zeros ?

Hi everyone,

Here is a simple question, how to convert integer numbers to strings with leading zeros using str or str{2} functions ?

ex:
1 to be show as 01 or 001
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
1 Solution

Accepted Solutions
Laszlo Nagy
Community Admin
Community Admin
After you converted it, you should inquire the length of the string (which will be 1, 2, or 3), and depending on that value, fill the beginning of the string with leading "0" characters.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac29

Go to post

3 Replies 3
Karl Ottenstein
Moderator Emeritus
If the format string for the STR function was like normal programming languages, this would be easy, but alas it is 'unique' and seems to have no way of producing leading zeros.
Vote for Wish: Copy/Paste in 3D

AC 29 USA and earlier   •   hardware key   •   macOS Taho 26.1 MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Laszlo Nagy
Community Admin
Community Admin
After you converted it, you should inquire the length of the string (which will be 1, 2, or 3), and depending on that value, fill the beginning of the string with leading "0" characters.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac29
Nader Belal
Mentor
Thank you all
A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!