Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

[MBS] CoreFoundation and Total Seconds (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] Re: Mbsplugins monkeybreadsoftware.info Digest, Vol 58, Issue 3
Next thread: [MBS] 6.0pr3


Re: [MBS] MIDI Destinations and External Devices   -   Ron Benditt
  [MBS] CoreFoundation and Total Seconds   -   Beatrix Willius
   Re: [MBS] CoreFoundation and Total Seconds   -   Christian Schmitz
    Re: [MBS] CoreFoundation and Total Seconds   -   Beatrix Willius
     Re: [MBS] CoreFoundation and Total Seconds   -   Christian Schmitz

[MBS] CoreFoundation and Total Seconds
Date: 05.01.06 11:05 (Thu, 5 Jan 2006 11:05:59 +0100)
From: Beatrix Willius
Hello,

I am trying to read some prefs on the Mac containing a total seconds
value, which should be converted to a date. Saving works, but reading
doesn't. Instead of 2005 values I get 1972. I can see that the
NumberType of the number is 4. What is going on there???

Code reading the preferences is as follows:

dim theCFPrefs as CFPreferencesMBS
Dim theCFObject As CFObjectMBS
dim Key as String
Dim theCFArray As CFArrayMBS
Dim currentValue As Integer

theCFPrefs = new CFPreferencesMBS
theCFArray = theCFPrefs.CopyKeyList
(theCFPrefs.kCFPreferencesCurrentApplication,
theCFPrefs.kCFPreferencesCurrentUser, theCFPrefs.kCFPreferencesAnyHost)

PrefItems = new Dictionary

'prefs already there
If theCFArray <> nil Then
For currentValue = 0 to theCFArray.Count - 1
Key = CFStringMBS(theCFArray.Item(currentValue))
theCFObject = theCFPrefs.CopyAppValue(CFStr
(Key),theCFPrefs.kCFPreferencesCurrentApplication)
Select Case theCFObject.TypeDescription.Str
Case "CFNumber"
PrefItems.Value(Key) = CFNumberMBS(theCFObject).integerValue
'other cases deleted
End Select
Next
else
'new preferences + default values will stay in place
End If

Using Mac OS 10.4, RB2005R4, Monkey 5.5.

Mit freundlichen Grüßen/Regards

Trixi Willius

http://www.mothsoftware.com
Mail Archiver X: archive, clean and search email
http://www.beatrixwillius.de
Fractals, 3d landscapes etc.

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
http://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] CoreFoundation and Total Seconds
Date: 05.01.06 11:42 (Thu, 5 Jan 2006 11:42:32 +0100)
From: Christian Schmitz
Beatrix Willius <<email address removed>> wrote:

> Hello,
>
> I am trying to read some prefs on the Mac containing a total seconds
> value, which should be converted to a date. Saving works, but reading
> doesn't. Instead of 2005 values I get 1972. I can see that the
> NumberType of the number is 4. What is going on there???

Where is code to save?

enum CFNumberType {
/* Types from MacTypes.h */
kCFNumberSInt8Type = 1,
kCFNumberSInt16Type = 2,
kCFNumberSInt32Type = 3,
kCFNumberSInt64Type = 4,
kCFNumberFloat32Type = 5,
kCFNumberFloat64Type = 6, /* 64-bit IEEE 754 */
/* Basic C types */
kCFNumberCharType = 7,
kCFNumberShortType = 8,
kCFNumberIntType = 9,
kCFNumberLongType = 10,
kCFNumberLongLongType = 11,
kCFNumberFloatType = 12,
kCFNumberDoubleType = 13, /* Other */
kCFNumberCFIndexType = 14,
kCFNumberMaxType = 14
};

So 4 is a signed 64bit value.

Mfg
Christian

Re: [MBS] CoreFoundation and Total Seconds
Date: 05.01.06 14:34 (Thu, 5 Jan 2006 14:34:44 +0100)
From: Beatrix Willius
Hello Christian,

Am 05.01.2006 um 11:42 schrieb Christian Schmitz:

> Where is code to save?

Saving the total seconds works, because I checked the plist.
PrefItems is a dictionary with the preference values.

Dim currentValue As Integer
dim theCFPrefs As CFPreferencesMBS
dim theCFObject As CFObjectMBS
Dim Key As String, Value As Variant

If PrefItems = Nil Then
'nothing to do
return true
else

theCFPrefs = new CFPreferencesMBS
For currentValue = 0 to PrefItems.Count - 1
Key = PrefItems.Key(currentValue).StringValue
Value = PrefItems.Value(Key)
Select Case VarType(Value)
Case 2 //Integer
theCFObject = NewCFNumberMBSInteger(Value)
'other cases omitted
End Select
If Key <> "" Then theCFPrefs.SetAppValue(CFStr
(Key),theCFObject,theCFPrefs.kCFPreferencesCurrentApplication)
Next

If theCFPrefs.AppSynchronize
(theCFPrefs.kCFPreferencesCurrentApplication) Then
return true
else
return false
end if
end if




Mit freundlichen Grüßen/Regards

Trixi Willius

http://www.mothsoftware.com
Mail Archiver X: archive, clean and search email
http://www.beatrixwillius.de
Fractals, 3d landscapes etc.

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
http://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] CoreFoundation and Total Seconds
Date: 05.01.06 17:19 (Thu, 5 Jan 2006 17:19:37 +0100)
From: Christian Schmitz
Beatrix Willius <<email address removed>> wrote:

> theCFObject = NewCFNumberMBSInteger(Value)

Totalseconds is a double in the date class.

Actually it should be a 64 bit integer, but RB 2005 does not have such
data types.

Mfg
Christian