Raspberry BASIC

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.


Topics - John Spikowski

Pages: 1 2 [3]
31
C BASIC / Hello C BASIC
« on: April 19, 2019, 07:30:38 PM »
Code: C
  1. #include <stdio.h>
  2. #include "cbasic.h"
  3.  
  4. MAIN
  5. BEGIN_FUNCTION
  6.   PRINT("Hello, World!\n");
  7. END_FUNCTION
  8.  


$ gcc hello.c -o hello
$ ./hello
Hello, World!
$


32
ScriptBasic / ScriptBasic Keyword List
« on: April 18, 2019, 02:42:02 AM »
This is the ScriptBasic keyword list.

ABS
ACOS
ACOSECANT
ACTAN
ADDDAY
ADDHOUR
ADDMINUTE
ADDMONTH
ADDRESS
ADDSECOND
ADDWEEK
ADDYEAR
ALIAS
AND
AS
ASC
ASECANT
ASIN
ATAN
ATN
BIN
BINMODE
BY
BYVAL
CALL
CHDIR
CHOMP
CHR
CHR$
CINT
CLOSE
CLOSEALL
COMMAND
CONF
CONST
COS
COSECANT
COTAN
COTAN2
CRYPT
CURDIR
CVD
CVI
CVL
CVS
DAY
DECLARE
DELETE
DELTREE
DIRECTORY
DO
ELIF
ELSE
ELSEIF
ELSIF
END
ENDIF
ENVIRON
ENVIRON$
EOD
EOF
ERROR
ERROR$
EVEN
EXECUTE
EXIT
EXP
FALSE
FILE
FILEACCESSTIME
FILECOPY
FILECREATETIME
FILEEXISTS
FILELEN
FILEMODIFYTIME
FILEOWNER
FIX
FOR
FORK
FORMAT
FORMATDATE
FORMATTIME
FRAC
FREEFILE
FROM
FUNCTION
GCD
GLOBAL
GMTIME
GMTIMETOLOCALTIME
GO
GOSUB
GOTO
HCOS
HCOSECANT
HCTAN
HEX
HEX$
HOSTNAME
HOUR
HSECANT
HSIN
HTAN
ICALL
IF
IMAX
IMIN
INPUT
INSTR
INSTRREV
INT
ISARRAY
ISDEFINED
ISDIRECTORY
ISEMPTY
ISFILE
ISINTEGER
ISNUMERIC
ISREAL
ISSTRING
ISUNDEF
JOIN
JOKER
KILL
LBOUND
LCASE
LCASE$
LCM
LEFT
LEFT$
LEN
LET
LIB
LIKE
LINE
LOC
LOCAL
LOCALTIMETOGMTIME
LOCK
LOF
LOG
LOG10
LOOP
LOWER
LOWER$
LTRIM
LTRIM$
MAX
MAXINT
MID
MID$
MIN
MININT
MINUTE
MKD
MKD$
MKDIR
MKI
MKI$
MKL
MKL$
MKS
MKS$
MODULE
MONTH
NAME
NEXT
NEXTFILE
NO
NOT
NOW
NULL
OCT
OCT$
ODD
ON
OPEN
OPTION
OR
OUTPUT
PACK
PATTERN
PAUSE
PI
POP
POW
PRINT
PRINTNL
QUOTE
RANDOMIZE
REF
REGION
REPEAT
REPLACE
RESET
RESUME
RETURN
REWIND
RIGHT
RIGHT$
RND
ROUND
RTRIM
RTRIM$
SEC
SECANT
SEEK
SET
SGN
SIN
SLEEP
SPACE
SPACE$
SPLIT
SPLITA
SPLITAQ
SQR
STEP
STOP
STR
STR$
STRING
STRING$
STRREVERSE
STRREVERSE$
SUB
SWAP
SYSTEM
TAN
TAN2
TEXTMODE
THEN
TIME
TIMEVALUE
TO
TRIM
TRIM$
TRUE
TRUNCATE
TYPE
UBOUND
UCASE
UCASE$
UNDEF
UNPACK
UNTIL
UPPER
UPPER$
VAL
VAR
WAITPID
WEEKDAY
WEND
WHILE
WILD
XOR
YEAR
YEARDAY

