We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Escape-character in GDL ?

Anonymous
Not applicable
I'm about to analyze a string containing this:
record = bla-bla-bla "texture174" = "CD" bla-bla-bla

I would like to search for the "-substring
I use STRSTR(record, "\"texture"), but when I check the script, I get an error message.
So how should I escape special characters like " ?

Thank you!
16 REPLIES 16
Anonymous
Not applicable
Although I'm not totally sure it will work in that case you can usually use ' instead of ". Like: strstr(record,"'\'texture")
Hope this helps
regards,
olivier
Anonymous
Not applicable
Hi Olivier
Yes today, after a good night sleep, I figured out that I could simply replace the " with '. So I search for '"texture', and that worked!
But I always get new problems trying to do new things.
So now I'm struggelig with this:

My file start with:
DIM tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[3]
tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[1] = 0.9803921580315
tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[2] = 0.9098039269447
tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[3] = 0.7803921699524
define texture "Texture174" "CD", 0.3, 0.3, 932, 0

define material "PKSLeatherCD" 20,
bla
bla
bla

The first record contains only DIM but miss the rest of the line,
and the next records are ok, but the reading ends at the empty line. My loop test for n > 0 (n= INPUT(.....))
Between the DIM and the rest of the line is a tabulator.
I have also tried to specify the separator \n when I open the file, but no change.
Now I'm trying to find an overview of special characters like \t, \n a.s.o.
but I've not found it so far.
I would like to use the character that really ends the lines as a separator and test for a character that ends the file (if it exists) to end the loop.
Anonymous
Not applicable
It seem like the tabulator is used as the separator, even if I give the \n as a separator when I open the file.
Now I test at n <> -1 where n= INPUT(......)
Then the reading do not end at the empty line.
I see that the Unicode character set is used in GDL. I've found a table,
but I do not understand the connection between the \t, \n - notation at one side and the Unicode-table at the other side.
If I want to use CR and LF as a separator, what should I test for?
I tried SEPARATOR = 'CRLF', but the tabulator is still beeing used as a separator.
Please help!
Anonymous
Not applicable
I'm not sure about what you are trying to achieve, but I guess u want to define variables ( in that case tmp_LWA_COGSMASKEDIMAGE_BASECOLOR)
in a separate text file.
If that is the case, instead of using txt in plugin to read in the data, you could save your txt file as a gdl file(just change the extension to ".gdl") and call it from your main script. If there is a "tmp_LWA_COGSMASKEDIMAGE_BASECOLOR" existing in your main object,
then when you will call the gdl file the values defined in it will be transferred to the main object

in short
-a main object with a tmp_LWA_COGSMASKEDIMAGE_BASECOLOR parameter
+
call "values1.gdl"

-a values1.gdl file with your gdl code defining the tmp_LWA_COGSMASKEDIMAGE_BASECOLOR in it.

Hope this helps,
olivier
Anonymous
Not applicable
Now I'm confused.
My idea is to make a material the regular way, write the definition to a file "Material.gdl", put the names of the other material's textures into another file. Then I want make a program (GDL-object) merging this information together in a sensible way, and write the result to a file.

Then I can copy/paste the new material-definitions into the master-script of the object needing this materials.

But, unfortunately I meet some challenges .....
Anonymous
Not applicable
Sorry but I'm ever more confused, I really don't get it.
Maybe I'll figure it out after one night of sleep
Anonymous
Not applicable
I have a background as a system developer, so it is such things we are likely to do. I suppose it is cryptic to others that do not have the same background.

So I just try to automate the job of making material definitions that has small variations. It's only the texture-iterator and the material name and the texture-filename that changes for every definition.

If you just use the Write GDL-command from the Special Menu, a file with material definitions is created.
But it is possible to make such a file programatically too.
GDL has possibilities to open a file, read from it, test the strings and replace part of strings, and write the changed content back to another file.
But I'm struggeling testing on special characters like tabulator, linefeed a.s.o.

