Rank: Newbie
Groups: Registered, Registered Users Joined: 5/16/2006(UTC) Posts: 2
|
I am trying to write some signals created through a Power Basic Dll in text file (as well as transmit them using TCP/IP to a local DB).. I ve already done that, quite well and your forum was really very helpful.
My problem is that I cant successfully convert:... 1. @a_psDataRec.pszSymbol 2. @a_psDataRec.psDate ... to valid string values.
I suspect that these values are in char* format and they should be treated as BSTR values, but I am not sure about it. And even if I was sure I still dont know how to make BSTR->STR conversion in Power Basic. I tried STR$() function but no success there... The reason I am using Power Basic (which I hardly know) over C++ for this particular DLL is the very easy to use TCP implementation. The rest of the code (TCP Server, etc is in C++).
So, anyone has a solution to this?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/28/2005(UTC) Posts: 276 Location: Salt Lake City, UT
|
Yes, they are char*.
I'm not that familiar with coding in PowerBasic. In the PowerBasic MSX example, it shows it setting sz... items by just using "string here".
I looked in the MSFL documentation and it shows using an ASCIIZ to get a sz... from a function.
Hope that helps.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 5/16/2006(UTC) Posts: 2
|
You are right, they are indeed char* values. In Power Basic they are called ASCIIZ values. And since there is no c_str in Power Basic (as I learnt today) I manually iterated through each char in ASCIIZ (pszSymbol) using the MID$ function and added it to a (normal) string buffer thus forming the actual string symbol that I can finally transmit to my server..... pheww (another 2 hours of my life lost over nothing... hehe)
Thank you for making it clear that these were char* values. You pointed me to the right direction.
Note: For some reason the Power Basic for DLL [censored]es if you directly try to manipulate @a_psDataRec.pszSymbol with MID$, so just put it in an another local asciiz of yours and play with that (quite simple really)
LOCAL s_Symbol AS ASCIIZ PTR LOCAL fxSymbol AS STRING LOCAL i_Len AS INTEGER s_Symbol = @a_psDataRec.pszSymbol i_Len = LEN(@a_psDataRec.pszSymbol) fxSymbol = "" FOR i = 1 TO i_Len fxSymbol = fxSymbol + MID$(@s_Symbol,i,1) NEXT i
Of course there could be another (more direct) way to do this, but since this one works, I ll go with it.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.