What does this mean?
QuoteWebOS:
// New libs included. Can use WebOS 3.x features now. Please check for
// PDL_GetPDKVersion() > 100 if you want features unavailable on 1.4.5
You can use the Touchpad-PDK library now. If you want to be compatible with 1.4.5 devices, check for PDL_GetPDK_Version() > 100 to see that you're on 2.x at least.
You can use these function with:
IMPORT "C" int PDL_GetPDKVersion()
for example.
https://developer.palm.com/content/api/reference/pdk/plug-in-api-summary.html (https://developer.palm.com/content/api/reference/pdk/plug-in-api-summary.html)
Can you write a little example?
For example with
PDL_GetDataFilePath Gets a location for saving app data.
(https://developer.palm.com/content/api/reference/pdk/pdl/pdl-get-data-file-path.html)
I'm soooo lost with C...
PDL_Err PDL_GetDataFilePath(const char *dataFileName, char *buffer, int bufferLen);
PDL_Err is int (had to look that up).
// make sure there's no space between char and * ("char*" and "const char*" is recognized as DGStr string argument)
IMPORT "C" int PDL_GetDataFilePath(const char*dataFileName, char* buffer, int bufferLen);
LOCAL short$, long$
LOCAL ierr%
ierr% = PDL_GetDataFilePath(short$, long$, 1024)
IF ierr% = 0 // PDL_NOERROR
// This is a problem now. If you want to get a string - see below
INLINE
long_Str.releasebuffer();
ENDINLINE
STDOUT "Save to: >>"+long$+"<<\n"
ENDIF
not tested, but that might be it.
[edit]
OK, when you have a const char*, DGStr strings work properly. It's just passing a pointer to the first character and the function can not change the contents of the string.
But! When you pass a "char*", the function is allowed to change the contents of the string buffer pointed to. This is a problem, because GLBasic DGStr strings internally have a "length" variable (which saves you from buffer overflows, speeds up many operations and allows you to have \0 characters in the string).
So, passing a DGStr to a char* will allocate 1024 bytes for the string, and pass that pointer. HOWEVER! If the length of the string was changed (which usually is always the case with char* arguments), you must tell GLBasic the new string length.
The DGStr::releasebuffer() function does this. It parses for the first \0 character in the string (which is an indicator for the end of a C-string) and sets this length internally.
If you use INLINE code and want a string buffer, you can call:
char* pString = mystring_Str.getbuffer( length_of_buffer );
...
mystring_Str.releasebuffer();