[ Home ]

BAStoC-Converter

The basic portion of the sauce of 'BASIC' is converted to the 'C language'.
The supported thing is that basic grammar is standard specification.
Rework is needed to actually use.

Usage.

Select from the Menu (File - Convert), and select 'BASIC File' you want to convert.
(Extension : ".bas" ".txt" ".frm")
Conversion is begun and,
the sauce before conversion is displayed on the upper part, and
the sauce after conversion is displayed on the lower part.
The converted file will be ".c" extension, and will be saved in the original folder.

The line number is deleted and automatic indent processing is performed.
As for header portion, '#include <stdio.h>' and function declaration part are described.
About 'String' type, it becomes conversion of 'java' form.
The next conversion can be carried out continuously.



Instruction to be converted.

'rem -> //rem

a=5 mod 2; -> a=5 % 2;

Standard built-in function is unchanged and in lower case.
Int(2.4) -> int(2.4)
Str$(7) -> str(7)

DIM as(24,10) -> int as[24][10];
DIM s$(10) -> String s[10];
DIM s(10) As String -> String s[10];

PRINT "abc" -> printf("abc\n");
PRINT "abc"; -> printf("abc");

INPUT a -> gets(a);

FOR I=1 TO 10 STEP 2
Exit For
NEXT
  |
for (i=1;i<=10;i+=2) {
break;
}

IF a=1 AND b<>2 OR c<3 THEN
ELSE
ENDIF(End If)
  |
if (a==1 && b!=2 || c<3) {
} else {
}

WHILE a=1 -> while (a==1) {}
WEND

Do While a=1
Exit Do
Loop
  |
while (a==1) {
break;
}

*It is same, in the case of 'Public'.
Private Sub test(a As Integer)
Exit Sub
End Sub
  |
void test(int a) {
return;
}
 
Private Function test(a As Integer) As String
test="abc"
End Function
  |
String test(int a) {
return "abc";
}

FUNC test(a$)
ENDFUNC b
  |
int test(String a) {
retuen b;
}

SELECT CASE a
CASE 1:
END SELECT
  |
switch (a) {
case 1:
break;
}