Extension Modules > TinyScheme
TinyScheme Extension Module
Support:
I thought I would post an update to where things are with the Lisp in BASIC adventure. Mike has taken over with the QB converted Lisp in BASIC and is primarily developing it for FBSL and possibly OxygenBasic. My interest in the project was to see how compatible Script BASIC was with QB 4.5 and as a possible teaching aid. It seemed to be too much work to convert it to C when there are already more complete and faster implementations of Scheme. I'm using TinyScheme which is the scripting language for GIMP and easily embedded in SB. I have a C BASIC TinyScheme extension working on Ubuntu 64 and decided to use DLLC under Windows to take advantage of the multi-threading feature of the DLLC interface. The following example loads/calls a ASCII Mandelbrot Scheme script Rob wrote on the O2 forum and returns the results in a SB predefine buffer string.
--- Code: Scheme ---(newline)(newline)(display "Ascii Mandelbrot TinyScheme") (newline)(display "---------------------------") (newline) (define sq (lambda (x) (* x x))) (define (1+ x) (+ x 1))(define (1- x) (- x 1)) (define level (lambda (i x y rc ic it orb) (if (or (= i it) (> orb 4)) i (level (1+ i) (+ rc (- (sq x) (sq y))) (+ ic (* 2 x y)) rc ic it (+ (sq x) (sq y)))))) (define mlevel (lambda (L) (level 0 (cadr L) (car L) (cadr L) (car L) 11 0))) (define (main) (let ((cnt 0) (lvl 0) (xo -1.7) (yo -2.3) (dz 0.1) ) (do ((i 0 (1+ i))) ((= i 30)) (do ((j 0 (1+ j))) ((= 30 j)) (set! lvl (mlevel (list (+ xo (* i dz)) (+ yo (* j dz)) ))) (if (< lvl 10) (begin (display lvl) (display " ")) (display lvl)) (set! cnt (1+ cnt)) (when (= 30 cnt) (set! cnt 0) (newline)))))) (main)(quit)
--- Code: Script BASIC ---' TinyScheme Script BASIC DLLC Example DECLARE SUB dllfile ALIAS "dllfile" LIB "dllc"DECLARE SUB dllproc ALIAS "dllproc" LIB "dllc"DECLARE SUB dllcall ALIAS "dllcall" LIB "dllc"DECLARE SUB dllsptr ALIAS "dllsptr" LIB "dllc" ts = dllfile("libtinyscheme.dll")InitNew = dllproc(ts, "scheme_init_new i = ()")RtnStr = dllproc(ts, "scheme_set_output_port_string (i sc, i startptr, i endptr)")Deinit = dllproc(ts, "scheme_deinit (i sc)")LoadStr = dllproc(ts, "scheme_load_string (i sc, c *cmd)") sc = dllcall(InitNew)lispbuf = STRING(4096,CHR(0))lispstrptr = dllsptr(lispbuf)lispstrend = lispstrptr + 4096 - 1dllcall(RtnStr,sc, lispstrptr, lispstrend)dllcall(LoadStr, sc, "(load \"init.scm\")")dllcall(LoadStr, sc, "(load \"mbrot2.scm\")")strlen = INSTR(lispbuf, CHR(0))PRINT LEFT(lispbuf, strlen - 1),"\n"dllcall(Deinit, sc) dllfile()
Output
--- Code: ---C:\SB22\TS>ptime scriba dllchellots.sb
ptime 1.0 for Win32, Freeware - http://www.pc-tools.net/
Copyright(C) 2002, Jem Berkes <jberkes@pc-tools.net>
=== scriba dllchellots.sb ===
Ascii Mandelbrot TinyScheme
---------------------------
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 115 4 4 3 3 2 2 2
1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 5 7 9 114 4 3 3 2 2
1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 9 118 5 4 4 3 3 3
1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 8 1111116 5 5 4 3 3
1 1 1 1 1 2 3 3 3 3 3 3 3 4 4 4 5 7 8 8 101111119 6 6 5 4 3
1 1 1 1 2 3 3 3 3 3 3 3 4 4 5 5 6 11111111111111111111114 3
1 1 1 1 2 3 3 3 3 3 4 5 5 5 5 6 8 111111111111111111117 5 3
1 1 1 1 3 3 3 3 4 5 7 7 7 7 7 7 11111111111111111111119 5 4
1 1 1 1 3 4 4 4 5 5 7 111111119 1111111111111111111111116 4
1 1 1 1 4 4 4 5 5 6 8 11111111111111111111111111111111115 4
1 1 1 1 4 4 6 6 7 1111111111111111111111111111111111118 5 4
1 1 1 1111111111111111111111111111111111111111111111117 5 4
1 1 1 1 4 4 6 6 7 1111111111111111111111111111111111118 5 4
1 1 1 1 4 4 4 5 5 6 8 11111111111111111111111111111111115 4
1 1 1 1 3 4 4 4 5 5 7 111111119 1111111111111111111111116 4
1 1 1 1 3 3 3 3 4 5 7 7 7 7 7 7 11111111111111111111119 5 4
1 1 1 1 2 3 3 3 3 3 4 5 5 5 5 6 8 111111111111111111117 5 3
1 1 1 1 2 3 3 3 3 3 3 3 4 4 5 5 6 11111111111111111111114 3
1 1 1 1 1 2 3 3 3 3 3 3 3 4 4 4 5 7 8 8 101111119 6 6 5 4 3
1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 8 1111116 5 5 4 3 3
1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 9 118 5 4 4 3 3 3
1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 5 7 9 114 4 3 3 2 2
1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 115 4 4 3 3 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2
Execution time: 1.086 s
C:\SB22\TS>
--- End code ---
Support:
Here is a primes < 5000 example of passing a Scheme script as a string rather than loading it from a file. 8)
--- Code: Script BASIC ---' TinyScheme Script BASIC DLLC Example DECLARE SUB dllfile ALIAS "dllfile" LIB "dllc"DECLARE SUB dllproc ALIAS "dllproc" LIB "dllc"DECLARE SUB dllcall ALIAS "dllcall" LIB "dllc"DECLARE SUB dllsptr ALIAS "dllsptr" LIB "dllc" ts = dllfile("libtinyscheme.dll")InitNew = dllproc(ts, "scheme_init_new i = ()")RtnStr = dllproc(ts, "scheme_set_output_port_string (i sc, i startptr, i endptr)")Deinit = dllproc(ts, "scheme_deinit (i sc)")LoadStr = dllproc(ts, "scheme_load_string (i sc, c *cmd)") sc = dllcall(InitNew)lispbuf = string(4096,CHR(0))lispstrptr = dllsptr(lispbuf)lispstrend = lispstrptr + 4096 - 1dllcall(RtnStr,sc, lispstrptr, lispstrend)dllcall(LoadStr, sc, "(load \"init.scm\")")tscm = """(newline)(display "start")(newline) (define (seq x) (let ((M '())) (do ((i 0 (+ i 1))) ((> i x)) (set! M (cons i M))) M )) (define numbers (reverse (seq 4999))) (define (sieve L) (let ( ( len (- (length L) 2)) (vec (list->vector L)) ) (do ((i 2 (+ i 1))) ((> i (floor (/ len 2)))) (when (> (vector-ref vec i) 0) (do ((j 2 (+ j 1))) ((> (* i j) len)) (vector-set! vec (* i j) 0)))) vec )) (define (print-vec V) (let ((len (vector-length V)) (cnt 0) ) (do (( i 2 (+ 1 i))) (( = i (- len 1))) (let (( item (vector-ref V i))) (when (not (= item 0)) (set! cnt (+ 1 cnt)) (display item) (display " ")))) cnt )) (define (main) (let ((cnt 0)) (newline) (display "calculating prime-numbers < 5000") (newline) (display "--------------------------------") (newline) (set! cnt (print-vec (sieve numbers))) (newline) (display "that's it") (newline) (display cnt) (display " prime numbers found") )) (main) (quit)""" dllcall(LoadStr, sc, tscm)strlen = INSTR(lispbuf, CHR(0))PRINT LEFT(lispbuf, strlen - 1),"\n"dllcall(Deinit, sc) dllfile()
Output
C:\SB22\TS>ptime scriba tsprimes.sb
ptime 1.0 for Win32, Freeware - http://www.pc-tools.net/
Copyright(C) 2002, Jem Berkes <jberkes@pc-tools.net>
=== scriba tsprimes.sb ===
start
calculating prime-numbers < 5000
--------------------------------
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 16
7 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349
353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547
557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 7
51 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 97
1 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 11
51 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 13
19 1321 1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 15
11 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 16
97 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 18
89 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 20
87 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267 2269 2273 2281 22
87 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 24
67 2473 2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663 2671 2677 2683 26
87 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851 28
57 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 30
79 3083 3089 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221 3229 3251 3253 3257 3259 3271 3299 3301 33
07 3313 3319 3323 3329 3331 3343 3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461 3463 3467 3469 3491 3499 35
11 3517 3527 3529 3533 3539 3541 3547 3557 3559 3571 3581 3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671 3673 3677 36
91 3697 3701 3709 3719 3727 3733 3739 3761 3767 3769 3779 3793 3797 3803 3821 3823 3833 3847 3851 3853 3863 3877 3881 3889 39
07 3911 3917 3919 3923 3929 3931 3943 3947 3967 3989 4001 4003 4007 4013 4019 4021 4027 4049 4051 4057 4073 4079 4091 4093 40
99 4111 4127 4129 4133 4139 4153 4157 4159 4177 4201 4211 4217 4219 4229 4231 4241 4243 4253 4259 4261 4271 4273 4283 4289 42
97 4327 4337 4339 4349 4357 4363 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457 4463 4481 4483 4493 4507 4513 4517 4519 45
23 4547 4549 4561 4567 4583 4591 4597 4603 4621 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721 4723 4729 4733 47
51 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861 4871 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 49
69 4973 4987 4993
that's it
668 prime numbers found
Execution time: 4.855 s
C:\SB22\TS>
Support:
--- Quote from: Rob ---If you need some teasers for TS -- quickly written : the reward of the King (story goes when the King asked the inventor of the game of chess about his price ,he answered to start with one grain and double it every next field (rice / corn .. etc ). The King answered, is that all ?! -- however some calculations learn the amount is immense .....
2 things in the code :
the named let -- how to do "pseudo" iterations (the use name "loop" is just another name -- run , do-it etc.. also will do)
how to mark the number is inexact : use 1.0 i.o. 1 (otherwise it will run out of capable numbers)
--- End quote ---
Script BASIC and the TinyScheme extension module are 64 bit in my example. Rob's 32 bit overflow hack he used on his PC code was removed.
--- Code: Script BASIC ---' King's Reward DECLARE SUB InitNew ALIAS "TS_init_new" LIB "ts"DECLARE SUB Deinit ALIAS "TS_deinit" LIB "ts"DECLARE SUB LoadStr ALIAS "TS_load_string" LIB "ts" sc = InitNew()LoadStr(sc, "(load \"init.scm\")")reward = """(define (grains x) (let loop ((i 1) (j 1)) (display " field ") (display i) (display " number of grains ")(display j) (newline) (when (< i x) (loop (+ i 1) (* 2 j) )))) (define (main) (display "The reward of the King") (newline) (display "----------------------") (newline) (newline) (grains 64))(main) """ PRINT LoadStr(sc, reward)Deinit sc
Output
jrs@laptop:~/sb/sb22/sblisp/Rob$ time scriba king.sb
The reward of the King
----------------------
field 1 number of grains 1
field 2 number of grains 2
field 3 number of grains 4
field 4 number of grains 8
field 5 number of grains 16
field 6 number of grains 32
field 7 number of grains 64
field 8 number of grains 128
field 9 number of grains 256
field 10 number of grains 512
field 11 number of grains 1024
field 12 number of grains 2048
field 13 number of grains 4096
field 14 number of grains 8192
field 15 number of grains 16384
field 16 number of grains 32768
field 17 number of grains 65536
field 18 number of grains 131072
field 19 number of grains 262144
field 20 number of grains 524288
field 21 number of grains 1048576
field 22 number of grains 2097152
field 23 number of grains 4194304
field 24 number of grains 8388608
field 25 number of grains 16777216
field 26 number of grains 33554432
field 27 number of grains 67108864
field 28 number of grains 134217728
field 29 number of grains 268435456
field 30 number of grains 536870912
field 31 number of grains 1073741824
field 32 number of grains 2147483648
field 33 number of grains 4294967296
field 34 number of grains 8589934592
field 35 number of grains 17179869184
field 36 number of grains 34359738368
field 37 number of grains 68719476736
field 38 number of grains 137438953472
field 39 number of grains 274877906944
field 40 number of grains 549755813888
field 41 number of grains 1099511627776
field 42 number of grains 2199023255552
field 43 number of grains 4398046511104
field 44 number of grains 8796093022208
field 45 number of grains 17592186044416
field 46 number of grains 35184372088832
field 47 number of grains 70368744177664
field 48 number of grains 140737488355328
field 49 number of grains 281474976710656
field 50 number of grains 562949953421312
field 51 number of grains 1125899906842624
field 52 number of grains 2251799813685248
field 53 number of grains 4503599627370496
field 54 number of grains 9007199254740992
field 55 number of grains 18014398509481984
field 56 number of grains 36028797018963968
field 57 number of grains 72057594037927936
field 58 number of grains 144115188075855872
field 59 number of grains 288230376151711744
field 60 number of grains 576460752303423488
field 61 number of grains 1152921504606846976
field 62 number of grains 2305843009213693952
field 63 number of grains 4611686018427387904
field 64 number of grains -9223372036854775808
real 0m0.042s
user 0m0.040s
sys 0m0.000s
jrs@laptop:~/sb/sb22/sblisp/Rob$
Support:
Here is the source to the Script BASIC TinyScheme extension module written in C BASIC. (my BASIC wrapper for C)
interface.c
--- Code: C ---// Tiny Scheme - Script BASIC extension module #include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <math.h>#include <time.h>#include "../../basext.h"#include "cbasic.h" #define USE_INTERFACE 1 #include "scheme.h"#include "scheme-private.h" /**************************** Extension Module Functions****************************/ besVERSION_NEGOTIATE RETURN_FUNCTION((int)INTERFACE_VERSION);besEND besSUB_START DIM AS long PTR p; besMODULEPOINTER = besALLOC(sizeof(long)); IF (besMODULEPOINTER EQ NULL) THEN_DO RETURN_FUNCTION(0); p = (long PTR)besMODULEPOINTER; RETURN_FUNCTION(0);besEND besSUB_FINISH DIM AS long PTR p; p = (long PTR)besMODULEPOINTER; IF (p EQ NULL) THEN_DO RETURN_FUNCTION(0); RETURN_FUNCTION(0);besEND /*********************** Tiny Scheme Functions***********************/ besFUNCTION(TS_init_new) DIM AS scheme PTR sc; sc = scheme_init_new(); besRETURN_LONG(sc);besEND besFUNCTION(TS_deinit) DIM AS scheme PTR sc; besARGUMENTS("i") AT sc besARGEND scheme_deinit(sc); besRETURNVALUE = NULL;besEND besFUNCTION(TS_load_string) DIM AS scheme PTR sc; DIM AS char PTR cmdstr; DIM AS char tsbuf[16384]; besARGUMENTS("iz") AT sc, AT cmdstr besARGEND scheme_set_output_port_string (sc, (char PTR) tsbuf, (char PTR) tsbuf + 16383); scheme_load_string(sc, cmdstr); besRETURN_STRING(RTRIM(tsbuf));besEND
ts.inc
--- Code: Script BASIC ---' TinyScheme DECLARE SUB TS_New ALIAS "TS_init_new" LIB "ts"DECLARE SUB TS_Close ALIAS "TS_deinit" LIB "ts"DECLARE SUB TS_Cmd ALIAS "TS_load_string" LIB "ts"
Support:
I found a github repository for TinyScheme (fork) that has fixed some issues and included the RE (regular expression) and TSX (TinySchmeme Extensions) extension modules. I couldn't get RE to work so it isn't included in the attached zip. If you could give this a test, that would be great. The tinyscheme.exe was compiled with VS2008 (VC9) and the schme.exe and the libtinyscheme.dll were compiled with TDM-GCC-32. The Script BASIC TinyScheme extension module for Windows 32 seems to work fine with the new libtinyscheme.dll.
[*]based on TinyScheme 1.41
[*]build with MS Visual C++ on Windows
[*]continuations support without using 'SCHEME STACK' (#undef USE_SCHEME_STACK)
[*]embedding 'init.scm' into tinyscheme.exe (or tinyscheme.lib)
[*]fixed crash in GC after getting read-char 'EOF'
[*]implement 'string->uninterned-symbol' and 'gensym' gets new uninterned-symbol
[*]include TinyScheme Extensions (TSX)
[*]include TinyScheme RE extension
[/list]
--- Code: Scheme ---ts> (load-extension "tsx")#tts> (time)(114 8 1 17 59 44)ts> (gettimeofday)(1409619622 865397)ts> (file-size "init.scm")24511ts> (system "ls -l init.scm")-rw-rw-r-- 1 jrs jrs 24511 Sep 1 16:45 init.scm0ts>
--- Code: ---TinyScheme Extensions (TSX) 1.1 [September, 2002]
(c) 2002 Manuel Heras-Gilsanz (manuel@heras-gilsanz.com)
This software is subject to the license terms contained in the
LICENSE file.
TSX FUNCTIONS
TSX incorporates the following functions:
*Sockets (included if HAVE_SOCKETS is defined in tsx.h)
(make-client-socket host port)
host: string (IP address or host name)
port: integer number
Returns a socket which is already connected to the
specified host and port, or #f if the connection could
not be performed.
(make-server-socket port)
port: integer number
Returns a socket which is bound to the specified port on
the local machine, and ready to accept connections. If the
socket could not be created (e.g., because the port is
already in use, or it is a privileged port and the user has
no permissions on it), #f is returned.
(recv! sock buff)
sock: socket obtained with make-client-socket or accept
buff: string
Waits for received data through the specified socket, and
stores it on the buffer. The return value indicates the
number of received bytes. This call blocks until some data
is received, but does not guarantee that buff gets
completely filled. If an error occurs (e.g., the other
peer disconnects) then #f is returned.
(recv-new-string sock)
sock: socket obtained with make-client-socket or accept
Waits for received data through the specified socket, and
returns it in a new string. This call blocks until some
data is received. If an error occurs, then #f is returned.
(send sock buff)
sock: socket obtained with make-client-socket or accept
buff: string
Sends the data contained in the string through the socket.
It returns the number of transmitted bytes (could be
different than the size of the string!), or #f if an error
occured (e.g., the other peer disconnected).
(accept server-sock)
server-sock: socket obtained with make-server-socket
Waits until a connection is received on the specified
server socket, and returns the connected socket. If an
error occurs (e.g., the network interface shuts down), it
returns #f instead.
(close-socket sock)
sock: socket obtained with make-server-socket,
make-client-socket or accept
The socket is closed. No further calls should be performed
on this socket.
(sock-is-data-ready? sock)
sock: socket obtained with make-server-socket,
make-client-socket or accept
This function allows non-blocking operation with sockets.
It returns #t if data is available for reception on this
socket, and #f if no data has been received.
(sock-peek sock)
sock: socket obtained with make-server-socket,
make-client-socket or accept
This function returns (as a newly created string) the
data received in this socket. The information is not
removed from the input queue.
*File system (included if HAVE_FILESYSTEM is defined in tsx.h)
Scheme already defines functions to read and write files. These
functions allow access to the filesystem to check if a certain
file exists, to get its size, etc.
(file-size filename)
filename: string
This function returns the size (in bytes) of the
indicated file, or #f if the file does not exists or
is not accessible to the requesting user.
(file-exists? filename)
filename: string
This function returns #t if the indicated file exists, and
#f if it does not exists or it is not accessible to the
requesting user.
(delete-file filename)
filename: string
Removes the specified file. It returns #t if the operation
succeeds, or #f otherwise (e.g., because the file is
read-only, or because the file does not exist).
(open-dir-stream path)
path: string
Opens a "directory stream" on the provided directory path.
This stream will provide all the files within the directory,
using the function read-dir-entry. The stream should be closed
at the end with close-dir-stream.
(read-dir-entry dirstream)
dirstream: directory stream, obtained with open-dir-stream.
It returns the name of the following directory entry, or eof
if all the entries were provided. Check the return value with
with eof-object?.
(close-dir-stream dirstream)
dirstream: directory stream, obtained with open-dir-stream.
Close directory stream. No further calls to read-dir-entry should
be performed.
*Time (available if HAVE_TIME is defined in tsx.h)
(time)
Returns the current local time, as a list of integer
containing:
(year month day-of-month hour min sec millisec)
The year is expressed as an offsett from 1900.
(gettimeofday)
Returns a list containing the number of seconds from
the beginning of the day, and microseconds within the
current second.
(usleep microsec)
microsec: integer
Suspends execution of the calling thread during the
specified number of microseconds.
*Miscellaneous functions (available if HAVE_MISC is defined)
(getenv varname)
varname: string
Returns a string with the content of the specified
environment variable, or #f if the variable is not
defined.
(system command)
command: string
Executes a command on the /bin/sh shell. Returns #f if
it is unable to run /bin/sh or another error occurs,
or an integer return code which is the value returned
by the command to the shell.
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version