4DIS - IO

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
Line 10: Line 10:
 
<javascript>
 
<javascript>
  
- IO.ExistsFile ( "...url..." ) : boolean;
+
IO.ExistsFile ( "...url..." ) : boolean;
- IO.RemoveFile ( "...url..." );
+
IO.RemoveFile ( "...url..." );
- IO.WriteFile ( "...url...", "...text..." );
+
IO.WriteFile ( "...url...", "...text..." );
- IO.ReadFile ( "...url..." ) : String;
+
IO.ReadFile ( "...url..." ) : String;
  
 
</javascript>
 
</javascript>

Revision as of 21:37, 2 November 2011

IO

4D IS - Back


You need this class to save and load strings.

Functions :

<javascript>

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

</javascript>


IO.js

<javascript>

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; } }

</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox