cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Gabor Szelei
Enthusiast

extracting a real number from a string in GDL

Hello,

I have a string that defines the size of an opening 100x240. How can I extract the two numbers from this string so that I can calculate the area of ​​the opening? I can solve it with text functions in the case of properties, but I can't do it in the case of GDL code.

Can anyone help with this? Thanks in advance for your help.

Gábor

Versions 6.5 to 28, AMD Ryzen 9 3900x, 32GB ram, GeForce RTX 2070 super, Windows 10
1 Solution

Accepted Solutions
Barry Kelly
Moderator

It should be something like this ...

 

text_string = "100x240"
n = SPLIT (text_string, "%nx%n", size1, ss2, size2)


PRINT size1, ss2, size2 !!! 100 x 240

 

You may need to do further conversion to get the sizes into the unit of choice so you can get the area in the correct unit of measurement you need.

 

Barry.

 

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Go to post

2 Replies 2
Barry Kelly
Moderator

It should be something like this ...

 

text_string = "100x240"
n = SPLIT (text_string, "%nx%n", size1, ss2, size2)


PRINT size1, ss2, size2 !!! 100 x 240

 

You may need to do further conversion to get the sizes into the unit of choice so you can get the area in the correct unit of measurement you need.

 

Barry.

 

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Gabor Szelei
Enthusiast

Thanks Barry,
I tried something similar but for some reason it didn't work... ☹️
I hope it works this way!

Thank you again.

Gábor

Versions 6.5 to 28, AMD Ryzen 9 3900x, 32GB ram, GeForce RTX 2070 super, Windows 10

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!