Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Support

Pages: 1 ... 9 10 [11] 12 13 ... 59
151
Quote
Is the IDE/Debugger using an older version of scriba.exe?

I sent Dave the SB 2.2 source when about mid way in his project. I thought he updated his SB 2.1 source. Just use the scriba & libscriba.dll from the SB 2.2 beta I posted on the download board. (sticky post)

Thanks for the heads-up!

152
Quote
In the meantime, I have found a way to reduce the size of EXE files produced with the  scriba -Eo G:\SB22B2\bin\OUTPUT.exe  %1 option by 60%.


Script BASIC is < 600KB stock. Glad you found compression to work for you.

Check out Dave's IDE. Very cool.

153
Here you go.

154
The post just before your thread contains the link to the Github project site for Dave's COM ext. module. You can download the complete project in a zip from there. Binaries and Windows install included.


155
Don,

Just received your e-mail. If you would like the current 2.2 source then download Dave's COM extension module, IDE/Debugger. The following is how to build the sb.a for use with the standalone method of compiling to C.

Code: [Select]
ar rcs sb.a stndlone.obj report.obj myalloc.obj errcodes.obj dynlolib.obj

FYI: Using this method allows you to static link your extension modules used for a more seamless end result.


156
General Discussions / Re: ? about compiling C code produced with ScriptBasic
« on: September 30, 2014, 06:27:57 PM »
Don,

I'm still in the process of rebuilding my Linux system after it got trashed by a bad install script from a 3rd party library. Here is steps to compile a Script BASIC script to C under Ubuntu 14.04.1 LTS 64 bit. As soon as I get my XP virtualBox restored I post the Windows version of this.

Code: [Select]
jrs@laptop:~/sb/sb22/test$ cat testlike.sb
t = "Text at the beginning <tag>OPEN</tag>just some text<tag>CLOSE</tag> text at the end"

IF t LIKE "*<tag>*</tag>*<tag>*</tag>*" THEN
PRINT JOKER(2),"\n"
PRINT JOKER(3),"\n"
PRINT JOKER(4),"\n"
ELSE
PRINT "No Match\n"
END IF


jrs@laptop:~/sb/sb22/test$ scriba -Co testlike.c testlike.sb
jrs@laptop:~/sb/sb22/test$ gcc -Os testlike.c -I /home/jrs/sb/scriptbasic/source /usr/lib/sb.a -lscriba -lm -lpthread -ldl -o testlike
jrs@laptop:~/sb/sb22/test$ ls -l testlike*
-rwxrwxr-x 1 jrs jrs 25813 Sep 30 18:23 testlike
-rw-rw-r-- 1 jrs jrs  8225 Sep 30 18:23 testlike.c
-rw------- 1 jrs jrs   233 Sep 24 11:06 testlike.sb
jrs@laptop:~/sb/sb22/test$ ./testlike
OPEN
just some text
CLOSE
jrs@laptop:~/sb/sb22/test$ file testlike
testlike: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=d0837f48122526833ddab760f8bdec3199efe4b9, not stripped
jrs@laptop:~/sb/sb22/test$

157
General Discussions / Re: ? about compiling C code produced with ScriptBasic
« on: September 29, 2014, 12:26:49 PM »
Hi Don,

Please use the Script BASIC 2.2 beta release for all your development. (see download board - sticky post) When using the scriba -Co new.c your.bas to create the C wrapper for the binary PCODE SB script, you are using libscriba.dll for your runtime support. This option creates small footprint executables sharing a common runtime. Send me an e-mail to support@scriptbasic.org and I will send you the latest source. You could use the 2.2 binaries and the 2.1 source (headers) as that is the only thing needed for the source and nothing has change in 2.2 with headers. I posted on the forum an example of compiling to C SB scripts. If you need further help, just ask.

As an alternative, you can create a standalone .exe of your script with the scriba -Eo new.exe your.bas . This option appends your binary tokenized script to the end of scriba.exe and renames it to the name given. Scriba always checks for an appended script before processing any of its command line options.

