cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
GDL
About building parametric objects with GDL.
SOLVED!

extracting a real number from a string in GDL

Gabor Szelei
Booster

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 ACCEPTED SOLUTION

Accepted Solutions
Solution
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

View solution in original post

2 REPLIES 2
Solution
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

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