Not Implemented
  • BIN - This is a planned function to convert the argument number to binary format. (aka. format as a binary number containing only 0 and 1 characters and return this string)
  • GCD - Mathematical function has become a reserved word, but are not implemented.
  • LCM - Mathematical function has become a reserved word, but are not implemented.
  • ATN - This is a planned function to calculate the arcus tangent of the argument.
  • ATAN - This is a planned function to calculate the arcus tangent of the argument.
  • TAN - This is a planned function to calculate the tangent of the argument.
  • TAN2 - This is a planned function to calculate the tangent of the ratio of the two arguments.
  • COTAN - This is a planned function to calculate the cotangent of the argument.
  • COTAN2 - This is a planned function to calculate the cotangent of the ratio of the two arguments.
  • ACTAN - This is a planned function to calculate the arcus cotangent of the argument.
  • SECANT - This is a planned function to calculate the secant of the argument.
  • COSECANT - This is a planned function to calculate the cosecant of the argument.
  • ASECANT - This is a planned function to calculate the arcus secant of the argument.
  • ACOSECANT - This is a planned function to calculate the arcus cosecant of the argument.
  • HSIN - This is a planned function to calculate the sinus hyperbolicus of the argument.
  • HCOS - This is a planned function to calculate the cosinus hyperbolicus of the argument.
  • HTAN - This is a planned function to calculate the tangent hyperbolicus of the argument.
  • HCTAN - This is a planned function to calculate the cotangent hyperbolicus of the argument.
  • HSECANT - This is a planned function to calculate the secant hyperbolicus of the argument.
  • HCOSECANT - This is a planned function to calculate the cosecant hyperbolicus of the argument.
  • MAX - This is a planned function to select and return the maximum of the arguments.
  • MIN - This is a planned function to select and return the minimum of the arguments.
  • IMAX - This is a planned function to select and return the index of the maximum of the arguments.
  • IMIN - This is a planned function to select and return the index of the minimum of the arguments.
  • CVD - This is a planned function to convert the argument string into a real number. (8 byte)
  • CVI - This is a planned function to convert the argument string into an integer. (2 bytes)
  • CVL - This is a planned function to convert the argument string into an long integer. (4 bytes)
  • CVS - This is a planned function to convert the argument string into an integer. (4 byte)
  • MKD - This is a planned function to convert the argument real number to an 8 byte string. (8 byte)
  • MKI - This is a planned function to convert the argument integer number to a string. (2 byte)
  • MKS - This is a planned function to converts a single-precision number "n" into a  string so it can later be retrieved from a random-access file as a numeric value. (4 byte)
  • MKL - This is a planned function converts a long-integer number "n" into a string so it can later be retrieved from a random-access file as a numeric value. (4-byte)

Valid ScriptBasic Operators

Power operator (^)
Multiplication operator (*)
Division operator (/)
Integer division operator (\)
Modulus operator (%)
Addition and subtraction operators (+, -)
Bit-wise and logical NOT (NOT)
Equality operator (=)
Not equal operator (<>)
Compare operators (<, <=, >, >=)
Logical operators (and, or, xor)
Concatenation operator (&)
ByVal operator
LIKE operator



 Operators that are undefined by default but can be used by external modules are:


?     !     #     `     @
+^    +<    +>    +?    +=    +*    +/    +%    +!    +#    +&    +\    +`    +'   
+@    -^    -<    ->    -?    -=    -*    -/    -%    -!    -#    -&    -\    -`   
-'    -@    ^^    ^<    ^>    ^?    ^=    ^*    ^/    ^%    ^!    ^#    ^&    ^\   
^`    ^'    ^@    <^    <<    <?    <*    </    <%    <!    <#    <&    <\    <`   
<'    <@    >^    ><    >>    >?    >*    >/    >%    >!    >#    >&    >\    >`   
>'    >@    ?^    ?<    ?>    ??    ?=    ?*    ?/    ?%    ?!    ?#    ?&    ?\   
?`    ?'    ?@    =^    =<    =>    =?    ==    =*    =/    =%    =!    =#    =&   
=\    =`    ='    =@    *^    *<    *>    *?    *=    **    */    *%    *!    *#   
*&    *\    *`    *'    *@    /^    /<    />    /?    /=    /*    //    /%    /!   
/#    /&    /\    /`    /'    /@    %^    %<    %>    %?    %=    %*    %/    %%   
%!    %#    %&    %\    %`    %'    %@    !^    !<    !>    !?    !=    !*    !/   
!%    !!    !#    !&    !\    !`    !'    !@    #^    #<    #>    #?    #=    #*   
#/    #%    #!    ##    #&    #\    #`    #'    #@    &^    &<    &>    &?    &=   
&*    &/    &%    &!    &#    &&    &\    &`    &'    &@    \^    \<    \>    \?   


\=    \*    \/    \%    \!    \#    \&    \\    \`    \'    \@    `^    `<    `>   
`?    `=    `*    `/    `%    `!    `#    `&    `\    ``    `'    `@    '^    '<   
'>    '?    '=    '*    '/    '%    '!    '#    '&    '\    '`    ''    '@    @^   
@<    @>    @?    @=    @*    @/    @%    @!    @#    @&    @\    @`    @'    @@


33
ScriptBasic / Remote Console Debugger
« on: April 16, 2019, 05:10:03 PM »
This is an example of debugging a script with the console mode interactive debugger.

dbgcontest.sb
Code: Script BASIC
  1. a = 1
  2. b = "ScriptBasic"
  3. PRINT a,"\n"
  4. PRINT b,"\n"
  5.  


pi@raspberrypi:~/sbrpi $ scriba dbgcon.sb dbgcontest.sb
Application: ScriptBasic Remote Debugger
Version: 1.0
Source-File-Count: 1
Source-File: dbgcontest.sb
Current-Line: 1
-> l 1-
 [0001] a = 1
 [0002] b = "ScriptBasic"
 [0003] PRINT a,"\n"
 [0004] PRINT b,"\n"
