- This wiki is out of date, use the continuation of this wiki instead
 
Load
From FenixWiki
(Difference between revisions)
												
			
			| Revision as of 09:38, 23 May 2008 (edit) 85.144.194.29 (Talk) (New article.) ← Previous diff  | 
				Current revision (20:50, 23 May 2008) (edit) (undo) Sandman (Talk | contribs) m  | 
			||
| Line 5: | Line 5: | ||
| '''INT''' load ( <'''STRING''' filename> , <'''VARSPACE''' data> ) | '''INT''' load ( <'''STRING''' filename> , <'''VARSPACE''' data> ) | ||
| - | Loads the data read from the specified file into  | + | Loads the data read from the specified file into the specified variable. | 
| == Parameters == | == Parameters == | ||
| Line 42: | Line 42: | ||
| End | End | ||
| </pre> | </pre> | ||
| - | Used in example: [[file_exists]](), [[write]](), [[key]]() | + | Used in example: [[file_exists]](), [[load]](), [[write]](), [[key]]() | 
| + | |||
| + | {{Funcbox | ||
| + | | category = Files | ||
| + | }} | ||
Current revision
Contents | 
[edit] Definition
INT load ( <STRING filename> , <VARSPACE data> )
Loads the data read from the specified file into the specified variable.
[edit] Parameters
| STRING filename | - The name of the file to be loaded. | 
| VARSPACE data | - The variable (of any datatype) in which the data read from the file will be loaded. | 
[edit] Returns
INT : The number of bytes read from the file.
[edit] Notes
To check whether a file exists before it is loaded, file_exists() can be used.
[edit] Example
Program test;
Global
    struct My_struct
        Level_number;
        string Map_name;
    End
Begin
    If (file_exists("myfile.sav")) 
        Load("myfile.sav",My_struct);            // Content from myfile.sav is loaded into My_struct
        Write(0,10,10,0,My_struct.level_number); // A variable from the loaded struct is shown on screen
        Write(0,10,20,0,My_struct.map_name);     // Another variable loaded is shown on screen
    Else
        Write(0,10,10,0,"File couldn't be loaded, it doesn't exist.");
    End
    While (!key(_esc))
        Frame;
    End
End
Used in example: file_exists(), load(), write(), key()
| Files Functions | |
| • Cd() • Chdir() • Fclose() • Feof() • Fgets() • File() • File_exists() • Flength() • Fopen() • Fputs() • Fread() • Fseek() • Ftell() • Fwrite() • Glob() • Load() • Mkdir() • Rmdir() • Save() • | |
