Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-16-2004, 01:47 PM
Member
 
Join Date: Oct 2004
Posts: 53
Default save a file

i m trying to save a variable to a text file, the save diaglog box shows up, but no file is created?????

here is the code
Quote:
mydata = "ABCDEFGHIJKLMNOPQRSTUVWZ";

var filter = "Data files(*.txt)|*.txt|";
var filename = Dialogs.fileSave(filter, ".txt");

if (filename)
{
DataFile.save(filename, mydata);
}
any solutions ???
Reply With Quote
  #2 (permalink)  
Old 10-17-2004, 02:14 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:save a file

You should specify a variable name like this:

Code:
DataFile.save(filename, "mydata");
Reply With Quote
  #3 (permalink)  
Old 10-19-2004, 08:30 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:save a file

ya, now it saves a text file.

but why are the file contents as such
Code:
[mydata]
type=string
value=abcdefghijklmnopqrstuvwxyz
why not just
Code:
abcdefghijklmnopqrstuvwxyz
and if the sting is as follows
mydata = "abcd efghi jklm nopqrst uvwxyz";

the output is
Code:
[mydata]
type=string
value=abcd%20efghi%20jklm%20nopqrst%20uvwxyz
??????????

and one more thing, is it possible to create an MS Excel file. if yes, pl guide how to.

thanks




Reply With Quote
  #4 (permalink)  
Old 10-19-2004, 09:19 AM
Senior Member
 
Join Date: Feb 2003
Posts: 212
Default Re:save a file

the datafile method saves vars in a way swfkit can easely read.
If you want to save a var to a text file without the declaration of the var types, check out the notepad example in the sample section.
Reply With Quote
  #5 (permalink)  
Old 10-19-2004, 10:00 AM
Member
 
Join Date: Jan 2003
Posts: 56
Default Re:save a file

or try something like this:

Code:
mydata = "ABCDEFGHIJKLMNOPQRSTUVWZ";

var filter = "Data files(*.txt)|*.txt|";
var filename = Dialogs.fileSave(filter, ".txt");

if (filename) 
{
file_stream = new FileStream(filename,"w");
trace(file_stream);
file_stream.writeLine(mydata);

//do file_stream.writeLine("&sometypeofdata="+mydata);
// if you want the '&var='mydata file structure

file_stream.close();

}//end of if(filename)
Thank this thread for the basis of the code:
http://www.topcmm.com/forum/thread_1_737.html

To do something instead like
Reply With Quote
  #6 (permalink)  
Old 10-19-2004, 10:34 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:save a file

hello adan

thanks a lot, the code is working perfectly.



and how do we get a "File overwriting prompt", if the file already exits.

any idea?
Reply With Quote
  #7 (permalink)  
Old 10-19-2004, 02:32 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:save a file

You can assign a flag to the Dialog.fileSave method

Dialogs.fileSave([filter[, default_ext[, filename[, flags]]]])

flags Integer. Can be one of the following values

OFN_READONLY 0x00000001
OFN_OVERWRITEPROMPT 0x00000002
OFN_HIDEREADONLY 0x00000004
OFN_NOCHANGEDIR 0x00000008
OFN_SHOWHELP 0x00000010
OFN_ENABLEHOOK 0x00000020
OFN_ENABLETEMPLATE 0x00000040
OFN_ENABLETEMPLATEHANDLE 0x00000080
OFN_NOVALIDATE 0x00000100
OFN_ALLOWMULTISELECT 0x00000200
OFN_EXTENSIONDIFFERENT 0x00000400
OFN_PATHMUSTEXIST 0x00000800
OFN_FILEMUSTEXIST 0x00001000
OFN_CREATEPROMPT 0x00002000
OFN_SHAREAWARE 0x00004000
OFN_NOREADONLYRETURN 0x00008000
OFN_NOTESTFILECREATE 0x00010000
OFN_NONETWORKBUTTON 0x00020000
OFN_NOLONGNAMES 0x00040000
OFN_EXPLORER 0x00080000 // new look commdlg
OFN_NODEREFERENCELINKS 0x00100000
OFN_LONGNAMES 0x00200000 // force long names for 3.x modules
OFN_ENABLEINCLUDENOTIFY 0x00400000 // send include message to callback
OFN_ENABLESIZING 0x00800000

Eg. Dialogs.fileSave("Zip files(*.zip; *.gz)|*.zip; *.gz|Text files(*.txt)|*.txt|All files(*.*)|*.*|", null, null, /*OFN_OVERWRITEPROMPT*/2);
Reply With Quote
  #8 (permalink)  
Old 10-20-2004, 09:20 AM
Member
 
Join Date: Oct 2004
Posts: 53
Default Re:save a file

thanks, otherwise i was trying something like this

Code:
if (filename) {
if(File.exists(filename)){
checkC = Dialogs.msgBox(filename + "already exists.Do you want to replace it.", "Save As", 52);
if (checkC == 6){
file_stream = new FileStream(filename,"w");
trace(file_stream);
Dialogs.msgBox("File  "+filename);
file_stream.writeLine(order);
file_stream.close();
}
} else{
file_stream = new FileStream(filename,"w");
trace(file_stream);
Dialogs.msgBox("File  "+filename);

file_stream.writeLine(order);
file_stream.close();
}
}
;D
Reply With Quote
Reply

Was this information helpful?    Yes No



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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:51 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.