Current-Line: 1
-> s
Current-Line: 2
-> b4
Message: done
Current-Line: 2
-> r
1
Current-Line: 4
-> G
Global-Variable-Name: main::a
Global-Variable-Value: 1
Global-Variable-Name: main::b
Global-Variable-Value: "ScriptBasic"
Current-Line: 4
-> r
ScriptBasic
Debug session closed.
pi@raspberrypi:~/sbrpi $


Place the sdbg.so in your /usr/local/lib/scriba directory.
The dbgcon.sb script should be in the same directory as the script you're debugging.

34
ScriptBasic / Working with cURL
« on: April 15, 2019, 05:06:58 AM »
This thread will be about using ScriptBasic and the cURL extension module. The first example is what I call my Hello Me cURL example. This is also included in the extension module test scripts I posted in the Resources thread.

Code: Script BASIC
  1. ' MyIP
  2.  
  3. IMPORT curl.bas
  4.  
  5. ch = curl::init()
  6. curl::option(ch,"URL","ipinfo.io")
  7. PRINT curl::perform(ch),"\n"
  8.  
  9. curl::finish(ch)
  10.  

Output

pi@RPi3B:~/sbrpi/examples $ time scriba myip.sb
{
  "ip": "#4.#9.#1.#11",
  "hostname": "c-#4-#9-#1-#11.hsd1.wa.comcast.net",
  "city": "Anacortes",
  "region": "Washington",
  "country": "US",
  "loc": "48.5004,-122.6310",
  "postal": "98221",
  "org": "AS33650 Comcast Cable Communications, LLC"
}

real   0m0.334s
user   0m0.049s
sys   0m0.016s
pi@RPi3B:~/sbrpi/examples $



35
BBC BASIC / BBC BASIC Compiler?
« on: April 15, 2019, 03:33:17 AM »
Richard,

Quote from: Your Web Site
The Raspberry Pi edition has an ARM assembler.

This was the reason I thought BBC BASIC was a BASIC to ASM compiler.


36
ScriptBasic / Resources
« on: April 15, 2019, 02:07:05 AM »
The following resources are available for the Raspberry Pi.

ScriptBasic Runtime - RPi Zero (this version runs on all models of the Raspberry Pi)
https://raspberrybasic.org/download/scriptbasic-rpi-zero.deb

ScriptBasic Runtime - Rpi ARMv7 (B / B+ Doesn't run on the Zero)
https://raspberrybasic.org/download/scriptbasic-2.1-linux-armhf.deb

ScriptBasic Runtime - AppImage (ARMv7 single file no install)
https://raspberrybasic.org/download/sb.AppImage.zip

DEB Install (installs needed dependences as well)
sudo apt install ./scriptbasic-2.1-linux-armhf.deb

AppImage
Extract the sb file from the zip in a directory in the system path.

Note: The DEB installs use scriba to run scripts and the AppImage uses sb to run them.

The source can be found in the AllBASIC sandbox.
https://sandbox.allbasic.info:8181/scriptbasic/sb-dev

Extract your source download whch will create a sb-dev directory. Make sure you install the developer dependencies for the extension modules.

libcurl4-gnutls-dev
libiodbc2-dev
libmariadbclient-dev-compat (provides mysqlclient)
libncurses5-dev
libsqlite3-dev
libssl-dev
zlib1g-dev

sudo perl jamal.pl -i    (this adds a Perl module the ScriptBasic build system needs but normally not installed by default)

./setup   (this builds the ScriptBasic runtime executables and include files created in the bin directory.

If all goes well, run the mkdeb.sh script to create the PACKAGES .deb install file or create a local install using mkdist.sh <dest dir>.


Documentation (User and Developer) can be found in the ScriptBasic Wiki.
https://scriptbasic.org/wiki

Feel free to send me a PM (Private Message) or post your questions to the ScriptBasic forum board.

Attached is a set of scripts and data files I use to test the extension modules with.

Additional Extension Modules

GPM Fibo
Extract the zip and put the gmp.so extension module that should go in the /usr/local/lib/scriba directory.

https://raspberrybasic.org/download/gmp_zero.zip


TinyScheme
* Unzip to a tmp directory.
* Copy libtinyscheme.so to your /usr/lib/ directory.
* Copy ts.so to your /usr/local/lib/scriba/ directory.
* Copy the remaining examples and init.scm to your ScriptBasic examples directory where ever that may be.

Note: The init.scm file is a Lisp script that adds additional syntax to your Lisp scripts.

https://raspberrybasic.org/download/TinyScheme_RPi_Zero.zip

37
ScriptBasic / ScriptBasic Introduction
« on: April 09, 2019, 07:16:57 PM »


Script BASIC is written in ANSI C with an object like API. The scripting engine is embeddable, with a thread safe memory manager and virtually unlimited expandability. The core language uses one source tree for all platforms. Variables are maintained in a variant like structure and typeless until used.

Script BASIC comes with an array of industry standard library extension modules and a multi-threaded proxy HTTPD application server running as an OS service.

Scripting doesn't get any easier and based on a language syntax we all grew up with.

ScriptBasic Forum


Pages: 1 2 [3]