Author Topic: 10.205 new?  (Read 1779 times)

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
10.205 new?
« on: 2011-Dec-17 »
What does this mean?

Quote
WebOS:
   //    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
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: 10.205 new?
« Reply #1 on: 2011-Dec-17 »
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

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: 10.205 new?
« Reply #2 on: 2011-Dec-17 »
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...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: 10.205 new?
« Reply #3 on: 2011-Dec-20 »
PDL_Err PDL_GetDataFilePath(const char *dataFileName, char *buffer, int bufferLen);
PDL_Err is int (had to look that up).

Code: GLBasic [Select]
// 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();
« Last Edit: 2011-Dec-20 by Kitty Hello »