Huge BASIC programs
Dr_Acula
Posts: 5,484
Someone on another thread mentioned adding Spin to the SimpleIDE. I've got another idea - how about adding Basic?
I've written my own IDE for this and so have ironed out a lot of bugs. But it is written in vb.net and vb.net has a bug that does a DTR pulse when you open a port. It is a recognised bug (the pulse is 100ms) and it means I can't replicate SimpleIDE's feature of opening the debug terminal after download.
But maybe it is not so hard to add this to SimpleIDE.
Start with this simple BCX demo (http://www.bcxgurus.com/)
Technically this is not Basic as it has C #includes. However, having these at the beginning is a terribly convenient way of adding libraries, and hopefully this one 'feature' won't upset Basic users too much. Actually the real reason it is done this way is as a workaround to the way BCX is designed by default to work with Windows. Start with this even simpler demo program
and the output from BCX is this
And you can see there are a lot of #includes that are not going to be relevant to the propeller. So we do some simple text editing. Go back to the original program
Step 1) Search for all lines starting with #include and store these lines in a text file INCLUDE.TXT
Step 2) Run the file through BCX
Step 3) Go through the output file searching for "// End of Object/Import Libraries To Search" and discard all lines above this, this line and two lines after this.
Step 4) Paste INCLUDE.TXT at the beginning of the file
Step 5) Then add this C code
Which compiles and runs from SimpleIDE.
This can all be done from a simple command line program. Input a .bas file, output a .c file. I could write that program in vb.net or something simpler. It is less than 50 lines of code.
From SimpleIDE's perspective, the basic code could be in one tab (the C syntax highlighting is not bad for Basic either) and maybe you could have one line at the beginning of all Basic programs that starts with BASIC or something, and if SimpleIDE finds that, it goes off and shells a batch program, waits for the batch program to finish, puts the new C code in another tab, then compiles and downloads that C code. If the whole BCX compiler was only activated when it found the word "BASIC" at the top of the program, it would be hidden to C users and there would be no new buttons or anything in SimpleIDE that would be different to how it looks now. So it stays "simple", (ie uncluttered).
Is this something that we could think about porting over from vb.net into SimpleIDE?
I've written my own IDE for this and so have ironed out a lot of bugs. But it is written in vb.net and vb.net has a bug that does a DTR pulse when you open a port. It is a recognised bug (the pulse is 100ms) and it means I can't replicate SimpleIDE's feature of opening the debug terminal after download.
But maybe it is not so hard to add this to SimpleIDE.
Start with this simple BCX demo (http://www.bcxgurus.com/)
#include <stdio.h> #include <propeller.h> Print "Hello World"
Technically this is not Basic as it has C #includes. However, having these at the beginning is a terribly convenient way of adding libraries, and hopefully this one 'feature' won't upset Basic users too much. Actually the real reason it is done this way is as a workaround to the way BCX is designed by default to work with Windows. Start with this even simpler demo program
Print "Hello World"
and the output from BCX is this
// ********************************************************************* // Created with BCX32 - BASIC To C/C++ Translator (V) 6.1.6 (2010/08/02) // BCX (c) 1999 - 2009 by Kevin Diggins // ********************************************************************* // Translated for compiling with a C Compiler // ********************************************************************* #include <windows.h> // Win32 Header File #include <windowsx.h> // Win32 Header File #include <commctrl.h> // Win32 Header File #include <commdlg.h> // Win32 Header File #include <mmsystem.h> // Win32 Header File #include <shellapi.h> // Win32 Header File #include <shlobj.h> // Win32 Header File #include <richedit.h> // Win32 Header File #include <wchar.h> // Win32 Header File #include <objbase.h> // Win32 Header File #include <ocidl.h> // Win32 Header File #include <winuser.h> // Win32 Header File #include <olectl.h> // Win32 Header File #include <oaidl.h> // Win32 Header File #include <ole2.h> // Win32 Header File #include <oleauto.h> // Win32 Header File #include <conio.h> #include <direct.h> #include <ctype.h> #include <io.h> #include <math.h> #include <stdio.h> #include <string.h> #include <stddef.h> #include <stdlib.h> #include <setjmp.h> #include <time.h> #include <stdarg.h> #include <process.h> // *************************************************** // Compiler Defines // *************************************************** // C++ #if defined( __cplusplus ) #define overloaded #define C_EXPORT EXTERN_C __declspec(dllexport) #define C_IMPORT EXTERN_C __declspec(dllimport) #else #define C_EXPORT __declspec(dllexport) #define C_IMPORT __declspec(dllimport) #endif // Open Watcom defs #if defined( __WATCOM_CPLUSPLUS__ ) || defined( __TINYC__ ) #define atanl atan #define sinl sin #define cosl cos #define tanl tan #define asinl asin #define acosl acos #define log10l log10 #define logl log #define _fcloseall fcloseall #endif // Borland C++ 5.5.1 defs - bcc32.exe #if defined( __BCPLUSPLUS__ ) // ===== Borland Libraries ========== #include <dos.h> #pragma comment(lib,"import32.lib") #pragma comment(lib,"cw32.lib") // ================================== #endif // Microsoft VC++ #ifndef DECLSPEC_UUID #if (_MSC_VER >= 1100) && defined ( __cplusplus ) #define DECLSPEC_UUID(x) __declspec(uuid(x)) #else #define DECLSPEC_UUID(x) #endif #endif #if !defined( __LCC__ ) // ************************************************* // Instruct Linker to Search Object/Import Libraries // ************************************************* #pragma comment(lib,"kernel32.lib") #pragma comment(lib,"user32.lib") #pragma comment(lib,"gdi32.lib") #pragma comment(lib,"comctl32.lib") #pragma comment(lib,"advapi32.lib") #pragma comment(lib,"winspool.lib") #pragma comment(lib,"shell32.lib") #pragma comment(lib,"ole32.lib") #pragma comment(lib,"oleaut32.lib") #pragma comment(lib,"uuid.lib") #pragma comment(lib,"odbc32.lib") #pragma comment(lib,"odbccp32.lib") #pragma comment(lib,"winmm.lib") #pragma comment(lib,"comdlg32.lib") #pragma comment(lib,"imagehlp.lib") #pragma comment(lib,"version.lib") #else #pragma lib <winspool.lib> #pragma lib <shell32.lib> #pragma lib <ole32.lib> #pragma lib <oleaut32.lib> #pragma lib <uuid.lib> #pragma lib <odbc32.lib> #pragma lib <odbccp32.lib> #pragma lib <winmm.lib> #pragma lib <imagehlp.lib> #pragma lib <version.lib> // ************************************************* // End of Object/Import Libraries To Search // ************************************************* #endif // ************************************************* // User Global Initialized Arrays // ************************************************* // ************************************************* // Main Program // ************************************************* int main(int argc, char *argv[]) { printf("%s\n","Hello World"); return 0; // End of main program } // ************************************************* // Runtime Functions // *************************************************
And you can see there are a lot of #includes that are not going to be relevant to the propeller. So we do some simple text editing. Go back to the original program
#include <stdio.h> #include <propeller.h> Print "Hello World"
Step 1) Search for all lines starting with #include and store these lines in a text file INCLUDE.TXT
Step 2) Run the file through BCX
Step 3) Go through the output file searching for "// End of Object/Import Libraries To Search" and discard all lines above this, this line and two lines after this.
Step 4) Paste INCLUDE.TXT at the beginning of the file
Step 5) Then add this C code
// ************************************************* // Typedef // ************************************************* typedef unsigned char UCHAR; typedef unsigned long DWORD; typedef unsigned long UINT;and then the rest of the C program. So the output now looks like this:
#include <stdio.h> #include <propeller.h> // ************************************************* // Typedef // ************************************************* typedef unsigned char UCHAR; typedef unsigned long DWORD; typedef unsigned long UINT; // ************************************************* // User Global Initialized Arrays // ************************************************* // ************************************************* // Main Program // ************************************************* int main(int argc, char *argv[]) { printf("%s\n","Hello World"); return 0; // End of main program }
Which compiles and runs from SimpleIDE.
This can all be done from a simple command line program. Input a .bas file, output a .c file. I could write that program in vb.net or something simpler. It is less than 50 lines of code.
From SimpleIDE's perspective, the basic code could be in one tab (the C syntax highlighting is not bad for Basic either) and maybe you could have one line at the beginning of all Basic programs that starts with BASIC or something, and if SimpleIDE finds that, it goes off and shells a batch program, waits for the batch program to finish, puts the new C code in another tab, then compiles and downloads that C code. If the whole BCX compiler was only activated when it found the word "BASIC" at the top of the program, it would be hidden to C users and there would be no new buttons or anything in SimpleIDE that would be different to how it looks now. So it stays "simple", (ie uncluttered).
Is this something that we could think about porting over from vb.net into SimpleIDE?
Comments
This is my kind heresy! I love this!!
@Heater, If SimpleIDE is designed as well I I think it will be in the end this shouldn't be any more complex than simply adding a language to the dropdown menu.
OBC
Considering my schedule right now I can't even entertain these ideas.
Ping me on it in August. Thanks.