John

158
COM / Script BASIC IDE/Debugger
« on: September 07, 2014, 09:38:19 PM »
David Zimmer (our COM/VB pro) embedded Script BASIC into VB6 to create an interactive IDE/Debugger for the project. (Windows 7 screenshot attached)




This project aims to create a VB6 usable ScriptBasic Engine.
along with a an integrated IDE + debugger.

Features include:

 VB6 access class to ScriptBasic Engine
   - AddObject
   - AddCode
   ? Eval

 IDE as VB6 ActiveX control
   - intellisense
   - syntax highlighting
   - integrated debugger
      - breakpoints
      - single step
      - step over
      - step out
      - variable inspection
      - call stack
      - variable modification
      - run to line
 
Status:
   - standalone debugger and vb usable script engine is complete.
      switching over to dll/ocx control will be completed next time I
      need this functionality embedded in another app. (hard part done)

Notes:

  - auto complete/intellisense has several scopes. hit ctrl+space to trigger.
    if there is a partial identifer already typed, with only one match, the
    string will be auto completed. If there are multiple matches, then the
    filtered results will be show in intellisense list. If no matches are found
    then entire list will be shown.

    The following scopes are supported:

      - import statements - lists *.bas in specified /include directory
      - external module functions - parses the *.bas headers to build func list.
      - built in script basic functions
      - is not currently aware of script variable names
 
   - for module functions (ex curl::) to show up, the matching import must exist
      (include file name, must match embedded module name)

   - debugger variable inspection / modification - When debugging a list view
     of variable names, scopes, and values is kept. You can edit values by right
     clicking its list entry. Array values can be viewed by double clicking on
     its variable name to bring up the array viewer form.

     You can also display a variable value, by hovering the mouse over it in
     the IDE window. A call tip will popup showing its value. Click on the call tip
     to being up the edit value form. Longs and string values are supported. You can
     also prefix a string with 0x for hex numbers.

   - parse errors will show up in their own listview. Each error will get its own entry.
     where possible line numbers, files, and error descriptions are provided. Clicking
     on the entry will jump to that line in the IDE (if one was given by SB engine)

   - changes to scripts are automatically saved each time they are executed.

   - special hot keys:

              ctrl-f - find/replace
              ctrl-g - goto line
              ctrl-z - undo
              ctrl-y - redo

              F2     - set breakpoint
              F5     - go
              F7     - single step
              F9     - step out
              F8     - step over
 


Github Project Repository

159
TinyScheme / Re: TinyScheme Extension Module
« on: September 01, 2014, 07:23:08 PM »
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

Code: Scheme
  1. ts> (load-extension "tsx")
  2. #t
  3. ts> (time)
  4. (114 8 1 17 59 44)
  5. ts> (gettimeofday)
  6. (1409619622 865397)
  7. ts> (file-size "init.scm")
  8. 24511
  9. ts> (system "ls -l init.scm")
  10. -rw-rw-r-- 1 jrs jrs 24511 Sep  1 16:45 init.scm
  11. 0
  12. ts>
  13.  

Code: [Select]
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.

160
TinyScheme / Re: TinyScheme Extension Module
« on: August 29, 2014, 11:29:52 PM »
Here is the source to the Script BASIC TinyScheme extension module written in C BASIC. (my BASIC wrapper for C)

