Home › Forums › Problems and solutions in GDL › GDL add-ons › Writing to a text file
- This topic has 6 replies, 4 voices, and was last updated 6 years, 6 months ago by
Joachim Sühlo.
-
AuthorPosts
-
-
September 20, 2018 at 10:07 #4263
James Goode
ParticipantHello,
I want to be able to write parameter values to a text document and then read those values in another object. Is this possible? If so, how can I achieve this. I have found the OPEN, INPUT, OUTPUT functions in the GDL Reference Guide but they don’t really go into specifics and a bit more guidance would be much appreciated.
Thanks
-
September 20, 2018 at 12:22 #4264
Michael Herse
ParticipantA good starting point would be to have a look at the example script and files here https://gdl.graphisoft.com/tips-and-tricks/how-to-read-and-write-text-files.
Cheers,
Michael. -
September 20, 2018 at 12:36 #4265
James Goode
ParticipantI’ve had a go using that as a base but I can’t get my write code to work. Here it is;
ch1 = OPEN ("TEXT", "TEST123", "separator = ' ', MODE = WO") string = "12345" OUTPUT ch1, 1, 0, string
-
September 20, 2018 at 12:58 #4266
Péter Baksa
KeymasterHi,
reading and writing to files from GDL is only good for communication with external programs.
The problem with communication between library parts is that the order in which the scripts run is not deterministic. There is no guarantee that the current parameters will be written to the file before the other libpart will try to read it.
The only way for communication between library parts is to write an Add-on that sets and reads parameters of the library parts based on their subtype.
This is beyond GDL, C++ programming experience is required. You can join the API developer community at https://archicadapi.graphisoft.com/start.Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
September 20, 2018 at 14:07 #4267
James Goode
ParticipantI understand that it isn’t a perfect solution but it’s something that may be suitable for what we need. Can you point me in the right direction in terms of my code and why it’s not writing to the file?
-
September 20, 2018 at 14:30 #4268
Péter Baksa
KeymasterTry adding close ch1, maybe the data will be written only then. I haven’t tried it, just guessing.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
September 20, 2018 at 15:42 #4269
Joachim Sühlo
ParticipantJames, with your script the file is written into a special folder, which differs from Mac to Windows.
Maybe you did not find it (on Mac it is placed within the Library Folder). You could try to wrie the file in a special directory (use the keyword FULLPATH).
Some good examples of writing and raeding text files you can find in the GDL Cookbook 3, including the saving of parameter values.GDL Object Developer
b-prisma
MAC OSx 10.14
-
-
AuthorPosts
- The forum ‘GDL add-ons’ is closed to new topics and replies.