Syntax
outstr=cell2strlines(tab,[nl,sing])
Input Parameter
tab : | | cell list of string |
nl : | | number of elements per line; default is 10000 |
sing : | | separate string by separation char such as """ or '' |
Output Parameter
Examples
cell2strlines({'A','B','C'})
cell2strlines({'A','B','C'},6)
cell2strlines({'A','B','C'},6,true)
cell2strlines({'A','B','C'},6,'"')
Copyright 2020-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, cell2strlines
, converts a cell list of strings into a single string line. It is part of the SolidGeometry library and was introduced in version 5.0.
Input Parameters
- tab: A cell list of strings that need to be converted.
- nl: The number of elements per line. The default value is 10000.
- sing: A flag or character for separating strings. It can be a boolean or a character like
"
or '
.
Output
- outstr: The resulting concatenated string.
Algorithm Steps
- Initialize
nl
and sing
using getfuncparams
to handle optional parameters.
- Initialize
cl
(current line length) to 0 and n
to the number of elements in tab
.
- Initialize
outstr
as an empty string.
- Iterate over each element in
tab
:
- Check if the element is a character string.
- Calculate the length of the current string
ci
, adding 2 for quotes. If sing
is true, add 2 more.
- Check if adding the current string exceeds
nl
. If so, start a new line.
- Assign the current string to
si
.
- If
sing
is true, format the string with quotes or the specified character.
- If
sing
is false, append the string with a comma.
- After the loop, adjust
outstr
to remove the initial comma or trailing comma based on sing
.
Example Usage
cell2strlines({'A','B','C'})
cell2strlines({'A','B','C'},6)
cell2strlines({'A','B','C'},6,true)
cell2strlines({'A','B','C'},6,'"')
Algorithm explaination created using ChatGPT on 2025-08-19 07:58. (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