I found this version of Basic (Linux AMD64 only) while pottering around:
https://sourceforge.net/projects/buraph ... l%20BASIC/
I'll try it out later.
I am getting interest in Lua just for a change of scene. I'm using these things:
http://www.hamady.org/comet.html
http://www.amulet.xyz/
The idea is to use the low level capabilities of FreeBasic to write cmodules for Lua or, for certain multi-threaded applications to communicate between Lua and FreeBasic via the nanomsg message sharing library.
Combining a simple high level scripting language with simple lower level programming seems like a good idea to me. You are taking out all the mid-level verbosity in terms of unnecessary typing (as in both Types and click, click, click). You can structure your code at a high level while still being able to run sort algorithms etc. at full native speed.
Mutant version of Basic
Re: Mutant version of Basic
That version of Basic worked well. It was great to see line numbers again, for nostalgic reasons. If you had that version of Basic in 1986 running at that speed you would have been the owner of the most powerful and programmable supercomputer on the planet.
There is a lot to be said for keeping things as simple as possible. If you threw in nanomsg with that you could actually do some real work running server side code.
There is a lot to be said for keeping things as simple as possible. If you threw in nanomsg with that you could actually do some real work running server side code.
Re: Mutant version of Basic
A while back member RockTheSchock showed an example using Lua script with Freebasic.
The Library is at:
https://sourceforge.net/projects/fbc/f ... ibraries/
(32 bit compiler).
Free basic has all the .bi files.
Here is the example, I added some code as a small demo (of the Lua string parser).
He also mentioned a sandbox method which simplified things a bit, but I didn't get round to testing it out.
The Library is at:
https://sourceforge.net/projects/fbc/f ... ibraries/
(32 bit compiler).
Free basic has all the .bi files.
Here is the example, I added some code as a small demo (of the Lua string parser).
Code: Select all
#Include Once "Lua/lua.bi"
#Include Once "Lua/lauxlib.bi"
#Include Once "Lua/lualib.bi"
Function Eval(ByVal Expression As String,StringVariable As String,DoubleVariable As Double) As Double
static as string funclast,func
static Lua As lua_State Ptr
if funclast<>expression then
lua=luaL_newstate
luaL_openlibs(Lua)
func = "function " + "f" +"("+StringVariable+")" +Chr(13)+Chr(10) _
+ " return " + Expression +Chr(13)+Chr(10) _
+ "end"
Print func:print
If luaL_dostring(Lua,func) Then
PRINT "Error: " & *lua_tostring(Lua, -1),__LINE__
sleep
EndIf
EndIf
funclast=expression
lua_getglobal(Lua, "f")
lua_pushnumber(Lua, DoubleVariable)
IF lua_pcall(Lua, 1, 1, 0) Then
Print "Error: " & *lua_tostring(Lua, -1),__LINE__
sleep
EndIf
Eval = lua_tonumber(Lua, -1)
lua_pop(Lua, 1)
End Function
'================================================================
#define map(a,b,x,c,d) ((d)-(c))*((x)-(a))/((b)-(a))+(c)
dim as integer w,h
screeninfo w,h
screenres w,h
Width ,h\16 'make the font slightly larger
dim as string fn
dim as single lx,hx,ly,hy
dim as integer xval,yval
dim as integer count
do
count=0
read fn
if fn="end" then exit do
read lx
read hx
read ly
read hy
cls
'================== the vewing box =============
line(.1*w,.1*h)-(.9*w,.9*h),,bf
draw string(.1*w,.5*h),str(lx),5
draw string(.9*w-20,.5*h),str(hx),5
draw string(.5*w,.1*h),str(hy),5
draw string(.5*w,.9*h-20),str(ly),5
draw string(.45*w,.1*h+20),fn,0
'===============================================
'plotter
for x as single=lx to hx step (hx-lx)/1000
count+=1
var value=eval(fn,"x",x)
xval=map(lx,hx,x,.1*w,.9*w)
yval=map(hy,ly,value,.1*h,.9*h)'cartesian
if count=1 then
pset(xval,yval),0
else
line -(xval,yval),0
end if
next x
sleep
loop until inkey=chr(27)
locate 2,2
print "Done"
sleep
const pi=4*atn(1)
'data function(in x),lowerX,upperX,lowerY,upperY (cartesian co-ordinates)
data "math.sin(x)",-10,10,-1.5,1.5
data "math.cos(x)",0,2*pi,-2,2
data "x^2",-5,5,0,25
data "math.sin(x)/x",-20,20,-1,2
data "3*math.sin(3*x)+2*math.cos(2*x)+math.sin(x)",-5,5,-10,10
data "(((((-2*x+5)*x)+7)*x-3)*x+9)+3",-5,5,-100,100
data "2*math.random()-2*math.random()",0,8,-2,2
data "1/math.exp(x^2)",-3,3,-1.5,1.5
data "1/(1+x^2)",-3,3,-1.5,1.5
data "end"
'_END
Re: Mutant version of Basic
Thanks for the code. I'll try it out.
Re: Mutant version of Basic
That worked fine with a static link to liblua.a (Lua 5.3.3) and the .bi files included with FB.
Re: Mutant version of Basic
nice lua demo, compiles and runs ok both in 32 and 64 bit.
Re: Mutant version of Basic
Haven't done anything with this in years and it's a bit of a mess, but at one time this was a working Lua interpreter with access to many of FB's functions:
http://www.filedropper.com/fblua
http://www.filedropper.com/fblua
Re: Mutant version of Basic
If Amulet is open source then it could provide FB with an easy graphics update.