4DIS - IO

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
Line 15: Line 15:
 
IO.ReadFile ( "...url..." ) : String;
 
IO.ReadFile ( "...url..." ) : String;
  
</javascript>
+
</syntaxhighlight>
  
 
----
 
----
Line 72: Line 72:
 
}
 
}
  
</javascript>
+
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

[edit] IO

4D IS - Back


You need this class to save and load strings.

Functions :

IO.ExistsFile ( "...url..." ) : boolean;
IO.RemoveFile ( "...url..." );
IO.WriteFile ( "...url...", "...text..." );
IO.ReadFile ( "...url..." ) : String;

IO.js

import System.IO;
 
class IO
{
	public static function ExistsFile ( url : String )
	{
		var info : FileInfo = new FileInfo ( url );
 
		return info.Exists;
	}
 
	public static function RemoveFile ( url : String )
	{
		var info : FileInfo = new FileInfo ( url );
 
		if ( info.Exists )
			info.Delete ( );
	}
 
	public static function WriteFile ( url : String, string : String )
	{
		var writer : StreamWriter;
		var info : FileInfo = new FileInfo ( url );
 
		if ( info.Exists )
			info.Delete ( );
 
		writer = info.CreateText ( );
 
		writer.Write ( string );
		writer.Close ( );
	}
 
	public static function ReadFile ( url : String )
	{
		var info : FileInfo = new FileInfo ( url );
 
		if ( ! info.Exists )
			return "";
 
		var reader : StreamReader = File.OpenText ( url );
		var readedString : String = reader.ReadToEnd ( );  
 
		reader.Close ( );
 
		return readedString;
	}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox