Page 1 of 1

PreferenceKeyType()

Posted: Sat May 18, 2024 8:29 pm
by RichAlgeni
Would return the following constants:

#PreferenceKeyInteger
#PreferenceKeyLong
#PreferenceKeyFloat
#PreferenceKeyDouble
#PreferenceKeyQuad
#PreferenceKeyString

When ExaminePreferenceKeys() is executed.

Re: PreferenceKeyType()

Posted: Sat May 18, 2024 10:01 pm
by AZJIO
The ini file is text and does not contain information about the data type. You can treat any data as any type of data. If you read the given as a string, then it will be a string. If you read the data as a number, it will be a number.
Alternatively, use XML, which contains data type information.

Re: PreferenceKeyType()

Posted: Sun May 19, 2024 12:03 am
by RichAlgeni
Excellent point!!!

Never mind!

Re: PreferenceKeyType()

Posted: Sun May 19, 2024 1:19 pm
by benubi
You can also easily put a bit of binary data in preference as a string - Base64 encoded. It's not memory effective but small useful things like a ciphered text/password or cipher-/software keys it's not an overkill. But I wouldn't store larger things, not even a little icon image of 1-2 kb, as it would result in very long lines.

Most used hash functions have a hexadecimal human readable representation (MD5, SHA1, SHA2, SHA3), this is less effective than Base64. You could convert those hashes to binary and then store them as Base64; that would be an "exception" to the rule of base64 making things longer. Sending or storing hash values in binary format instead of human readable code better hides their nature, especially when they are embedded in a longer stream of bits (since the key lengths have standard sizes, and human readable hash keys very often use hexadecimal coding which is self-revealing); except for the programer nobody can guess that there's a hash at position X in the bitstream. Transmitting those hash in binary format reduces the memory/transfer footprint by 50%. Just an idea I have to try out one day...
:lol:

Re: PreferenceKeyType()

Posted: Sun May 19, 2024 2:01 pm
by mk-soft
If you have created the preferences yourself, you also know what type the entries are.
But I switched to XML myself, because you can simply save and load structures.

Re: PreferenceKeyType()

Posted: Sun May 19, 2024 5:05 pm
by RichAlgeni
What I am working on is to have system defaults in the Registry, and overrides in an ini file. I have a map that contains the Registry/PreferenceKeyNames, with each having an array telling the program what type it is, the length, etc.. I thought having a preference type might make things a bit easier. Bit of a blonde moment!!!

Thanks all!