interface.c
Code: C
  1. // Tiny Scheme - Script BASIC extension module
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include <time.h>
  9. #include "../../basext.h"
  10. #include "cbasic.h"
  11.  
  12. #define USE_INTERFACE 1
  13.  
  14. #include "scheme.h"
  15. #include "scheme-private.h"
  16.  
  17.  
  18. /****************************
  19.  Extension Module Functions
  20. ****************************/
  21.  
  22. besVERSION_NEGOTIATE
  23.   RETURN_FUNCTION((int)INTERFACE_VERSION);
  24. besEND
  25.  
  26. besSUB_START
  27.   DIM AS long PTR p;
  28.   besMODULEPOINTER = besALLOC(sizeof(long));
  29.   IF (besMODULEPOINTER EQ NULL) THEN_DO RETURN_FUNCTION(0);
  30.   p = (long PTR)besMODULEPOINTER;
  31.   RETURN_FUNCTION(0);
  32. besEND
  33.  
  34. besSUB_FINISH
  35.   DIM AS long PTR p;
  36.   p = (long PTR)besMODULEPOINTER;
  37.   IF (p EQ NULL) THEN_DO RETURN_FUNCTION(0);
  38.   RETURN_FUNCTION(0);
  39. besEND
  40.  
  41.  
  42. /***********************
  43.  Tiny Scheme Functions
  44. ***********************/
  45.  
  46. besFUNCTION(TS_init_new)
  47.   DIM AS scheme PTR sc;
  48.   sc = scheme_init_new();
  49.   besRETURN_LONG(sc);
  50. besEND
  51.  
  52. besFUNCTION(TS_deinit)
  53.   DIM AS scheme PTR sc;
  54.   besARGUMENTS("i")
  55.     AT sc
  56.   besARGEND
  57.   scheme_deinit(sc);
  58.   besRETURNVALUE = NULL;
  59. besEND
  60.  
  61. besFUNCTION(TS_load_string)
  62.   DIM AS scheme PTR sc;
  63.   DIM AS char PTR cmdstr;
  64.   DIM AS char tsbuf[16384];
  65.   besARGUMENTS("iz")
  66.     AT sc, AT cmdstr
  67.   besARGEND
  68.   scheme_set_output_port_string (sc, (char PTR) tsbuf, (char PTR) tsbuf + 16383);
  69.   scheme_load_string(sc, cmdstr);
  70.   besRETURN_STRING(RTRIM(tsbuf));
  71. besEND
  72.  

ts.inc
Code: Script BASIC
  1. ' TinyScheme
  2.  
  3. DECLARE SUB TS_New ALIAS "TS_init_new" LIB "ts"
  4. DECLARE SUB TS_Close ALIAS "TS_deinit" LIB "ts"
  5. DECLARE SUB TS_Cmd ALIAS "TS_load_string" LIB "ts"
  6.  

161
TinyScheme / TinyScheme - King's Reward
« on: August 29, 2014, 07:15:25 PM »
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)

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
  1. ' King's Reward
  2.  
  3. DECLARE SUB InitNew ALIAS "TS_init_new" LIB "ts"
  4. DECLARE SUB Deinit ALIAS "TS_deinit" LIB "ts"
  5. DECLARE SUB LoadStr ALIAS "TS_load_string" LIB "ts"
  6.  
  7. sc = InitNew()
  8. LoadStr(sc, "(load \"init.scm\")")
  9. reward = """
  10. (define (grains x)
  11.   (let loop ((i 1) (j 1))
  12.     (display " field ") (display i)
  13.     (display "  number of grains   ")(display j)  (newline)
  14.     (when (< i x) (loop (+ i 1) (* 2 j) ))))
  15.  
  16. (define (main)
  17.   (display "The reward of the King") (newline)
  18.   (display "----------------------") (newline)
  19.   (newline)
  20.   (grains 64))
  21. (main)  
  22. """  
  23. PRINT LoadStr(sc, reward)
  24. Deinit sc
  25.  

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$

