|
| Read and print data from a void pointer |
| Iniciado por guest, 20,abr. 2015 17:04 - 8 respuestas |
| |
| | | |
|
| |
| Publicado el 20,abril 2015 - 17: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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 20,abril 2015 - 17:09 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 20,abril 2015 - 18:01 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 21,abril 2015 - 16:38 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 21,abril 2015 - 16:55 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 22,abril 2015 - 09:53 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 22,abril 2015 - 15:23 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 22,abril 2015 - 16:24 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 22,abril 2015 - 19:36 |
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 |
| |
| |
| | | |
|
| | | | |
| | |
|