Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
52e3e77
UI: add window.setFont command
chrisws Mar 12, 2016
c465237
COMMON: added TIMESTAMP keyword
chrisws Mar 14, 2016
6a062fe
SDL: fix capslock handling
chrisws Mar 14, 2016
f850a9e
COMMON: Removed system constants BPP and VIDADR, OSNAME
chrisws Mar 15, 2016
ded5d54
COMMON: cleanup constants
chrisws Mar 16, 2016
306b5ee
UI: tweak hash to avoid false highlighting
chrisws Mar 17, 2016
103f439
SDL: fix recent file error
chrisws Mar 17, 2016
e828500
COMMON: fix problem with escape chars using format
chrisws Mar 19, 2016
c6775ab
COMMON: Fix problem with XNOR command result
chrisws Mar 21, 2016
14a4050
COMMON: fix IMP and EQV
chrisws Mar 24, 2016
6f78b12
COMMON: fix map bool
chrisws Mar 25, 2016
10d6261
COMMON: bump version
chrisws Mar 25, 2016
18af421
COMMON: update jsmn
chrisws Mar 26, 2016
2a87e8a
COMMON: fix inkey handling
chrisws Mar 27, 2016
f820269
UI: fix file manager
chrisws Mar 27, 2016
d5b87a5
COMMON: fix try-catch
chrisws Mar 28, 2016
0155879
COMMON: fix try-catch
chrisws Mar 29, 2016
f729aa9
UI: add simple input layout handling
chrisws Mar 31, 2016
b671a13
COMMON: Added LSHIFT and RSHIFT bit shift operators
chrisws Apr 4, 2016
bd68bb0
COMMON: Added LSHIFT and RSHIFT bit shift operators
chrisws Apr 4, 2016
6aa079b
UI: fix editor layout
chrisws Apr 4, 2016
601eefb
UI: Fixed using POINT to retrieve IMAGE data
chrisws Apr 10, 2016
67ecb69
UI: update IMAGE handling
chrisws Apr 12, 2016
724bc30
UI: update IMAGE handling
chrisws Apr 13, 2016
8544435
UI: update IMAGE handling
chrisws Apr 13, 2016
7cd274c
UI: update lodepng
chrisws Apr 13, 2016
9951cca
COMMON: fixed issues with CHAIN
chrisws Apr 14, 2016
bb10539
COMMON: Fixed TLOAD to work correctly with TRY/CATCH
chrisws Apr 16, 2016
cbdf3aa
COMMON: Fixed XPOS and YPOS to return 0 based values
chrisws Apr 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
2016-02-18
Removed TICKSPERSEC, TICKS now returns millisecond intervals
2016-03-29 (0.12.6)
Removed TICKSPERSEC
Removed BALLOC, MALLOC and VADR keywords. Removed duplicate ENVIRON
Removed system constants BPP and VIDADR, OSNAME, LINECHART, BARCHART
Added TIMESTAMP to return the modified-datetime of a file
Added LSHIFT and RSHIFT bit shift operators
SBVER now includes build information
TICKS now returns millisecond intervals
Refactor eval() for performance
Fixed some memory leaks in the ui handler
Editor now restores cursor when returning from run
Editor now displays the correct filename in the title bar
Added "industrial" editor theme from Shian (slot 2)
Fixed editor highlighting
Runtime errors now show source screen with red error highlighter
Form refresh command now takes an boolean arg, true=push ui state to vars
Removed BALLOC, MALLOC and VADR keywords
The IMAGE argument can now be PNG data stored in an INT array
The IMAGE argument can now be x,y,w,h screen corordinates
The IMAGE argument can now be a 2-D array of POINTS
Updated IMAGE sub-command to save 2-D array of POINT
Added window.setFont command to set font size, bold and italic. example:
w = window():w.setFont(10, "pt", false, true)
TRUE is now always returned as 1
Added file manager to main shell program
Fixed problem with escaped chars using FORMAT
Fixed problem with XNOR command result
Fixed problem with IMP and EQV command result
Fixed issues with INKEY command to allow ALT/SHIFT/CTRL states to be returned
Fixed capslock handling
Fixed issues with TRY/CATCH
Fixed using POINT to retrieve IMAGE data
Fixed issues with CHAIN
Fixed TLOAD to work correctly with TRY/CATCH
Fixed XPOS and YPOS to return 0 based values

