PDA

View Full Version : C Basic



kryton9
24-10-2013, 04:45
Eros, Petr and other PowerBasic gurus here is an update to a project that could use your help. With your guy's extensive PB code, you could run it through and post recommendations. I think this a worthy project for the future of your huge code base.

Look here first:
http://www.ucalc.com/transform.html

Then here:
https://github.com/uCalc/powerbasic-to-cpp

On another totally different front there is a new language that many of us are falling for. Take your time and give it a few days, you will see why it is very unique and could be the one language that does it all.
I found the irc chat room very helpful and friendly also for things I got stuck on.
http://nimrod-code.org/

Also John has put together a lot of translator tools on his site in a nice organized manner. In addition, some experimental Basic to Nimrod tests here:
http://www.allbasic.info/forum/index.php?board=4.0

kryton9
30-10-2013, 02:30
Wow that has come along so quickly and looks great. Thanks for the update John and thanks to Charles.

ErosOlmi
30-10-2013, 08:12
Can you please drive me into the right direction?
Where can I get C BASIC in order to test it?

Thanks
Eros

Charles Pegge
30-10-2013, 10:25
Hi Eros,

This language was invented a few days ago :D

And we think it has legs. Especially for BASIC programmers who want or need to go mainstream and make the transition to C. We are using GCC.

In it's simplest form, it is this small list of #defines, which can be used to write native C code that looks like BASIC.

The greater challenge is how to deal with dynamic strings, and other objects, which have always been integral to BASIC. I am currently writing a dynamic string library. It works in a similar way to Patrice's VC10 strings.



#define function
#define method
#define gosub
#define dim
#define as
#define to
#define limit
#define step
#define then
#define procedure void
#define sub void
#define begin {
#define end }
#define and &&
#define or ||
#define class typedef struct
#define types typedef struct
#define member ->
#define addressof &
#define has =
#define incr ++
#define decr --
#define next ++
#define prior --
#define byref *
#define ref void*
#define references = &
#define FreeSpace free


#define FUNCTION
#define BEGIN_FUNCTION {
#define END_FUNCTION }
#define SUB void
#define BEGIN_SUB {
#define END_SUB }
#define RETURN return
#define CALL
#define AND &&
#define OR ||
#define MOD %
#define DIM
#define AS
#define LET
#define INCR ++
#define DECR --
#define IF if
#define BEGIN_IF {
#define THEN {
#define THEN_DO
#define ELSE } else {
#define END_IF }
#define FOR for
#define TO ;
#define STEP ;
#define BEGIN_FOR {
#define NEXT }
#define SELECT_CASE switch
#define BEGIN_SELECT {
#define CASE case
#define _TO_ ...
#define END_CASE break;
#define CASE_ELSE default:
#define END_SELECT }
#define DO do {
#define WHILE } while



http://www.allbasic.info/forum/index.php?topic=256 (http://www.allbasic.info/forum/index.php?topic=256)

ErosOlmi
30-10-2013, 14:59
Ok, got the idea of macro usage.

Interesting for a quick and dirty migration/testing.
As soon as I will have some time I will try to make a thinBasic module where no or very few strings are involved.

Thanks a lot.
Eros

Charles Pegge
31-10-2013, 00:29
I'm testing out some dynamic string functions:



types StringClassTableStruct
begin
method StringObject (byref Redim) (StringObject*pthis, int n, int wi, int cnt);
method StringObject (byref Get) (StringObject*r, StringObject this);
method StringObject (byref Set) (StringObject*pthis, StringObject s);
method char* (byref GetChars)(char**r, StringObject this, int wi);
method StringObject (byref SetChars)(StringObject*pthis, char*c, int le, int wi);
method StringObject (byref GetMid) (StringObject*r, StringObject this, int s, int le, int wi);
method StringObject (byref SetMid) (StringObject*pthis, StringObject s, int i);
method StringObject (byref Join) (StringObject*pthis, int n,...);
method StringObject (byref Ucase) (StringObject*r, StringObject this);
method StringObject (byref Lcase) (StringObject*r, StringObject this);
method StringObject (byref Ltrim) (StringObject*r, StringObject this);
method StringObject (byref Rtrim) (StringObject*r, StringObject this);
method StringObject (byref Insert) (StringObject*pthis, StringObject s, int i);
method StringObject (byref Delete) (StringObject*pthis, int i, int le);
method StringObject (byref Chr) (StringObject*r, int a, int wi);
method StringObject (byref Str) (StringObject*r, double d);
method int (byref Show) (StringObject this);
method int (byref Asc) (StringObject this, int i); // also supports wide chars
method int (byref Instr) (int i, StringObject this, StringObject k);
method double (byref Val) (StringObject this);
end
StringClassTable,*StringMethods;