the input lib implements basic input/output routines.
dofile(
path, [raiseerror])
;
compiles a squirrel script or loads a precompiled one and executes it. returns the value returned by the script or null if no value is returned. if the optional parameter 'raiseerror' is true, the compiler error handler is invoked in case of a syntax error. If raiseerror is omitted or set to false, the compiler error handler is not ivoked. When squirrel is compiled in unicode mode the function can handle different character ecodings, UTF8 with and without prefix and UCS-2 prefixed(both big endian an little endian). If the source stream is not prefixed UTF8 ecoding is used as default.
loadfile(
path, [raiseerror])
;
compiles a squirrel script or loads a precompiled one an returns it as as function. if the optional parameter 'raiseerror' is true, the compiler error handler is invoked in case of a syntax error. If raiseerror is omitted or set to false, the compiler error handler is not ivoked. When squirrel is compiled in unicode mode the function can handle different character ecodings, UTF8 with and without prefix and UCS-2 prefixed(both big endian an little endian). If the source stream is not prefixed UTF8 ecoding is used as default.
writeclosuretofile(
destpath, closure)
;
serializes a closure to a bytecode file (destpath). The serialized file can be loaded using loadfile() and dofile().
stderr
File object bound on the os standard error stream
stdin
File object bound on the os standard input stream
stdout
File object bound on the os standard output stream
The file object implements a stream on a operating system file. It's contructor imitate the behaviour of the C runtime function fopen for eg.
local myfile = file("test.xxx","wb+");
creates a file with read/write access in the current directory.
close(
)
;
closes the file
eos(
)
;
returns a non null value if the read/write pointer is at the end of the stream.
flush(
)
;
flushes the stream.return a value != null if succeded, otherwise returns null
len(
)
;
returns the lenght of the stream
readblob(
size)
;
read n bytes from the stream and retuns them as blob
readn(
type)
;
reads a number from the stream according to the type parameter. type can have the following values:
'i' | 32bits number | returns an integer |
's' | 16bits signed integer | returns an integer |
'w' | 16bits unsigned integer | returns an integer |
'c' | 8bits signed integer | returns an integer |
'b' | 8bits unsigned integer | returns an integer |
'f' | 32bits float | returns an float |
'd' | 64bits float | returns an float |
seek(
seek, [origin])
;
Moves the read/write pointer to a specified location. offset indicates the number of bytes from origin. origin can be 'b' beginning of the stream,'c' current location or 'e' end of the stream. If origin is omitted the parameter is defaulted as 'b'(beginning of the stream).
tell(
)
;
returns read/write pointer absolute position
writeblob(
blob)
;
writes a blob in the stream
writen(
n, type)
;
writes a number in the stream formatted according to the type parameter. type can have the following values:
'l' | processor dependent, 32bits on 32bits processors, 64bits on 64bits prcessors |
returns an integer | 'i' |
32bits number | 's' |
16bits signed integer | 'w' |
16bits unsigned integer | 'c' |
8bits signed integer | 'b' |
8bits unsigned integer | 'f' |
32bits float | 'd' |
64bits float |