Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 3 Jahren, 3 Monaten
Letzter Beitrag:
vor 3 Jahren, 3 Monaten
Beteiligte Autoren:
naveen ratan, Alexandre Leclerc, Fabrice Harari

Read and print data from a void pointer

Startbeitrag von naveen ratan am 20.04.2015 15:04

Hi all,

I am developing an windev windows application. In that I am using an external library written in C. On some event I am getting a callbck to application from library. Now my data is in void pointer. How to type cast and print the data?

My callback: int ReadDataCb(void *pDataInfo) //What is WinDev equivalent for void*

Any help to convert above definition to WinDev compatible and access data from the pointer?

Thanks in advance,
Naveen Rathan

Antworten:

Hi

a pointer in wlanguage is the address of a variable and is written &VarName

You should know that there is a page in the help containing equivalences between C declarations and wlanguage, and how to deal with them... You'll find it if you look for the pages dealing with the API function

Best regards

von Fabrice Harari - am 20.04.2015 15:09
Hi Naveen,

You first need to know what is the actual type of the data pointer. Then simply use the Transfer() function to copy the data into the required type.

PROCEDURE MyCAllback(pData is int)
s is fixed string on 12000
nLength is int = 1024
Transfer(&s, pData, nLength)
Trace(s)

If it is a data structure, you must declare the structure and then copy using transfer again.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 20.04.2015 16:01
Hi,Alexandre,

Thanks you so much for the help. I couldnot find this kind of clear information anywhere. You solved my problem.

Now after this I have trouble while sending data to library. Here is what I am doing

temp is fixed string on 12000
DataLen is int
temp = WIN_mywindow.edit_input //Take input from edit control
write_string is ixed string on 12000

API("LIB_NAME", "CreateMsg",&temp, &write_string, &DataLen)

For above call first parameter is buffer with data, second is empty buffer to hold new data, third is int to hold length of data that is created

API("LIB_NAME", "SendMsg",&write_string, DataLen, &WriteCompCB )


For above call write_string should be buffer with data, second parameter is length obtained form first call, third is address of callback function.

Please let me know where I am doing wrong.

Thanks in advance,
Naveen Rathan

von naveen ratan - am 21.04.2015 14:38
Hi Naveen,

I do not have time to look into it with detail, but very quickly I think your "empty" buffer should be filled with empty characters (i.e. the memory block should be allocated). I'm not sure if it is required in a fixed string as you do. Using a standard string one must do that. The function for this is RepeatString().

Otherwise it would be useful to know more about the exact types your two functions are waiting for as parameters. String pointers, buffer pointers, etc. (For string pointers there is another way to work with them using StringRetrieve().) It looks like you are using pointers to values in every case. Is this right? If you use & when it is not required, this cal cause problems.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 21.04.2015 14:55
Hi,Alexandre,

Thanks for the reply. Finally I could solve it on my own. I just have one more question.

In WinDev is it possible to debug external library source fieles? Say suppose while I am debugging and I hit a break point placed on my API() call and then press F7 it should take me to library source files. This is possible in other IDE's such as Qt creator etc,. I tried the same in WinDev and it didnt worked. Is there anyway to debug my external library source files in WinDev?

Thanks in advance,
Naveen Rathan

von naveen ratan - am 22.04.2015 07:53
Hi Naveen,

No this is not possible from WinDev to debug other DLL. I did not know it was at all possible in other IDE. Must be a kind of assembler debugging? (I remember having seen that many years ago, assembler debugging of external processes.)

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 22.04.2015 13:23
Hi,Alexandre,

Yes, I am talking about assembler debugging only. Is it possible in WinDev? This is possible in Qt which is my current IDE.


Thanks in advance,
Naveen Rathan

von naveen ratan - am 22.04.2015 14:24
Hi Naveen,

Sorry for the confusion, but I've seen that in another IDE, not in WinDev.

This is not possible in WinDev.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 22.04.2015 17:36
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.