2016-02-11
Added export to mobile command (SDL)
Expand Down
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl

AC_INIT([smallbasic], [0.12.5])
AC_INIT([smallbasic], [0.12.6])
AC_CONFIG_SRCDIR([configure.ac])

AC_CANONICAL_TARGET
Expand Down Expand Up @@ -364,6 +364,8 @@ checkDebugMode
checkForWindows

PACKAGE_CFLAGS="${PACKAGE_CFLAGS} -Wall -Wno-unused-result"
BUILD_DATE=`date +"%a, %d %b %Y"`
AC_DEFINE_UNQUOTED([BUILD_DATE],["$BUILD_DATE"],[Build date])

AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)
Expand Down
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
smallbasic (0.12.6) unstable; urgency=low
* Various - see web site

-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 26 Mar 2016 09:45:25 +1000

smallbasic (0.12.3) unstable; urgency=low
* Various - see web site

Expand Down
17 changes: 13 additions & 4 deletions documentation/build_kwp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ bool isKeyword(const char *keyword) {
}
}

const char* constants[] = {
"SBVER", "PI", "XMAX", "YMAX", "TRUE", "FALSE", "CWD", "HOME", "COMMAND", ""
};
for (int i = 0; !result && constants[i] != '\0'; i++) {
if (strcasecmp(constants[i], keyword) == 0) {
result = true;
}
}

return result;
}

Expand Down Expand Up @@ -223,8 +232,8 @@ uint32_t getHash(const char *key) {
uint32_t hash, i;
for (hash = i = 0; key[i] != '\0'; i++) {
hash += tolower(key[i]);
hash += (hash << 3);
hash ^= (hash >> 1);
hash += (hash << 4);
hash ^= (hash >> 2);
}
return hash;
}
Expand Down Expand Up @@ -264,7 +273,7 @@ int main(int argc, char *argv[]) {
HelpItem *item = (*it);
if (strcasecmp(item->package, "Language") == 0) {
count++;
fprintf(stdout, " %uu,\n", getHash(item->keyword));
fprintf(stdout, " %uu, //%s\n", getHash(item->keyword), item->keyword);
}
}
fprintf(stdout, "};\n");
Expand All @@ -276,7 +285,7 @@ int main(int argc, char *argv[]) {
HelpItem *item = (*it);
if (strcasecmp(item->package, "Language") != 0) {
count++;
fprintf(stdout, " %uu,\n", getHash(item->keyword));
fprintf(stdout, " %uu, //%s\n", getHash(item->keyword), item->keyword);
}
}
fprintf(stdout, "};\n");
Expand Down
16 changes: 16 additions & 0 deletions documentation/mkref.bas
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ in_map = array(in_str)

if (len(args) == 2 && args(1) == "txt") then
mk_text_reference(in_map)
elif (len(args) == 2 && args(1) == "bas") then
mk_bas(in_map)
else
mk_help(in_map)
fi
Expand Down Expand Up @@ -56,6 +58,20 @@ func fix_comments(comments, keyword)
fix_comments = comments
end

sub mk_bas(byref in_map)
local i, row, group, keyword
local in_map_len = len(in_map) - 1
for i = 0 to in_map_len
row = in_map(i).body_value
keyword = get_field(row, "keyword=", true)
group = get_field(row, "group=", true)
? group + " " + keyword
while (i + 1 < in_map_len && in_map(i).entity_id == in_map(i + 1).entity_id)
i++
wend
next i
end

