LB Booster
« INI returns »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:47am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: INI returns  (Read 445 times)
joker
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 157
xx INI returns
« Thread started on: Nov 28th, 2015, 12:25pm »

I believe these two statements are in conflict and the first one does not work as written. What I get from Entry$="" ' empty is the Default$.

Replacing the "" with _NULL fixes the problem.

PS. I think this is what I meant elsewhere as "{halfhearted}" effort in case anyone is counting.


From LBPE http://lbpe.wikispaces.com/IniFiles

{my emphasis}

Quote:
READING AN INI FILE BY API
GetPrivateProfileStringA
...
Entry$
Points to the null-terminated string that is associated with the value string. If this parameter is empty, the return string will contain a list of all values in the specified section, separated by null characters, and terminated with double null characters.

Default$
Points to a null-terminated string that specifies the default value for the given entry if the entry cannot be found in the initialization file. This parameter must never be NULL or empty. You might want to specify a value that makes it clear that this section of the ini file was blank.


Code:
INIfile$ = DefaultDir$ + "\JunkINIstruct.ini"
    
calldll #kernel32, "WritePrivateProfileStringA", "Register" as ptr, _
    "Forward" as ptr, "1234567890" as ptr, INIfile$ as ptr, ret as long
        
calldll #kernel32, "WritePrivateProfileStringA", "Register" as ptr, _
    "Backward" as ptr, "0987654321" as ptr, INIfile$ as ptr, ret as long

calldll #kernel32, "WritePrivateProfileStringA", "Register" as ptr, _
    "ABCword" as ptr, "ABCDEFGHIJ" as ptr, INIfile$ as ptr, ret as long

default$ = "NO DATA SPECIFIED"
sizestring = 100
string$ = Space$(sizestring)

    calldll #kernel32, "GetPrivateProfileStringA", "Register" as ptr, _
        "" as ptr,_
        default$ As ptr, _
        string$ As ptr, _
        sizestring As long, _
        INIfile$ as ptr, ret as long
'        _NULL as ptr,_
'        "Forward" as ptr,_
        
        
print "Raw Returned Entry Value: "; string$+"<-"
print "GetINI: "; ret
print "Returned Entry Value: "; Left$(string$,ret)+"<-"

end
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: INI returns
« Reply #1 on: Nov 28th, 2015, 1:27pm »

on Nov 28th, 2015, 12:25pm, pnlawrence wrote:
I believe these two statements are in conflict and the first one does not work as written.

I don't think they are "in conflict" but I agree that the term 'empty' is imprecise and ought to be better defined. Evidently what was meant is NULL (the numeric value zero) rather than "" (a zero-length string) but that's only evident by cross-referencing with the relevant MSDN page.

The potential for confusion is made even worse by a 'zero-length string' (or 'empty string') sometimes being referred to as a 'NULL string' - thus using the term NULL in two quite different senses. sad

Personally when needing a Windows API reference I would always prefer to go directly to the 'horse's mouth', i.e. MSDN, rather than reading somebody's (possibly incorrect or inaccurate) interpretation at LBPE.

Richard.
User IP Logged

joker
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 157
xx Re: INI returns
« Reply #2 on: Nov 28th, 2015, 1:38pm »

Again, at risk of being labeled, I brought up the same subject.

If one is aware of part of the page, then one should be able to figure out the rest of the page. Right? cheesy

As this INI stuff moves along, I've wondered why it took so long. Not that I want an answer. cheesy

I've just been working on parts of my project, and different points came up. This way to list all of the entries in an INI file is part of a combo box.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls