Page 1 of 1
Posted: Fri Nov 29, 2002 5:28 pm
by BackupUser
Restored from previous forum. Originally posted by marlo.
Hi all. I need to convert little code from Delphi to PB, the code start with this:
TAddActionProc = PROCEDURE( IDNum : INTEGER;
Name, Hint : PChar;
Params : ARRAY OF BYTE;
NumParams : BYTE );
TAddFileProc = PROCEDURE( FileName : PChar; AddFlag : BOOLEAN );
TVarGetProc = PROCEDURE( VarName : PChar; VAR Value : PChar );
TVarSetProc = PROCEDURE( VarName, Value : PChar );
TPlayActionProc = PROCEDURE( Action : PChar );
TInterfaceProc = FUNCTION( InterfaceID : INTEGER;
VAR Data :PChar ) : BOOLEAN;
Please, help!!! I need It. Txs
from Corruptionland
Posted: Fri Nov 29, 2002 6:58 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
This is just some procedure declarations, much the same that you do in PB:
Procedure TAddActionProc(IDNum.l, Name.s, Hint.s, Params.ByteArrayType, NumParams.b)
...
EndProcedure
Perhaps this translation isn't perfect as i'm not fluent in Delphi. Note that '.ByteArrayType' is a made up structure type so you have to declare it correctly(not 100% sure how the delphi counterpart 'ARRAY OF BYTE' is constructed).
Posted: Fri Nov 29, 2002 10:05 pm
by BackupUser
Restored from previous forum. Originally posted by marlo.
Thanks for your help, Pupil. I search about docs about Delphi to PB traslations, but nothing. So, how can write that variables on PB
MyFlag : BOOLEAN
VAR Myvar :PChar
and this called FUNCTION by Delphi:
TInterfaceProc = FUNCTION( InterfaceID : INTEGER;
VAR Data :PChar ) : BOOLEAN;
Txs again.
from Corruptionland
Posted: Fri Nov 29, 2002 10:46 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
BOOLEAN means only the logical values 0(false) and 1(true) is to be returned, in PB you can choose between '.b', '.w' or .'l' for this type, just remember that PB interprets 0 as false and value0 as true..
I think PChar is some kind of stringtype so i guess you can replace it with '.s' in PureBasic. Possibly it's some other kind of character buffer that can have null values inside(PB strings cannot as a null character terminates the string), in that case you would probably need to allocate some memory or create some kind of static structure for this.
Now to the function, in delphi a function is a procedure that returns a value, so in PB that function would look something like this:
Code: Select all
Procedure.l TInterfaceProc(InterfaceID.l, Data.s)
...
ProcedureReturn #SomeValue
EndProcedure
I'm not certain what the 'VAR' keyword does.
Hope this helps a little, just keep in mind that i'm basing my assumptions on logic and knowledge aquired some 8-10 years ago on a Borland Pascal course.