[futurebasic] Re: [FB] Util_CFPrefsCFStrings - funky results in plist

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2011 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Tue, 9 Aug 2011 12:57:43 -0700
On Aug 9, 2011, at 12:29 PM, Thomas Peters wrote:
> clear local
> local fn mysqlConnect
> 
> BeginCFunction
> 
>     Boolean ok;
>     char hostChar[ 80 ];
>     char usernameChar[ 80 ];
>     char passwordChar[ 80 ];
>     char schemaChar[ 80 ];
> 
>     ok = CFStringGetCString( host, hostChar, 80, kCFStringEncodingUTF8 );
>     ok = CFStringGetCString( username, usernameChar, 80,
> kCFStringEncodingUTF8 );
>     ok = CFStringGetCString( password, passwordChar, 80,
> kCFStringEncodingUTF8 );
>     ok = CFStringGetCString( schema, schemaChar, 80,
> kCFStringEncodingUTF8 );
> 
>     if (NULL == mysql) {
>          mysql = mysql_init( NULL );
>          // 
> mysql_real_connect(mysql,"localhost","tpeters","river123","process_engine",
> 0,NULL,0);
>          mysql_real_connect(mysql, hostChar, usernameChar, passwordChar,
> schemaChar, 0, NULL, 0);  //   <<<   here
>     }
> EndC
> 
> end fn
> 
> </snippet>
> 
> I have the 4 CFStringRef objects dimensioned in myprefs.glbl file.  The
> functions: Accessor: GetMySQLPrefs & Mutator: SetMySQLPrefs are now
> qorking with the suggestion from Bernie, Brian and Deep... Thanks guys...
> 
> The above code has a C Function because the mysql APIs that I am using are
> in C.  they work when I hard code the parameters, but I am trying to
> create a dynamic preference that allows end users to set their own
> connection properties in my preference window.


I would remove the CFStringGetCString’s from fn mysqlConnect and set them elsewhere. Then pass the parms ( with host, username etc. ) to the mysqlConnect function. Are you needing help with syntax for passing parms to a function?

Brian S