What is fbs

FBS (freeBASIC script) is an interpreter for FbCadCam macros and a server side script engine.

Moderators: kitty_webb, Ywsp, joanCruz03, yajra1219, Jayem, shela

Post Reply
owen
Site Admin
Posts: 642
Joined: Thu Apr 13, 2017 12:14 pm

What is fbs

Post by owen » Sat Aug 24, 2019 7:19 am

FBS is fbcadcam macro WITHOUT fbcadcam functions.
It is a very basic script engine with NEAR FB syntax.
note: fbs only understands a small portion of the freeBASIC language.

Currently i am busy modifying fbs in order to use it as my own server side script engine. see this post viewtopic.php?f=19&t=426

Here is a link to the original commands fbs understands. Scroll about half way down this page.
http://fbcadcam.com/fbcadcam_users_guide.html

owen
Site Admin
Posts: 642
Joined: Thu Apr 13, 2017 12:14 pm

Re: What is fbs

Post by owen » Sat Sep 21, 2019 3:53 am

Writing fbcadcam_macro (now called fbs {my own freeBASIC script interpreter} ) has been and still is quite the adventure.

Originally the interpreter was written for fbcadcam in order to draw programmatically in fbcadcam similar to the idea of autocad's LISP feature to draw programmatically in AutoCAD.

At the core of the interpreter (the bare bones functionality) is a very basic BASIC with commands such as: Dim, For Next, Do Loop, Print, etc...
For example these commands would be used something like this:
DIM AS INTEGER k
DIM AS STRING my_string
my_string="hello world"
For k=1 to 10
Print k, my_string
Next

In order to draw programmatically in fbcadcam I needed the Interpreter to be able to understand the basic commands and variable types integer and double and a few operators like +-×÷. After a couple months of working on this idea I achieved my goal but there were many bugs. Overtime I would test it and fix it and add more functionality such as arrays and strings and a full set of all the standard variable types in the freeBASIC language such as BOOLEAN, BYTE, UBYTE, etc... and all the operators and math functions such as TAN, SIN, COS, etc...
Once I created the Bare Bones basics of the Interpreter I then added drawing commands like LINE and CIRCLE along with commands that were specific to fbcadcam like copy rotate flip horizontal etc... and like always I would test it find errors fix it and keep on adding to it.

Once this was completed I was able to draw programmatically like this:

DIM AS INTEGER ×1,y1,x2,y2,k
X1=0
Y1=0
For k=10 to 100 step 10
X2=k*2
Y2=k
Line(x1,y1)-(x2,y2)
Next

Once those 10 lines were drawn after running the script you could then edit them in the drawing just as if you were to have drawn them manually using fbcadcam's drawing tools.

It turned out to be a pretty cool thing. But even with all of the work that I put into it is nothing in comparison to autocad's macro system. Of course the same could be said about fbcadcam itself. My program is just a hobby and nothing close to AutoCAD and other cad/cam software. I wrote it and I continue to work on it because it is fun for me.

And to this day I'm still working on my interpreter which I am now using as my own server-side script engine. Just like before the whole way in this Great Adventure I am finding bugs and fixing them and adding more and more to it.

Post Reply