162
TinyScheme / Re: TinyScheme Extension Module
« on: August 28, 2014, 01:35:41 AM »
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
  1. ' TinyScheme Script BASIC DLLC Example
  2.  
  3. DECLARE SUB dllfile ALIAS "dllfile" LIB "dllc"
  4. DECLARE SUB dllproc ALIAS "dllproc" LIB "dllc"
  5. DECLARE SUB dllcall ALIAS "dllcall" LIB "dllc"
  6. DECLARE SUB dllsptr ALIAS "dllsptr" LIB "dllc"
  7.  
  8. ts = dllfile("libtinyscheme.dll")
  9. InitNew = dllproc(ts, "scheme_init_new i = ()")
  10. RtnStr = dllproc(ts, "scheme_set_output_port_string (i sc, i startptr, i endptr)")
  11. Deinit = dllproc(ts, "scheme_deinit (i sc)")
  12. LoadStr = dllproc(ts, "scheme_load_string (i sc, c *cmd)")
  13.  
  14. sc = dllcall(InitNew)
  15. lispbuf = string(4096,CHR(0))
  16. lispstrptr = dllsptr(lispbuf)
  17. lispstrend = lispstrptr + 4096 - 1
  18. dllcall(RtnStr,sc, lispstrptr, lispstrend)
  19. dllcall(LoadStr, sc, "(load \"init.scm\")")
  20. tscm = """
  21. (newline)
  22. (display "start")
  23. (newline)
  24.  
  25.  
  26. (define (seq x)
  27.   (let ((M '()))
  28.     (do ((i 0 (+ i 1)))
  29.         ((> i x))
  30.         (set! M (cons i M))) M ))
  31.  
  32. (define numbers (reverse (seq 4999)))
  33.  
  34.  
  35.  
  36. (define (sieve L)
  37.   (let ( ( len (- (length L) 2)) (vec (list->vector L)) )
  38.     (do ((i 2 (+ i 1)))
  39.         ((> i (floor (/ len 2))))
  40.        
  41.         (when (> (vector-ref vec i) 0)
  42.            (do ((j 2 (+ j 1)))
  43.                ((> (* i j) len))
  44.              
  45.                (vector-set! vec (* i j) 0)))) vec ))
  46.  
  47. (define (print-vec V)
  48.   (let ((len (vector-length V)) (cnt 0) )
  49.     (do (( i 2 (+ 1 i)))
  50.         (( = i (- len 1)))
  51.         (let (( item (vector-ref V i)))
  52.           (when (not (= item 0))
  53.              (set! cnt (+ 1 cnt))
  54.              (display item)
  55.              (display " ")))) cnt ))
  56.  
  57. (define (main)
  58.  (let ((cnt 0))
  59.   (newline)
  60.   (display "calculating prime-numbers < 5000")  (newline)
  61.   (display "--------------------------------")  (newline)
  62.   (set! cnt (print-vec (sieve numbers)))
  63.   (newline)
  64.   (display "that's it")
  65.   (newline)
  66.    (display cnt) (display "  prime numbers found") ))
  67.  
  68.  
  69. (main)  
  70. (quit)
  71. """
  72.  
  73. dllcall(LoadStr, sc, tscm)
  74. strlen = INSTR(lispbuf, CHR(0))
  75. PRINT LEFT(lispbuf, strlen - 1),"\n"
  76. dllcall(Deinit, sc)
  77.  
  78. dllfile()
  79.  

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>


163
TinyScheme / TinyScheme Extension Module
« on: August 27, 2014, 11:38:58 PM »
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
  1. (newline)
  2. (newline)
  3. (display "Ascii Mandelbrot TinyScheme") (newline)
  4. (display "---------------------------") (newline)
  5.  
  6. (define sq
  7.    (lambda (x) (* x x)))
  8.  
  9. (define (1+ x) (+ x 1))
  10. (define (1- x) (- x 1))
  11.  
  12. (define level
  13.   (lambda (i x y rc ic it orb)
  14.    (if (or (= i it) (> orb 4)) i
  15.     (level (1+ i) (+ rc (- (sq x) (sq y))) (+ ic (* 2 x y)) rc ic it (+ (sq x) (sq y))))))
  16.  
  17. (define mlevel
  18.    (lambda (L)
  19.      (level 0 (cadr L) (car L) (cadr L) (car L) 11 0)))
  20.  
  21. (define (main)
  22.    (let ((cnt 0) (lvl 0) (xo -1.7) (yo -2.3) (dz 0.1) )
  23.      (do ((i 0 (1+ i)))
  24.          ((= i 30))
  25.         (do ((j 0 (1+ j)))
  26.             ((= 30 j))
  27.               (set! lvl (mlevel (list (+ xo (* i dz)) (+ yo (* j dz)) )))
  28.               (if (< lvl 10)
  29.                    (begin (display lvl) (display " "))
  30.                    (display lvl))
  31.               (set! cnt (1+ cnt))
  32.               (when (= 30 cnt)
  33.                  (set! cnt 0)
  34.                  (newline))
  35. ))))
  36.  
  37. (main)
  38. (quit)
  39.  

