Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------
- I/O API
- -----------------------------------------------------------
- include_library("io");
- printlns
- (
- "FILE: " $ ( f = io_file( "output.dir", FILE_READ ) ),
- "REOPEN: " $ f.open( "tmp", FILE_READ | FILE_WRITE ),
- "SETBUF: " $ f.setbuf( 123 ),
- "SIZE BEFORE: " $ f.size,
- "WRITE 'test': " $ f.write( "test" ),
- "FLUSH: " $ f.flush(),
- "SIZE AFTER: " $ f.size,
- "SEEK -1,end: " $ f.seek( -1, SEEK_END ),
- "SEEK -1,cur: " $ f.seek( -1, SEEK_CUR ),
- "TELL: " $ f.offset,
- "SEEK 1,set: " $ f.seek( 1 ),
- "READ: " $ f.read( 4 ),
- "ERROR?: " $ f.error,
- "EOF: " $ f.eof,
- "CLOSE: " $ f.close(),
- "CLEANUP: " $ io_file_delete( "tmp" )
- );
- foreach( t, i : io_dir( "." ) )
- printvars( t, i );
- -----------------------------------------------------------
- SGSVM [SGScript v0.8.2]
- FILE: file
- REOPEN: true
- SETBUF: true
- SIZE BEFORE: 0
- WRITE 'test': true
- FLUSH: true
- SIZE AFTER: 4
- SEEK -1,end: true
- SEEK -1,cur: true
- TELL: 2
- SEEK 1,set: true
- READ: est
- ERROR?: false
- EOF: true
- CLOSE: true
- CLEANUP: true
- bool (false)
- string [1] "."
- bool (false)
- string [2] ".."
- bool (true)
- string [7] "cat.txt"
- bool (true)
- string [8] "fapi.sgs"
- bool (true)
- string [7] "fmt.sgs"
- bool (true)
- string [10] "misapi.sgs"
- bool (true)
- string [9] "osapi.sgs"
- -----------------------------------------------------------
- Formatting API
- -----------------------------------------------------------
- include_library( "string" );
- include_library( "fmt" );
- function hexit( data )
- {
- tbl = "0123456789ABCDEF";
- out = "";
- for( i = 0; i < data.length; ++i )
- {
- if( out.length )
- out $= " ";
- cc = string_charcode( data, i );
- out $= tbl[ cc >> 4 ];
- out $= tbl[ cc & 15 ];
- }
- return out;
- }
- printlns
- (
- "",
- "3s4c : numbers,51,52,53,54 = " $ fmt_pack( "3s4c", "numbers", 51, 52, 53, 54 ),
- "+REV = " $ fmt_unpack( "3s4c", fmt_pack( "3s4c", "numbers", 51, 52, 53, 54 ) ),
- "",
- "w : 1024 = " $ hexit( fmt_pack( "w", 1024 ) ),
- "+REV = " $ fmt_unpack( "w", fmt_pack( "w", 1024 ) ),
- "",
- " fxd : 13.37, 13.37 = " $ hexit( fmt_pack( "fxd", 13.37, 13.37 ) ),
- "+REV = " $ fmt_unpack( "fxd", fmt_pack( "fxd", 13.37, 13.37 ) ),
- "",
- ">fxd : 13.37, 13.37 = " $ hexit( fmt_pack( ">fxd", 13.37, 13.37 ) ),
- "+REV = " $ fmt_unpack( ">fxd", fmt_pack( ">fxd", 13.37, 13.37 ) ),
- "",
- "b64 Man = " $ fmt_base64_encode( "Man" ),
- "b64 A = " $ fmt_base64_encode( "the red fo" ),
- "b64 B = " $ fmt_base64_encode( "the red fox" ),
- "b64 C = " $ fmt_base64_encode( "the red foxx" ),
- "b64 +R A = " $ fmt_base64_decode( fmt_base64_encode( "the red fo" ) ),
- "b64 +R B = " $ fmt_base64_decode( fmt_base64_encode( "the red fox" ) ),
- "b64 +R C = " $ fmt_base64_decode( fmt_base64_encode( "the red foxx" ) )
- );
- -----------------------------------------------------------
- SGSVM [SGScript v0.8.2]
- 3s4c : numbers,51,52,53,54 = num3456
- +REV = [num,51,52,53,54]
- w : 1024 = 00 04
- +REV = [1024]
- fxd : 13.37, 13.37 = 85 EB 55 41 00 3E 0A D7 A3 70 BD 2A 40
- +REV = [13.37,13.37]
- >fxd : 13.37, 13.37 = 41 55 EB 85 00 40 2A BD 70 A3 D7 0A 3E
- +REV = [13.37,13.37]
- b64 Man = TWFu
- b64 A = dGhlIHJlZCBmbw==
- b64 B = dGhlIHJlZCBmb3g=
- b64 C = dGhlIHJlZCBmb3h4
- b64 +R A = the red fo
- b64 +R B = the red fox
- b64 +R C = the red foxx
- -----------------------------------------------------------
- Iterable API
- -----------------------------------------------------------
- a1 = [1,3,5];
- a2 = [2,4,6];
- a3 = [7,8,9];
- a4 = [1,2,3,4,2,5,4];
- d1 = { a = "b", c = "d" };
- printvars
- (
- get_concat( a1, a2, a3 ),
- get_merged( d1, a4, a1 ),
- get_keys( d1 ),
- get_values( d1 ),
- a1.find( 3 ),
- a1.find( "3" ),
- a1.find( "3", true ),
- clone(a4).remove("2",false,true)
- );
- -----------------------------------------------------------
- SGSVM [SGScript v0.8.2]
- object (004CE7C0) [2] array
- [
- int (1)
- int (3)
- int (5)
- int (2)
- int (4)
- int (6)
- int (7)
- int (8)
- int (9)
- ]
- object (004CE820) [2] dict
- {
- a = string [1] "b"
- c = string [1] "d"
- 0 = int (1)
- 1 = int (3)
- 2 = int (5)
- 3 = int (4)
- 4 = int (2)
- 5 = int (5)
- 6 = int (4)
- }
- object (004CE880) [2] array
- [
- string [1] "a"
- string [1] "c"
- ]
- object (004CE8E0) [2] array
- [
- string [1] "b"
- string [1] "d"
- ]
- int (1)
- int (1)
- null
- int (2)
- -----------------------------------------------------------
- O/S API
- -----------------------------------------------------------
- include_library( "string" );
- include_library( "os" );
- formats = string_explode( "a,A,b,B,c,x,X,Z,U,W,C,d,e,F,H,I,j,m,M,p,R,S,T,u,w,y,Y,f,t,%", "," );
- dateproc = {};
- foreach( fmt : formats )
- dateproc[ fmt ] = os_date_string( "%" $ fmt );
- printlns
- (
- "OS type = " $ os_gettype(),
- "OS time = " $ os_time(),
- "OS time +2 = " $ os_time(2),
- "OS time +2:30 = " $ os_time(2.5),
- "OS time +3 = " $ os_time(3),
- "",
- "timezone (R) = " $ os_get_timezone(),
- "timezone (S) = " $ os_get_timezone(true),
- "",
- "date formats >", dumpvar( dateproc ),
- "",
- "parsed time >", dumpvar( os_parse_time() ),
- "",
- "made time >", dumpvar( os_make_time( 30, 30, 12, 25, 5, 2013 ) )
- );
- -----------------------------------------------------------
- SGSVM [SGScript v0.8.2]
- OS type = Windows
- OS time = 1369508130
- OS time +2 = 1369504530
- OS time +2:30 = 1369506330
- OS time +3 = 1369508130
- timezone (R) = 3
- timezone (S) = +03:00
- date formats >
- object (005D95C8) [1] dict
- {
- a = string [3] "Sat"
- A = string [8] "Saturday"
- b = string [3] "May"
- B = string [3] "May"
- c = string [17] "05/25/13 21:55:30"
- x = string [8] "05/25/13"
- X = string [8] "21:55:30"
- Z = string [17] "FLE Daylight Time"
- U = string [2] "20"
- W = string [2] "20"
- C = string [2] "20"
- d = string [2] "25"
- e = string [2] "25"
- F = string [10] "2013-05-25"
- H = string [2] "21"
- I = string [2] "09"
- j = string [3] "145"
- m = string [2] "05"
- M = string [2] "55"
- p = string [2] "PM"
- R = string [5] "21:55"
- S = string [2] "30"
- T = string [8] "21:55:30"
- u = string [1] "6"
- w = string [1] "6"
- y = string [2] "13"
- Y = string [4] "2013"
- f = string [19] "2013-05-25_21-55-30"
- t = string [10] "1369508130"
- % = string [1] "%"
- }
- parsed time >
- object (005DBEE0) [1] dict
- {
- year = int (2013)
- month = int (5)
- day = int (25)
- weekday = int (6)
- yearday = int (145)
- hours = int (21)
- minutes = int (55)
- seconds = int (30)
- }
- made time >
- int (1369477830)
- -----------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement