Page 1 of 2

Compound Basic - Beta 0.2.51

Posted: Sun Aug 14, 2005 12:54 am
by Killswitch
Over the summer I have been working on creating a new BASIC language in PureBasic, I had a fair bit of success and have decided to open the beta to everyone. This release is the last in the current generation of CB interpreters, I've decided to rewrite the whole thing from scratch (removing a lot of bugs) and develop a PB scripting language parrallel to it.

There is help file included which deals with all of the commands in CB, but there are a few things I did not get round to writing about.

Maths

Math statements must be followed by a ';'. Conditions do not have to be followed by a ';'

Code: Select all

  Bob.l=1+2;
Comments

A line must start with a ' to be consider a comment

Code: Select all

  'This is a comment
  Len(String.s) 'This is an error
Declaring Variables

Use either:

Code: Select all

  Bob.l
  Bob.s
  Bob.f 

Code: Select all

DEF Bob, Jim, Tim ~ Using defualt type (Long)
Def.[l,s,f] Bob, Jim, Tim ~ Using specified type
"IFs"

Code: Select all

  IF <Condition> THEN <Action>
  If Bob=1 THEN Bob=2;
Loops

Only 'while' or 'do' loops are considered

Code: Select all

  While Bob=1
    'Code
  Wend

  Do
    'Loops forever
  Loop

  Do
    'Loops until condition is true 
  Until Bob=1
Operators

Supported operators:

Code: Select all

  =
  +
  -
  (
  )
  *
  /
  <
  >
  <>
  >=
  <=
  AND
  OR
  ^
Debug

Use either:

Code: Select all

  Debug Len("a")
  Debug 1+2;

  Output Len("a")
  Output 1+2;
Note: 'Output' and 'Debug' are exactly the same - I just wasn't sure which keyword I should use, so I included both. Which do you prefer?

Commands

Use commands in exactly the same way as in PureBasic (read a bit further down to see why this is). CB even supports nested commands. You can have maths expressions as arguments but you cannot perform maths operations directly on command calls

Code: Select all

  Len("1")
  
  Bob.l = Len("1")
  
  Bob.l = Len(Mid(Left("abcd",2),1,1))

  Bob.l = Mid(Left("abcd",1+1),1,1)

  Bob.l = Mid(Left("abcd",1)+"a",1,1) WRONG  

Download 0.2.264

If you have any questions, suggestions or comments then either email me at evil_grunger@hotmail.com or post here!

Edit: Extended the explination a little bit.

Posted: Sun Aug 14, 2005 4:16 am
by dracflamloc
Sounds good. Open source it or cross-platform lib it and you may get some users...

Posted: Sun Aug 14, 2005 4:48 am
by Fou-Lu
Do and Loop? Have you being playing with darkbasic?

It seems good though, you could develop a simple language for beginners! :wink:

And if you plan to implement graphics, you could do it so that there's no StartDrawing() and Start3D(). It would be slower, but someone who is just starting to code would find it easier. :)

Oops, here I go with a wishlist... :oops: Sorry!

Posted: Sun Aug 14, 2005 9:28 am
by thefool
@Fou-lu: The most popular dos basic, quickbasic, wich was long time before darkbasic used that Do-Loop ;) also visual basic. And other basics too! i think its a rather good choise, also if he chose repeat-until the syntax would be closer to purebasic wich is probably not intended!

@killswitch: still looks rather nice :) however too close in syntax to pureb but we have talked about that [you better mention it here before people begin to complain]. okay in debugger the "filename" line is still only 50% from top to bottom, so half of it is covered.

Posted: Sun Aug 14, 2005 1:28 pm
by Killswitch
Theres a few reasons why the syntax is very similar to PureBasics. Firstly it allows for a benchmark for the the commands, so I can check that my commands work correctly. Secondly it means that the majority of the code will be highlighted and look pretty in the PB editor. Thirdly its quite hard to develop a new language (when your new to developing languages) and a brand new syntax. I will be creating a more unquie syntax when I rewrite the code.

I am not going to make the language open source, it'd just mean that we'd get a load of copy cat languages that have sliglty different key words. The scripting language will be in the form of a user library, and I will probally write some tutorials on how to make similar interpreters if anybody would like them (if you would like it then tell me). I am going to release a seperate userlibrary, consiting of two commands which allow people to solve complex maths equations from within their programs.

Posted: Sun Aug 14, 2005 1:50 pm
by thefool
@killswitch: Even though i probably would be able to write a smaller scripting language i wouldnt mind if you made some tutorials on writing interpretters. in fact that would be nice!

Also if it will be in form of a lib, that would be nice.!

Posted: Sun Aug 14, 2005 2:34 pm
by Killswitch
If what was in the form of a lib? :shock:

Posted: Sun Aug 14, 2005 3:07 pm
by dracflamloc
The interpreter, so it could be included in other people's projects.

Also I might add that its not illegal to create a programming language that looks like another language.

Posted: Sun Aug 14, 2005 3:25 pm
by thefool
Yes the scripting language :)
however i wonder how one could make it work with ones own app.
you must include some functions so the app can send data to the script
and receive data again!

@bout the "legal to copy":
no of course it is not unlegal! i just wanted him to point out that it is not just wrapping of pb commands even though they are pretty equal in the syntax! he wrote them in either winapi and some with more complex pb code.

Posted: Sun Aug 14, 2005 3:44 pm
by dracflamloc
He should have a way to integrate into another persons app. The one I'm working on atm does.

Posted: Sun Aug 14, 2005 4:38 pm
by thefool
exactly

Posted: Sun Aug 14, 2005 5:04 pm
by Fou-Lu
thefool wrote:@Fou-lu: The most popular dos basic, quickbasic, wich was long time before darkbasic used that Do-Loop ;) also visual basic. And other basics too! i think its a rather good choise, also if he chose repeat-until the syntax would be closer to purebasic wich is probably not intended!
Oh, I didn't know that yet. :oops: Thanks thefool! :wink:
And I was thinking it was a good idea for DB... sometimes I'm so dummy... :roll:

Posted: Sun Aug 14, 2005 5:07 pm
by thefool
oh well if you never used quickbasic you couldnt know that :)

Posted: Sun Aug 14, 2005 6:38 pm
by Killswitch
I did think of a solution to the script/app comminication. Basically there would be an array within the app in which you can define 'statuses' (I'm trying to think of a better name for them). Basically they work like a name attached to a space for data:

Code: Select all

  
  ;CreateStatus(Type.l,Name.s)
  CreateStatus(#Monocle_Type_Long,"Killswitchs Data")
  
  ;SetStatusData(Name.s,Long.l,Float.f,String.s)
  SetStatusData("Killswitchs Data",1,Float.d,String.s)
  
  ;GetStatusData(Name.s,Type.l)
  String.s=GetStatusData("Killswitchs Data",#Monocle_Type_Long)
  
Then the status can be used within the scripting language like constants:

Code: Select all

  
  Debug &Killswitches Data  

What do you think?

Posted: Sun Aug 14, 2005 6:46 pm
by thefool
it is definently a way to do it, yeah. however i think there will be the need for more comunication between the script and the main app.