PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → Working with pointers...
Working with pointers...
Iniciado por David, jul., 16 2004 7:03 PM - 3 respostas
Publicado em julho, 16 2004 - 7:03 PM
I have some code in Delphi wich i need to translate to Windev but Delphi code uses pointers, does Windev have anything I can use?
Other problem is the use of overloads functions in Delphi and I don't know how to migrate it to Windev, any sugestions??
Delphi code:
function SMStartCapturing(ScannerId: PAnsiChar; ImageProc: TSMImageProc; StateProc: TSMStateProc; Param: Pointer): Integer; stdcall;
function SMGetScannerId(Index: Integer; Id: PAnsiChar; Len: Integer): Integer; stdcall; overload;
function SMGetScannerId(Index: Integer): string; overload;
best regards...
David
Publicado em julho, 16 2004 - 9:14 PM
Hi,
1) To answer your question with regards to pointers:
In WinDev you can use the ampersand ('&')like in C/C++ sign to refer to the memory address of a variable or procedure instead of the variable value itself.
By default WinDev internally (when using W-Language) passes variables "by reference" (= memory address) instead of "by value".
Only when talking with other platforms (API's etc...) you may need explicitely pass a variable as memory address like the example below:
sWindowTitle is string ASCIIZ on 257
API("USER32","GetWindowTextA",iHwnd,&sWindowTitle,257)
For transferring string variables referenced by memory address back into a WinDev string check the Transfer() function.
2) To answer your question with regards to overloading:
As of WD8 (Maybe also WD75) overloading of procedures and even standard WinDev functions is supported. Haven't used it yet, but it should be possible.
Regards,
Peter


http://members.chello.be/cr45693/
Publicado em julho, 16 2004 - 9:21 PM
Hello David,
use &variable if you want pass the address of a variable. Do you mean polymorphic functions if you ask about overload? Sorry then, there is no way to write polymorphic functions in WinDev. However there is way for you!
Procedure SMGetScannerId(Index is Int, Id is variant = null, Len is variant = null)
Procedure SMGetScannerId(Index is int)
You can then check in the procedure for Null on the parameters and do the appropriate action.
HTH
Raimund

I have some code in Delphi wich i need to translate to Windev but Delphi code uses pointers, does Windev have anything I can use?
Other problem is the use of overloads functions in Delphi and I don't know how to migrate it to Windev, any sugestions??
Delphi code:
function SMStartCapturing(ScannerId: PAnsiChar; ImageProc: TSMImageProc; StateProc: TSMStateProc; Param: Pointer): Integer; stdcall;
function SMGetScannerId(Index: Integer; Id: PAnsiChar; Len: Integer): Integer; stdcall; overload;
function SMGetScannerId(Index: Integer): string; overload;
best regards...
David



http://www.invitec.com
Publicado em julho, 16 2004 - 9:40 PM
Thanks, you've really got it!! its to work with API's
David