sub mk_help(byref in_map)
local i, row, group, type, keyword, syntax, brief
local in_map_len = len(in_map) - 1
Expand Down
37 changes: 22 additions & 15 deletions documentation/sbasic_ref.csv
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ Date,command,TIMEHMS,574,"TIMEHMS hms| timer, BYREF h, BYREF m, BYREF s","Conver
Date,function,DATE,575,"DATE","Returns the current date as string ""DD/MM/YYYY""."
Date,function,DATEFMT,576,"DATEFMT (format, dmy| (d,m,y)| julian_date)","Returns formatted date string."
Date,function,JULIAN,577,"JULIAN (dmy| (d,m,y))","Returns the Julian date. (dates must be greater than 1/1/100 AD)."
Date,function,TICKS,1448,"TICKS","Returns the number of milliseconds that have elapsed between successive calls."
Date,function,TIME,578,"TIME","Returns the current time as string ""HH:MM:SS""."
Date,function,TIMER,1449,"TIMER","Returns the number of seconds from midnight."
Date,function,TIMESTAMP,1450,"TIMESTAMP filename","Returns the file last modified date and time."
Date,function,WEEKDAY,579,"WEEKDAY (dmy| (d,m,y)| julian_date)","Returns the day of the week (0 = Sunday)."
File,command,ACCESS,580,"ACCESS (file)","Returns the access rights of the file."
File,command,BLOAD,582,"BLOAD filename[, address]","Loads a specified memory image file into memory."
Expand All @@ -71,7 +74,6 @@ File,command,SEEK,597,"SEEK #fileN; pos","Sets file position for the next read/w
File,command,TLOAD,598,"TLOAD file, BYREF var [, type]","Loads a text file into array variable. Each text-line is an array element. type 0 = load into array (default), 1 = load into string."
File,command,TSAVE,599,"TSAVE file, var","Writes an array to a text file. Each array element is a text-line."
File,command,WRITE,600,"WRITE #fileN; var1 [, ...]","Store variables to a file as binary data."
File,function,ACCESS,601,"ACCESS (file)","Returns the access rights of the file."
File,function,BGETC,602,"BGETC (fileN)","Reads and returns a byte from file or device (Binary mode) ."
File,function,EOF,603,"EOF (fileN)","Returns true if the file pointer is at end of the file. For COMx and SOCL VFS returns true if the connection is broken."
File,function,EXIST,604,"EXIST (file)","Returns true if file exists."
Expand Down Expand Up @@ -106,6 +108,16 @@ Graphics,function,TXTW,634,"TXTW (s)","Returns the text width of string s in pix
Graphics,function,XPOS,635,"XPOS","Returns the current X position of the cursor in ""characters""."
Graphics,function,YPOS,636,"YPOS","Returns the current Y position of the cursor in ""characters""."
Language,command,CALL,637,"CALL (fp)","Invoke a sub or func by address pointer."
Language,command,THROW,1437,"THROW [info [, ...]]","The THROW command (previously known as RTE) is used to initiate a catch-able error. If there is no surrounding TRY/CATCH block, THROW can be used to abort the program."
Language,constant,COMMAND,1459,"COMMAND","SmallBASIC startup command line options."
Language,constant,CWD,1456,"CWD","Current working directory"
Language,constant,FALSE,1457,"FALSE","FALSE"
Language,constant,HOME,1458,"HOME","User HOME folder"
Language,constant,PI,1452,"PI","Holds PI"
Language,constant,SBVER,1451,"SBVER","Version and build information"
Language,constant,TRUE,1455,"TRUE","TRUE"
Language,constant,XMAX,1453,"XMAX","Holds the screen width in pixels"
Language,constant,YMAX,1454,"YMAX","Holds the screen height in pixels."
Language,function,IFF,638,"IFF expr","Inline version of IF. eg, animal = ""cat"": fur = IFF( animal = ""cat"", ""yes"", ""no""): ? fur"
Language,keyword,AS,1424,"AS #fileN","See: OPEN"
Language,keyword,BG,1428,"SOUND frq, dur [, vol] [BG]","Play sound in the background. This prevent the program from blocking while the sound plays."
Expand All @@ -120,12 +132,9 @@ Language,keyword,ELSE,644,"ELSE","foo = 2: if foo==1: ? ""one"": ELSE: ? ""not o
Language,keyword,ELSEIF,645,"ELSEIF","foo = 2: if foo==1: ? ""one"": ELSEIF foo==2: ? ""two"": fi"
Language,keyword,END TRY,1427,"END TRY","The END TRY statement marks the end of a TRY/CATCH block."
Language,keyword,ENDIF,646,"ENDIF","foo = 1: if foo==1: ? ""one"": ENDIF"
Language,keyword,EXEC,647,"EXEC file","Transfers control to another operating system program."
Language,keyword,EXIT,648,"EXIT [FOR|LOOP|SUB|FUNC]","Exits a multi line function definition, a loop, or a subprogram. By default (if no parameter is specified) exits from last command block (loop, for-loop or routine)."
Language,keyword,EXPORT,649,"EXPORT thing","Export a SUB, FUNC or variable from a UNIT to be used by the unit consumer."
Language,keyword,FI,650,"FI","Declares the end of an IF statement. Same as ENDIF."
Language,keyword,FUNC,651,"FUNC foo (a, b)","Declares a function. Return a value by assigning a 'variable' with the same name as the function."
Language,keyword,IMPORT,652,"IMPORT","Import an exported UNIT variable, SUB or FUNC."
Language,keyword,LOCAL,653,"LOCAL","Declare local variables inside a SUB or FUNC. Local variables no longer exist once the SUB or FUNC has returned."
Language,keyword,NEXT,654,"NEXT","See FOR."
Language,keyword,SELECT,655,"SELECT CASE expr","Perform multiple tests on the expression. Offers a more concise syntax to writing successive IF tests."
Expand All @@ -135,7 +144,6 @@ Language,keyword,SUB,657,"SUB foo (a, b)","Declare a sub procedure. Sub's do not
Language,keyword,THEN,658,"THEN","foo = 1: if foo==1 THEN: ? ""one"": fi"
Language,keyword,TO,1420,"FOR t = 1 TO 10","Specifies the loop counter end in a FOR loop"
Language,keyword,TRY,1425,"TRY","The TRY statement introduces a TRY/CATCH BLOCK"
Language,keyword,UNIT,659,"UNIT name","Units are a set of procedures, functions and/or variables that can be used by another program or unit."
Language,keyword,UNTIL,660,"UNTIL","a = 0: repeat: a++: ? a: UNTIL a = 10"
Language,keyword,USE,661,"USE","Used with various commands for passing a user-defined expression. eg SPLIT s,"" "",v USE TRIM(x). Trim each element of v."
Language,keyword,USG,1423,"PRINT USG","Synonym for USING"
Expand All @@ -144,7 +152,7 @@ Language,operator,AND,662,"a AND b","Logical AND. Right side is not evaluated if
Language,operator,BAND,663,"a BAND b","Bitwise AND."
Language,operator,BOR,664,"a BOR b","Bitwise OR."
Language,operator,EQV,665,"a EQV b","Bitwise equivalence."
Language,operator,IMP,666,"a IMP b","Bitwise IMP."
Language,operator,IMP,666,"a IMP b","Used to perform a logical implication on two expressions."
Language,operator,IN,667,"a IN b","Returns an index (1 Based) to the matching element when b is an array. Returns TRUE if the value is contained within b as a string."
Language,operator,LIKE,668,"a LIKE b","Regular-expression operator. Compares the left part of the expression with the right side regex pattern."
Language,operator,MDL,669,"MDL","Modulus."
Expand All @@ -155,7 +163,6 @@ Language,operator,NOT,673,"a NOT b","Invert expression result. Equivalent syntax
Language,operator,OR,674,"a OR b","Logical OR. Right side is not evaluated if left side evaluates to True."
Language,operator,XNOR,675,"a XNOR b","Bitwise exclusive NOT OR."
Language,operator,XOR,676,"a XOR b","Bitwise exclusive OR. Equivalent syntax to: a ~ b"
Language,statement,CHAIN,677,"CHAIN source","Compile and run the given source. Source can be a file name, a line of code or an array of code. Use ENV to share variables with the parent process."
Language,statement,CONST,678,"CONST name = expr","Declare a variable who's value does not change during program execution."
Language,statement,END,679,"END","Declares the END of a SUB or FUNC."
Language,statement,FOR,680,"FOR expr","Defines a FOR/NEXT loop. FOR counter = start TO end [STEP incr] ... NEXT. FOR element IN array (or map) ... NEXT."
Expand All @@ -165,7 +172,6 @@ Language,statement,IF,683,"IF expr","Tests the expression and IF it evaluates to
Language,statement,LABEL,684,"LABEL name","Defines a label. A label marks a position in the code."
Language,statement,LET,685,"LET var=expr","Assigns a value to the variable."
Language,statement,ON,686,"ON GOTO|GOSUB label1 [, ..., labelN]","Causes a branch to one of a list of labels."
Language,statement,OPTION,687,"OPTION keyword","Used to pass parameters to the run-time environment."
Language,statement,REM,688,"REM comment","Code comments. Comments can also be introduced using # and single quote character. "
Language,statement,REPEAT,689,"REPEAT ... UNTIL expr","Begins the definition of a REPEAT/UNTIL loop."
Language,statement,RETURN,690,"RETURN","Execution branches to the command immediately following the most recent GOSUB command."
Expand Down Expand Up @@ -286,18 +292,19 @@ String,function,UCASE,803,"UCASE (s)","Converts the string s to upper case."
String,function,UPPER,804,"UPPER (s)","Converts the string s to upper case."
String,function,VAL,805,"VAL (s)","Returns the numeric value of string s."
System,command,DELAY,806,"DELAY ms","Delay for a specified amount of milliseconds. Note 'delay' depends on the system clock."
System,command,ENV,807,"ENV expr","See ENVIRON."
System,command,ENVIRON,808,"ENVIRON expr","Adds a variable to or deletes a variable from the current environment variable-table."
System,command,ENV,807,"ENV expr","Adds a variable to or deletes a variable from the current environment variable-table."
System,command,PAUSE,809,"PAUSE [secs]","Pauses the execution for a specified length of time, or until user hit the keyboard."
System,command,RANDOMIZE,810,"RANDOMIZE [int]","Seeds the random number generator."
System,command,STKDUMP,812,"STKDUMP","Display internal execution stack."
System,command,THROW,811,"THROW [info [, ...]]","The THROW command (previously known as RTE) is used to initiate a catch-able error. If there is no surrounding TRY/CATCH block, THROW can be used to abort the program."
System,command,TROFF,813,"TROFF","See TRON."
System,command,TRON,814,"TRON","When trace mechanism is ON, displays each line number as the program is executed."
System,function,ENV,815,"ENV expr","See ENVIRON."
System,function,ENVIRON,816,"ENVIRON expr","Returns the value of a specified entry in the current environment table. If the parameter is empty ("""") then returns an array of the environment variables (in var=value form)."
System,function,ENV,815,"ENV expr","Returns the value of a specified entry in the current environment table. If the parameter is empty ("""") then returns an array of the environment variables (in var=value form)."
System,function,FRE,606,"FRE (x)","Returns system information. eg, 0 = free memory, "
System,function,PROGLINE,817,"PROGLINE","Returns the current program line number."
System,function,RUN,818,"RUN cmdstr","Loads a secondary copy of system's shell and, executes an program, or an shell command."
System,function,TICKS,819,"TICKS","Returns the number of milliseconds that have elapsed between successive calls."
System,function,TIMER,821,"TIMER","Returns the number of seconds from midnight."
System,keyword,EXEC,1443,"EXEC file","Transfers control to another operating system program."
System,keyword,EXPORT,1440,"EXPORT thing","Export a SUB, FUNC or variable from a UNIT to be used by the unit consumer."
System,keyword,IMPORT,1441,"IMPORT","Import an exported UNIT variable, SUB or FUNC."
System,keyword,UNIT,1446,"UNIT name","Declares the source module as a unit. Units are a set of procedures, functions and/or variables that can be used by another program or unit."
System,statement,CHAIN,1439,"CHAIN source","Compile and run the given source. Source can be a file name, a line of code or an array of code. Use ENV to share variables with the parent process."
System,statement,OPTION,1442,"OPTION keyword","Used to pass parameters to the run-time environment."
Loading