own Commands in GLBasic?

Previous topic - Next topic

erico

Quote from: Leon on 2015-Oct-21
Wow! Pretty good idea. :)
But that's really hard to achieve (at least for me  :( )

Maybe not, you could focus on the parsing of text and the function populating alone and use the likes of a notepad for the editor.
You could also output GLB equivalent to another text file, then you copy and paste into the glb ide and compile.
You can later take a look on the extras.

Matchy once did a painter in GLB that outputs trs-80 color basic code, that then you would copy and paste to an emulator, or type on the real machine, and the image would pop up. :good:

You may want to check this thread:
http://www.glbasic.com/forum/index.php?topic=9675.105

MrPlow

 :happy: Never knew this was coming and so popular :)

Just finishing off my book of basic games for Sinclair BASIC. :)

Maybe a script in a text editor could reformat the code with function brackets

If <command> is found then replace first <space> with ( and append ) to end of line.

Or something like that...not familiar with the smile syntax myself - used petite a few times.


Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

matchy

As erico kindly mentioned, it's very useful to create utilities to just produce code for classic 80s BASIC. There was a cool BBC interpreter and maybe some Turtle Logo I've seen on the board. The idea of cutting old code, parsing it and having it run sounds real cool, even if you covert/translate/invent your own terms.

Anyhow, I'm going to try an answer the question in the most practical way if precise commands aren't required. To replace DRAWRECT and reduce the parameter parsing efficiency, I use my own type class

Code (glbasic) Select

rect.draw()


Here is an example.

Code (glbasic) Select


TYPE _rect
x
y
width
height
color
texture
FUNCTION draw:
IF self.texture <> -1
STRETCHSPRITE self.texture, self.x, self.y, self.width, self.height
ELSE
DRAWRECT self.x, self.y, self.width, self.height, self.color
ENDIF
ENDFUNCTION
ENDTYPE

TYPE _scene
rect AS _rect
FUNCTION begin:
self.rect.x = 10
self.rect.y = 20
self.rect.width = 30
self.rect.height = 40
self.rect.color = 0xff0000
self.rect.texture = -1
WHILE TRUE
CLEARSCREEN
self.rect.y = 20
INC self.rect.y, SIN(GETTIMERALL()) * 10
self.rect.draw()
SHOWSCREEN
WEND
ENDFUNCTION
ENDTYPE

GLOBAL scene AS _scene
scene.begin()


Leon

Quote from: erico on 2015-Oct-21
Quote from: Leon on 2015-Oct-21
Wow! Pretty good idea. :)
But that's really hard to achieve (at least for me  :( )

Maybe not, you could focus on the parsing of text and the function populating alone and use the likes of a notepad for the editor.
You could also output GLB equivalent to another text file, then you copy and paste into the glb ide and compile.
You can later take a look on the extras.

Matchy once did a painter in GLB that outputs trs-80 color basic code, that then you would copy and paste to an emulator, or type on the real machine, and the image would pop up. :good:

You may want to check this thread:
http://www.glbasic.com/forum/index.php?topic=9675.105


Good idea but I have never written a parser or read a tutorial about it so I don't even know how to program a parser :(
Could somebody explain me how a parser works? I know what it does (at least I think I do  ;/)

matchy


Could somebody explain me how a parser works?
[/quote]

Simply, how about a classic text adventure because it's more fun? For example, LOOK SHELF, GET BOOK, GO UP. Split those two words combo (verb and noun) and processes them with select cases!

erico

Wiki has some good answers.
https://en.wikipedia.org/wiki/Parsing

But to simplify, it means to analyse text.
I think the most simple way to experience it, is with what Matchy just proposed, do a text adventure (Interactive Ficction).