Code: Script BASIC
  1. ' TinyScheme Script BASIC DLLC Example
  2.  
  3. DECLARE SUB dllfile ALIAS "dllfile" LIB "dllc"
  4. DECLARE SUB dllproc ALIAS "dllproc" LIB "dllc"
  5. DECLARE SUB dllcall ALIAS "dllcall" LIB "dllc"
  6. DECLARE SUB dllsptr ALIAS "dllsptr" LIB "dllc"
  7.  
  8. ts = dllfile("libtinyscheme.dll")
  9. InitNew = dllproc(ts, "scheme_init_new i = ()")
  10. RtnStr = dllproc(ts, "scheme_set_output_port_string (i sc, i startptr, i endptr)")
  11. Deinit = dllproc(ts, "scheme_deinit (i sc)")
  12. LoadStr = dllproc(ts, "scheme_load_string (i sc, c *cmd)")
  13.  
  14. sc = dllcall(InitNew)
  15. lispbuf = STRING(4096,CHR(0))
  16. lispstrptr = dllsptr(lispbuf)
  17. lispstrend = lispstrptr + 4096 - 1
  18. dllcall(RtnStr,sc, lispstrptr, lispstrend)
  19. dllcall(LoadStr, sc, "(load \"init.scm\")")
  20. dllcall(LoadStr, sc, "(load \"mbrot2.scm\")")
  21. strlen = INSTR(lispbuf, CHR(0))
  22. PRINT LEFT(lispbuf, strlen - 1),"\n"
  23. dllcall(Deinit, sc)
  24.  
  25. dllfile()
  26.  

Output

Code: [Select]
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>

164
General Discussions / Re: SBLisp
« on: August 20, 2014, 09:14:48 PM »
Mike (FBSL author) created this Ackermann example in SBLisp to show the progress we have made with the Scheme BASIC Lisp interpreter.

SBLisp current standalone executables for Windows 32 bit and Ubuntu 64 bit attached. (see attached for this running on CompileOnLine.com)

