Indigo Rose Software
  #1  
Old 12-24-2008
dwenco dwenco is offline
Indigo Rose Customer
 
Join Date: Jul 2008
Posts: 23
File.Create

There's a folder.create function but I can't find any file.create function (to create a new file). It would be good to have that. Thanks.
Reply With Quote
  #2  
Old 12-24-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
Hi,

what kind of file do you want o create?
  1. ASCII/Text file - use TextFile.WriteFromString();
  2. XML file - use XML.Save();
  3. INI file - use INIFile.SetValue();

Ulrich
__________________
Reply With Quote
  #3  
Old 12-26-2008
dwenco dwenco is offline
Indigo Rose Customer
 
Join Date: Jul 2008
Posts: 23
Thanks. I wanted to create both a new text file and a XML file. The Textfile.writefromstring would work for me for the text file. Sorry I was looking under "file" for the create option.

For creating a new XML file, however, XML.Save() saves whatever I have already loaded (using XML.Load) into the file I specify, unless I save it right at the beginning before I have loaded anything. If I create a blank XML file using textfile.writefromstring, I get an error loading this new blank xml file using xml.load.

I see that this is a suggestions forum, so maybe I should move it to the discussion forum...

Thanks.
Reply With Quote
  #4  
Old 12-26-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
Quote:
Originally Posted by dwenco View Post
For creating a new XML file, however, XML.Save() saves whatever I have already loaded (using XML.Load) into the file I specify, unless I save it right at the beginning before I have loaded anything. If I create a blank XML file using textfile.writefromstring, I get an error loading this new blank xml file using xml.load.
Although you can create a skeleton XML as a text file first, it seems to me that there is no need for it. Here I show you how I created a simple XML from scratch...
Code:
-- create new XML skeleton
XML.SetXML("<?xml version=\"1.0\"?>\n<myxml>\n<creator>TrueUpdate 3.0</creator>\n</myxml>\n");

-- create first node
XML.InsertXML("myxml/creator", "<data>\n<name>John Doe</name>\n</data>\n", XML.INSERT_AFTER);
-- insert more data
XML.InsertXML("myxml/data/name", "<address>123 Somewere Road</address>\n", XML.INSERT_AFTER);
-- insert more data
XML.InsertXML("myxml/data/name", "<city>Demotown</city>\n", XML.INSERT_AFTER);

-- create second node
XML.InsertXML("myxml/data", "<data>\n<name>Jane Smith</name>\n</data>\n", XML.INSERT_AFTER);
-- insert more data
XML.InsertXML("myxml/data:2/name", "<address>456 Windy Ave</address>\n", XML.INSERT_AFTER);
-- insert more data
XML.InsertXML("myxml/data:2/name", "<city>Smallville</city>\n", XML.INSERT_AFTER);

-- create third node
XML.InsertXML("myxml/data:2", "<data>\n<name>Joe Sixpack</name>\n</data>\n", XML.INSERT_AFTER);
-- insert more data
XML.InsertXML("myxml/data:3/name", "<address>789 NW 8th Ave</address>\n", XML.INSERT_AFTER);
-- insert more data
XML.InsertXML("myxml/data:3/name", "<city>Ontario</city>\n", XML.INSERT_AFTER);

-- save XML file somewhere
XML.Save("D:\\temp\\test.xml");
Ulrich
__________________
Reply With Quote
  #5  
Old 12-27-2008
dwenco dwenco is offline
Indigo Rose Customer
 
Join Date: Jul 2008
Posts: 23
Thanks a lot Ulrich. It works. This would solve my problem!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 08:38 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software