accessing string values

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

accessing string values

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:16 pm

by Kern Carboni >> Fri, 9 Jul 1999 1:16:57 GMT

I am trying to use the SHBrowseForFolderA and SHGetPathFromIDList
Windows api functions to create a directory browsing/selection dialog box.

The SHGetPathFromIDList takes two parameters, the most important being a pointer to a string variable ,directoryName, which stores the selected directory path.

directoryFound := call extractPath(idList,directoryName.bufferAddress);

After calling the above external function in the debugger, I inspect directoryName which reveals it to have the expected value ie "C:\Interface\Extract".
However I cannot seem to assign the value stored in directoryName to any variable,attribute etc as they always show up as null.
Is this due to Windows returning strings in a format unrecognisable by Jade ie null terminated strings.
I noticed that version 4.1 includes the unpackCString method and was wondering
a) if this would solve my problem,
b) if anyone knew what the unpackCString method does as I would need to implement my own version in 4.016 due to the fact that,
after upgrading through to 4.202, any external function calls to shell32.dll resulted in bringing Jade to its knees, coughing and spluttering.
(reminiscent of an All Black loose forward, after Saturday...8-} )


Any help/answers greatly appreciated
Kern

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: accessing string values

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:16 pm

by Krull >> Tue, 13 Jul 1999 4:37:23 GMT

Kern,

Here are some comments and suggestions:

1) Jade 5.0 provides a new FileFolder method called browseForFolder, which is simply a wrapper for the Windoze shell functions you are attempting access directly so if you can wait a little while JADE 5.0 might provide the functionality you require.

2) The usage of directoryName.bufferAddress as the second parameter to the call shown in your example code fragment is dangerous in this context; If you haven't ensured that memory for the string variable directoryName is preallocated, then memory corruption will occur, which is the likely cause for "bringing Jade to its knees, coughing and spluttering".

You didn't mention how you defined the external function in JADE, which is critical. The way I would define it is as follows:

extractPath(idList : Binary; pathName[MAX_PATH] output) : Boolean is SHGetPathFromIDList in shell32;

In the above, MAX_PATH is a constant with a value >= to the windows defined value (260 from memory). The length annotation in the function call definition informs the JADE interpreter to allocate a temporary buffer of the specified size to reciever the value and the output usage qualifier informs the interpreter to copy the contents of the buffer to the actual parameter after the function call.

To call this function use:

directoryFound := call extractPath(idList, directoryName);
The SHGetPathFromIDList takes two parameters, the most important being a pointer to a string variable ,directoryName, which stores the selected directory path.

directoryFound := call extractPath(idList,directoryName.bufferAddress);


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 6 guests