Author Topic: Lisp in Basic  (Read 208230 times)

0 Members and 4 Guests are viewing this topic.

JRS

  • Guest
Re: Lisp in Basic
« Reply #315 on: August 10, 2014, 09:55:24 AM »
Strange that the SWAP function isn't documented. Here is what I was able to find in the source. Pay special attention to the point of REF and it using the real variable and not the reference to it. If not using REF, just ignore my warning.

Code: [Select]
This command swaps two variables.

*/
COMMAND(SWAP)
#if NOTIMP_SWAP
NOTIMPLEMENTED;
#else
  LEFTVALUE VariableA,VariableB;
  pFixSizeMemoryObject VSWAP;
  long refcount;

  /* we get the pointer to the variable that points to the value */
  VariableA = EVALUATELEFTVALUE(PARAMETERNODE);
  ASSERTOKE;

  /* if this points to a reference value then we search the "real" variable
     to modify */
  DEREFERENCE(VariableA);

  /* get the next parameter of the command, which is the other variable */
  NEXTPARAMETER;

  /* we get the pointer to the variable that points to the value */
  VariableB = EVALUATELEFTVALUE(PARAMETERNODE);
  ASSERTOKE;

  /* if this points to a reference value then we search the "real" variable
     to modify */
  DEREFERENCE(VariableB);

  VSWAP = *VariableA;
  *VariableA = *VariableB;
  *VariableB = VSWAP;

#endif
END

I don't have a non-multi-threaded version of scriba.exe compiled nor have I created one in the past. I will work on  this as I'm also interested in the performance difference if SB is compiled as a single threaded process. (no MyAlloc routines used)

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #316 on: August 10, 2014, 10:16:28 AM »
Thanks John,

This information on SWAP() will largely suffice. I was wondering what it would do if the arguments were arrays. FBSL SWAP() would swap array pointers. Now I know that SB SWAP() would do the same. It enables me to split the SB arrays in the exact same programmatic way as I did in FBSL.

I would greatly appreciate your effort to recompile SB without multithreaded support. Just let me know when or if you have secceeded. This won't however slow down or suspend my current research plan.

JRS

  • Guest
Re: Lisp in Basic
« Reply #317 on: August 10, 2014, 10:27:08 AM »
Here are the Script BASIC keywords as defined in the code. Some aren't implemented and others undocumented but in either case they shouldn't be used as variable names.

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

JRS

  • Guest
Re: Lisp in Basic
« Reply #318 on: August 10, 2014, 10:41:30 AM »
Code: [Select]
' Mike's SWAP array test

a[0]=0
a[1]=1
a[2]=2

b[0]=2
b[1]=1
b[2]=0

SWAP a, b

PRINT a[0],"\n"
PRINT a[1],"\n"
PRINT a[2],"\n"

jrs@laptop:~/sb/sb22/sblisp$ scriba swaparray.sb
2
1
2
jrs@laptop:~/sb/sb22/sblisp$

Code: [Select]
a = 1
b = 2

SWAP a, b

PRINT "A: ",a,"\n"
PRINT "B: ",b,"\n"

jrs@laptop:~/sb/sb22/sblisp$ scriba testswap.sb
A: 2
B: 1
jrs@laptop:~/sb/sb22/sblisp$

« Last Edit: August 10, 2014, 10:49:11 AM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #319 on: August 10, 2014, 11:08:51 AM »
Grrrrrrr, yeah I've bumped into that already. >:(

Another easy alternative would be if SWAP() would swap correctly the pointers stored in two REF variables that refer to (alias) the both arrays... But something's telling me it wouldn't... :-\

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #320 on: August 10, 2014, 11:33:59 AM »
Wrong! It would! :)

Code: [Select]
a[0]=0
a[1]=1
a[2]=2

b[0]=2
b[1]=1
b[2]=0

PRINT "------------\n"
PRINT a[0]," ",a[1]," ",a[2],"\n"
PRINT "------------\n"
PRINT b[0]," ",b[1]," ",b[2],"\n"
PRINT "------------\n"

ref c = a
ref d = b

SWAP c, d

PRINT a[0]," ",a[1]," ",a[2],"\n"
PRINT "------------\n"
PRINT b[0]," ",b[1]," ",b[2],"\n"
PRINT "------------\n"

.

JRS

  • Guest
Re: Lisp in Basic
« Reply #321 on: August 10, 2014, 11:38:23 AM »
SB is full of surprises and the best part is I haven't run into any limitations yet that would prevent me from continuing using it.


Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #322 on: August 10, 2014, 11:51:47 AM »
You don't have to put up your defences, John. Nobody's on the offensive side here. This isn't the FreeBASIC forum after all.

JRS

  • Guest
Re: Lisp in Basic
« Reply #323 on: August 10, 2014, 12:03:13 PM »
No defenses intended. SB speaks for itself. I was just expressing my personal experience with the language.,

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #324 on: August 10, 2014, 12:24:21 PM »
Every single BASIC-er around the globe knows your attitudes. No need to repeat yourself over and over again. So let's consider this matter settled once and for all at least between us two, OK?

Now please tell me if there's any way for SB to load an STDCALL function directly from a Windows stock DLL without writing a wrapper for it?

JRS

  • Guest
Re: Lisp in Basic
« Reply #325 on: August 10, 2014, 12:40:45 PM »
Quote
No need to repeat yourself over and over again.

Great! Mike says the SB house isn't haunted and there are no ghosts. Peter Verhas truly is the hero here.

You have two choices. DYC (Peter's simple FFI) or Charles's DLLC which is FFI + on steroids. Both are 32 bit Windows only extension modules.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #326 on: August 10, 2014, 12:49:00 PM »
Peter Verhas truly is the hero here.

Under your wakeful eye, John.

Where do I find this DLLC wonder, please?

JRS

  • Guest
Re: Lisp in Basic
« Reply #327 on: August 10, 2014, 01:06:52 PM »
DLLC is part of the OxygenBasic WIP ZIP builds. See projectB\ScriptBasic.

I will put my Windows SB 2.2 source on the server for you to download. I will send you the link via a PM. I don't want pre-released SB 2.2 source floating around. The available 2.1 source would work fine but I'll send you current as you're a BASIC developer.

« Last Edit: August 10, 2014, 02:33:22 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #328 on: August 10, 2014, 01:17:06 PM »
Oh, you're so very kind John.

And, er, actually I am the BASIC developer. ;)
« Last Edit: August 10, 2014, 03:23:35 PM by Mike Lobanovsky »

JRS

  • Guest
Re: Lisp in Basic
« Reply #329 on: August 10, 2014, 04:01:18 PM »
Quote
And, er, actually I am the BASIC developer.

Are you saying that FBSL is now you're baby? (single developer effort)