You are probably even more confused...?? 🙂
Frank Beister
Moderator
you should post the part, which you have written to read the file.
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Anonymous
Not applicable
This is the input-file:
DIM tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[3]
tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[1] = 0.9803921580315
tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[2] = 0.9098039269447
tmp_LWA_COGSMASKEDIMAGE_BASECOLOR[3] = 0.7803921699524
define texture "Texture174" "CD", 0.3, 0.3, 932, 0

define material "PKSLeatherCD" 20,
0.980392, 0.909804, 0.780392,
0.92, 0.66, 0.14, 0, 4.6, 0,
1, 1, 1,
0, 0, 0,
0, ind(fill, "Background"), -4,
ind(texture, "Texture174") ADDITIONAL_DATA LWA_COLOR = "LWA_COGSMASKEDIMAGE",
LWA_COGSMASKEDIMAGE_BASECOLOR = tmp_LWA_COGSMASKEDIMAGE_BASECOLOR,
LWA_COGSMASKEDIMAGE_FILE = "CD", LWA_COGSMASKEDIMAGE_SCALE = 0.3000000119209,
LWA_COGSMASKEDIMAGE_ASPRATIO = 1, LWA_COGSMASKEDIMAGE_MASK_FILE = "CD",
LWA_COGSMASKEDIMAGE_MASKSCALE = 0.3000000119209, LWA_COGSMASKEDIMAGE_MASPRATIO = 1,
LWA_REFLECTANCE = "LWA_RFMATTE", LWA_RFMATTE_AMBIENT = 0.9200000166893,
LWA_RFMATTE_DIFFUSE = 0.660000026226, LWA_TRANSPARENCY = "LWA_TRNONE",
LWA_TEXTURESPACE = "LWA_TSGSREPLICATE", LWA_TSGSREPLICATE_SREFLECT = 1,
LWA_TSGSREPLICATE_TREFLECT = 1, LWA_TSGSREPLICATE_SSIZE = 0.3000000119209,
LWA_TSGSREPLICATE_TSIZE = 0.3000000119209, LWA_TSGSREPLICATE_ANGLE = 0,
LWA_PIPELINE = "LWA_PLNONE", LWA_DISPLACEMENT = "LWA_DPWBUMPMAP",
LWA_DPWBUMPMAP_FILE = "CD", LWA_DPWBUMPMAP_WIDTH = 0.5299999713898,
LWA_DPWBUMPMAP_HEIGHT = 0.5299999713898, LWA_DPWBUMPMAP_AMPLITUDE = 0.01999999955297,
LWA_DPWBUMPMAP_SOFTNESS = 1, LWA_DPWBUMPMAP_SCALE = 1,
LWA_DPWBUMPMAP_ASPRATIO = 1

This is the code:
materialDefinition = open ("TEXT", "Material.gdl", "mode = RO,LIBRARY")
materialNames = open ("TEXT", "MaterialNames.gdl", "mode = RO,LIBRARY")
Master_GDL = open ("TEXT", "Master_GDL_my materials.gdl","SEPARATOR = '\n', mode = WA,LIBRARY")


i = 1
n = INPUT (materialDefinition , i, 1, field1, field2, field3, field4, field5, field6, field7)

WHILE n <> -1 DO

definition[1] = field1
definition[2] = field2
definition[3] = field3
definition[4] = field4
definition[5] = field5
definition[6] = field6
definition[7] = field7

OUTPUT Master_GDL, i, 1, field1, field2, field3, field4, field5, field6, field7

field1 = ""
field2 = ""
field3 = ""
field4 = ""
field5 = ""
field6 = ""
field7 = ""

i = i + 1
n = INPUT (materialDefinition , i, 1, field1, field2, field3, field4, field5, field6, field7)
ENDWHILE
CLOSE materialDefinition
CLOSE Master_GDL

The result is attached.
How do I put in CR LF sequences after each line?

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!