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
- TEXT: An ASCII text string where the search will be conducted.
- codenr: A character pattern that the function will search for within the TEXT.
Output
- cr: A real number in double format representing the numeric value found immediately after the specified pattern, up to a space or newline.
Algorithm Steps
- Determine the length of the
codenr
pattern using strlength
.
- Find all occurrences of
codenr
in TEXT
using strfind
.
- Identify positions of spaces and newlines in
TEXT
and sort these positions.
- Initialize the output array
cr
with NaN values, with a size equal to the number of occurrences of codenr
.
- Iterate over each occurrence of
codenr
(up to a maximum of 1000 iterations):
- Use
showprogress
to display the current progress of the loop.
- Find the next space or newline after the current occurrence of
codenr
.
- Extract the substring from the end of
codenr
to the next space or newline.
- Convert this substring to a double using
str2double
and store it in the cr
array.
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