strfind2double

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Text/Strs/Chars/Links
Introduced first in SolidGeometry 5.0, Creation date: 2020-12-26, Last change: 2025-09-15

searches for pattern in char string and returns the next value as double real

Description

used for gcode analysis

See Also:

Example Illustration

 missing image of strfind2double(TEXT,codenr)

Syntax

cr=strfind2double(TEXT,codenr)

Input Parameter

TEXT: ASCII TEXT string
codenr: char patter to be matched

Output Parameter

cr: real number als double of the next chars up to space or newline

Examples


strfind2double('a s d f ert fvsf x200, y300','x')




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, strfind2double, is designed to search for a specific character pattern within a given ASCII text string and return the subsequent numeric value as a double. It is particularly useful for analyzing G-code.

Input Parameters

Output

Algorithm Steps

  1. Determine the length of the codenr pattern using strlength.
  2. Find all occurrences of codenr in TEXT using strfind.
  3. Identify positions of spaces and newlines in TEXT and sort these positions.
  4. Initialize the output array cr with NaN values, with a size equal to the number of occurrences of codenr.
  5. Iterate over each occurrence of codenr (up to a maximum of 1000 iterations):

Example

For the input strfind2double('a s d f ert fvsf x200, y300','x'), the function will search for 'x' in the string and return 200 as a double.

Algorithm explaination created using ChatGPT on 2025-08-19 00:20. (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