` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Windows API: Assigning address to reference
2006-02-19 -- Jim Kane
 
> Hi all. I have an address of a cstring in a ULONG variable. How can I > make a &CSTRING reference point at that address? > > I can't do cstrref &= myulong because the type doesn't match. I'd use > cstrref &= address(myulong) but that's not right. I tried doing > tmpulongRef &= mylong; cstrref &= address(tmpulongRef) but that doesn't do > it either. Check the help for reference variables. It will clearly tell you can't. Also note the use of ( ) to force a cast and avoid type problems. cref &= (myulong) Will point at it but the size will be considered zero which will screw things up for some commands where the runtime needs the cstring size and work just fine for other things. If you want to rely on the undocumented inner workings of c string ref variables you can do what you want to. Usually a bad idea when there are api c string functions to manipulate cstring. Here's enough rope to hang yourself - code will break if SV changes the internal structure of a cstring ref variable. Jim kane program map end crefGroup group,pre() cRef &cstring end crefgroupOver group, over(crefgroup) Theaddress long thesize long end cVar cstring(200) myulong ulong sizeofcstring long code !a cstring to test with cVar = 'cref Test' !make the ref variable point to cVar myulong = address( cVar ) sizeOfcstring = size( cvar) crefgroupover.theaddress = myulong crefgroupover.thesize = sizeofcstring !see if it worked message( cref ) return


Today is May 2, 2024, 8:05 am
This article has been viewed 35118 times.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: