Escape-character in GDL ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-30 03:10 PM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 09:43 AM
Hope this helps
regards,
olivier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 10:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 10:49 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 01:25 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 01:54 PM
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 .....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 02:50 PM
Maybe I'll figure it out after one night of sleep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 05:21 PM
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...??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 05:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2011-05-31 07:26 PM
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
definition
definition
definition
definition
definition
definition
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?