--------------------------------------------
		SHAREWARE !!
		Register: 10$
		
	Author: Dietmar Reinwald
		Goethestrasse 8
		69257 Wiesenbach
		Germany
		Tel.:  06223 40742
		Email: Dietmar.Reinwald@t-online.de
		CompuServe: 101761,335
--------------------------------------------


1)
a) Only for *.bas, not for *.frm and *.cls
b) A later version translates *.cls in Delphi classes
c) A later version additionally translates *.bas and *.cls into Java
d) A later version additionally translates *.bas and *.cls into C (C++)

2)
Assumption: 
a) The Visual Basic (VB) code is written with 'Option explicit' in the modul which you want to translate.
b) The VB code has to be syntactly correct
c) It doesnt translate Deftype statements
d) It doesnt creates Label for Goto Statements (in a later Version)
e) Translation with option 'Translate Sub' translates statement 'len' into 'sizeOf' (In a later Version if variable is string then into 'length')
f) Arrays allocated with Dim and ReDim has the minimal lower bound zero. If you declared an array like Dim a#(n , 2 to m), I assume Dim a#(n,m).

3)
Designed for VB 3.0, but you can use it also for VB 4.0.
(It supports Private and Public)

4)
Translation form VB modul to pascal Unit.

5)
Dim and ReDim are quite difficult to translate (for example Dim a(n) or ReDim a(n) with n a variable).
I have solved the difficulties with allocate/deallocate of pointers.
For this case you need the file ArrayPtr.pas. You can create it with a button in BasToPas.exe. 
There are functions only for the simple types.
For other types you have to define the functions in a simliar way.
The allocation and deallocation assume that the lower bound is minimal zero.

6)
You can create pointers with the option 'With Info' or with 'No Info'.
a) Option 'With Info':
The informations about the size of the pointerarray are stored in the pointerarray.
Its the sure way to translate Dim, ReDim and Ubound.
b) Option 'No Info':
The informations about the size of the pointerarray are not stored.
If  (Re)Dim a(n), the translator stores n and use it later in Ubound(a) --> n and DisposeArray(a,n).
Be sure, that not in the meantime you make something like n = m with n <> m.

7)
If you do translate a modul which needs global variables (arrays) from
another modul, then copy the global variables into the modul
that you whant to translate. After you have done the translation,
remove this variables (pointers to arrays) from the implementation
part of the ouput file. Example:

--------------------------------------------
---- Code of modul test --------------------

Option Explicit

Dim a$()

Function test% (a$(), m%)

 Dim b$()

 ReDim b$(m)
 ReDim a$(m)
 ReDim c$(m)

'Here is code

End Function

--------------------------------------------
------- Here the translated pascal code ----

Unit test ;

{Option Explicit}

interface

function test (var a : integerArrayPtr ;var m : integer ) :  integer ;

implementation

const

	a : integerArrayPtr = nil ;

function test  (var a : integerArrayPtr ;var m : integer ) :  integer ;
 const
 	 b : integerArrayPtr = nil ;

 begin
 	b := nil ;

	 b := ReDimINTEGERVektor(b , m) ;
	 a := ReDimINTEGERVektor(a , m) ;
	 c := ReDimINTEGERVektor(c , m) ;
	{Comment translator: Pointer not found in Sub/Function- or moduldeclaration. I think its as Sub/Function deklaration}

{'Here begins code}

{'Here ends code}

 	b:=  DisposeINTEGERArray(b) ;
 	c:= DisposeINTEGERArray(c) ;
 end ;

initialisation

	a := nil ;

end.
--------------------------------------------


Thats the output. You see the comment

	{Comment translator: Pointer not found in Sub/Function- or moduldeclaration. I think its as Sub/Function deklaration}

The array c%() is not defined as Dim c%() at the top of function test. Its better 
you do it. When c%() is a Global variable from another modul, declare this at the
top of the modul test near Dim a%(). Then not happens

 	c:= DisposeINTEGERArray(c) ;

at the bottom of function test.
--------------------------------------------

8)
The translation of Dim and ReDim (Preserve) only with arrays
of one and two dimensions.

9)
No translation to boolean

10)
This pointerconcept works not when the type has length 1.
Then the pointers has maximal length 253.
To do it with strings is also a bad idea. 
There are better classes (TStringList) in Delphi  (in a later Version)

11)
Be sure that your VB code works with strings of length < 256.

12)
The best if
	Type variant = string;

13)
For several special VB functions is the Unit BasTool.pas. You can create it with a button in BasToPas.exe.
You also then get the Unit Arrayptr.pas with all the pointer stuff.

14)
I translate Val to ValBasic, Str (Str$) to StrBasic.

15) Prepare code options
'Translate Sub':
If you unable this, no translation sqr->sqrt, a ^ b->exp(b*ln(a), log->ln, len->sizeof, Mid($)->copy, instr->pos or instr, val->ValBasic, Str($)->StrBasic, asc->ord,"
String($)-> StringBasic, cdbl->double, cint->integer, clng->longint, csng->single, cstr->string, lcase($)->LowerCase, 
ucase($)->UpperCase, print->writeln, line input->readln, close->CloseFile, Kill->DeleteFile,name->RenameFile, get->seek, put->seek or write, 
Open [input,append,...]->AssignFile [Reset,Append,Rewrite]

16)
This program is a VB exe. You need a vbrun300.dll to run.

17)
This program is only a help tool for translation. Its up to you to control and correct the translated code.

_______________________________________________________________________________
No gaurantee for well translated code. I take no responsibility if you use the translated code. 
The use of the translated code is your risk and your responsibility.
You has to control the translated code and to test it very carefully and thouroughly.
The translation of Dim and ReDim is done with pointers, hence the translated code can be dangerous.
_______________________________________________________________________________

18)
This program is shareware. It cost me a lot of time to put it in a form so other people can use it too. 
Please pay 10$ to me.
If you find mistakes, please locate them and send the code to me.
If it is possible, you'll then receive a corrected version.

19)
If you have questions, comments and critics, then give me a mail.

Why this program:

BasToPas was created to help me converting mathematical VB code to pascal code because of two reasons.
a) I want include fast mathematical pascal code as *.dll in
my VB project.
b) I want to protect the code against recompilation.


