num2strCNT

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Text/Strs/Chars/Links
Introduced first in SolidGeometry 5.2, Creation date: 2022-04-10, Last change: 2025-09-15

creates numberstring including addition zeros

Description

used for automatic frame name creation

See Also: num2strUP

Example Illustration

 missing image of num2strCNT(i,n,txt)

Syntax

num2strCNT(i,[n,txt])

Input Parameter

i: index
n: maximal number of indices
txt: optional leading string

Examples


num2strCNT(2,12); % if counter runs from 1 to 12
num2strCNT(2,12,'F'); % if counter runs from 1 to 12 with leading 'F"
num2strCNT(1,4999); % if counter runs to 4999




Copyright 2022-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, num2strCNT, is designed to create a formatted string representation of a number with leading zeros, often used for automatic frame name creation. It is part of the SolidGeometry library.

Input Parameters

Algorithm Steps

  1. The function getfuncparams is used to retrieve the value of n from the input arguments. If n is not provided, it defaults to the value of i.
  2. Calculate the number of digits required for the largest number, n, using the formula nn = floor(log10(n) + 1). This determines how many leading zeros are needed.
  3. Retrieve the optional leading string txt using getfuncparams. If not provided, it defaults to an empty string.
  4. Create a format string fstr using sprintf to specify the format for the output string. The format string includes the leading string, leading zeros, and the number itself.
  5. Generate the final formatted string nstr using sprintf with the format string fstr, the leading string txt, and the index i.

Example Usage

Algorithm explaination created using ChatGPT on 2025-08-18 23:12. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21