Code: Scheme
  1. ;;; Rob's macros
  2.  
  3. (define make-listx
  4.      (lambda (i x L)
  5.       (if (= i x) L
  6.           (make-listx (+ i 1) x (cons i L)))))
  7.  
  8. (define range
  9.   (lambda (x)
  10.     (reverse (make-listx 0 x '() ))))
  11.  
  12. (define iterate
  13.   (lambda (op it)
  14.     (map (eval op) (range it))
  15.   T ))
  16.  
  17.  
  18.  
  19. ;;; ======= My LISP program ======
  20.  
  21. ;; Define iterators
  22. (define m 0)
  23. (define n 0)
  24.  
  25. ;; John's recursive Ackermann algo redefined
  26. (define A
  27.   (lambda (x y)
  28.     (cond
  29.       ((= x 0) (+ y 1))
  30.       ((= y 0) (A (- x 1) 1))
  31.       (else
  32.         (A (- x 1) (A x (- y 1)))
  33.       )
  34.     )
  35.   )
  36. )
  37.  
  38. ;; My Ackermann call
  39. (define Ackermann
  40.   (lambda ()
  41.     (print '"A(") (print m)
  42.       (print '", ") (print n)
  43.         (print '") = ") (print (A m n))
  44.     (newline)
  45.     (set! n (+ n 1))
  46.   )
  47. )
  48.  
  49. (define for-inner
  50.   (lambda ()
  51.     (set! n 0)
  52.     (iterate 'ackermann (- 6 m))
  53.     (set! m (+ m 1))
  54.   )
  55. )
  56.  
  57. (define for-outer
  58.   (lambda ()
  59.     (iterate 'for-inner 4)
  60.   )
  61. )
  62.  
  63. (define main
  64.   (lambda ()
  65.     (iterate 'newline 10)
  66.     (print  '========================== ) (newline)
  67.     (print '"My First XBLisp Program :)") (newline)
  68.     (print  '========================== ) (newline) (newline)
  69.     (for-outer)
  70.   )
  71. )
  72.  
  73. (main)
  74. (quit)
  75.  
  76. ;;; ==== THAT'S ALL FOLKS! ====
  77.  

Output

jrs@laptop:~/sb/sb22/sblisp$ time scriba lisp.sb ackermann.scm
SBLisp - Scheme BASIC Lisp

(define make-listx
     (lambda (i x L)
      (if (= i x) L
          (make-listx (+ i 1) x (cons i L)))))
MAKE-LISTX
(define range
  (lambda (x)
    (reverse (make-listx 0 x '() ))))
RANGE
(define iterate
  (lambda (op it)
    (map (eval op) (range it))
  T ))
ITERATE
(define m 0)
M
(define n 0)
N
(define A
  (lambda (x y)
    (cond
      ((= x 0) (+ y 1))
      ((= y 0) (A (- x 1) 1))
      (else
        (A (- x 1) (A x (- y 1)))
      )
    )
  )
)
A
(define Ackermann
  (lambda ()
    (print '"A(") (print m)
      (print '", ") (print n)
        (print '") = ") (print (A m n))
    (newline)
    (set! n (+ n 1))
  )
)
ACKERMANN
(define for-inner
  (lambda ()
    (set! n 0)
    (iterate 'ackermann (- 6 m))
    (set! m (+ m 1))
  )
)
FOR-INNER
(define for-outer
  (lambda ()
    (iterate 'for-inner 4)
  )
)
FOR-OUTER
(define main
  (lambda ()
    (iterate 'newline 4)
    (print  '=================== ) (newline)
    (print  '"Ackermann - SBLisp") (newline)
    (print  '=================== ) (newline) (newline)
    (for-outer)
  )
)
MAIN
(main)




===================
ACKERMANN - SBLISP
===================

A(0, 0) = 1
A(0, 1) = 2
A(0, 2) = 3
A(0, 3) = 4
A(0, 4) = 5
A(0, 5) = 6
A(1, 0) = 2
A(1, 1) = 3
A(1, 2) = 4
A(1, 3) = 5
A(1, 4) = 6
A(2, 0) = 3
A(2, 1) = 5
A(2, 2) = 7
A(2, 3) = 9
A(3, 0) = 5
A(3, 1) = 13
A(3, 2) = 29
T
(quit)

real   0m1.133s
user   0m1.116s
sys   0m0.012s
jrs@laptop:~/sb/sb22/sblisp$

165
General Discussions / Re: SBLisp
« on: August 11, 2014, 05:40:06 PM »
Attached is a standalone Windows 32 bit version of SBLisp. (Scheme BASIC Lisp) The documentation provided by the original author is attached as well. A PDF from Randy Beer that wrote the first cut that Arthur used as a reference to write LISP in BASIC is also attached.

Update - 2014-AUG-16 - SBLisp  (standalone executable) Windows 32 bit & Ubuntu 64 bit.

Pages: 1 ... 9 10 [11] 12 13 ... 59