REQ: comp.lang.basic.misc.FAQ and ini help 
Author Message
 REQ: comp.lang.basic.misc.FAQ and ini help

I need the faq for this group, or any GOOD basic FAQ.
I also need away to read data from a *.ini file. Where I can have groups
in the INI file like this:

[Program_1]
this_data= That_data

[Program_2]
My_data = YES or No

Helo on Bollean switchs in a file would help too.

I undersatnd the basic of OPEN FILE FOR INPUT and all.. its juts picking
the right data FROM the file I need help on...

Storm Child
/s
oopps...were not in wwiv...<g>



Sat, 27 Jun 1998 03:00:00 GMT  
 REQ: comp.lang.basic.misc.FAQ and ini help

Quote:
>I need the faq for this group, or any GOOD basic FAQ.
>I also need away to read data from a *.ini file. Where I can have groups
>in the INI file like this:

>[Program_1]
>this_data= That_data

>[Program_2]
>My_data = YES or No

>Helo on Bollean switchs in a file would help too.

>I undersatnd the basic of OPEN FILE FOR INPUT and all.. its juts picking
>the right data FROM the file I need help on...

>Storm Child
>/s
>oopps...were not in wwiv...<g>

Declare Function WritePrivateProfileString Lib "kernel"(Heading$,
Keyname$, Value$, INIFileName$) As Integer

Declare Function GetPrivateProfileString Lib "kernel"(Heading$, Keyname$,
DefaultValue$, Value$, MaxChars As Integer, INIFileName$) As Integer

Dim Shared Heading$
Dim Shared INIFileName$

Sub MAIN

' Create an INI file
INIFileName$ = "C:\DUMMY.INI"
Heading$ = "Dummy Information"
stat1 = WritePrivateProfileString(Heading$, "Line1", "Initial Line One",
INIFileName$)
MsgBox Str$(stat1), "ALT-TAB and open C:\DUMMY.INI with NotePad"

MsgBox "Close Notepad without saving the file.", "C:\DUMMY.INI"

stat2 = WritePrivateProfileString(Heading$, "Line2", "Second Line",
INIFileName$)

' I meant 0 to 5.  look at the order in the file when finished.
For i = 0 To 5
        Keyname$ = "Line" + LTrim$(Str$(i))
        msg$ = "i equals " + Str$(i)
        stat3 = WritePrivateProfileString(Heading$, Keyname$, msg$,
INIFileName$)
Next i

MsgBox "Now ALT-TAB to NotePad again and look at the file again",
"C:\DUMMY.INI"

MsgBox "close Notepad...", "C:\DUMMY.INI"

ans1 = GetPrivateProfileString(Heading$, "Line1", "-ERROR-", answer$, 80,
INIFileName$)

MsgBox answer$, "Line1 - read status=" + Str$(ans1)
' Note,  ans1 = len(answer$)
End Sub

I'm sure there are other ways to do this but this is the first one I
got working.

See "Hacker's Guide to Word for Windows" (second Edition)
by Woody Leonhard, Vincent Chen, Scott Krueger

Published by Addison Wesley 1995

Best "howto" I've seen for WordBasic

--

Anything I say is my fault, not my employer's.
http://home.aol.com/MorganRLM



Sat, 04 Jul 1998 03:00:00 GMT  
 REQ: comp.lang.basic.misc.FAQ and ini help

Quote:
> I need the faq for this group, or any GOOD basic FAQ.
> I also need away to read data from a *.ini file. Where I can have groups
> in the INI file like this:

> [Program_1]
> this_data= That_data

> [Program_2]
> My_data = YES or No

> Helo on Bollean switchs in a file would help too.

> I undersatnd the basic of OPEN FILE FOR INPUT and all.. its juts picking
> the right data FROM the file I need help on...

        There are libraries which deals with INIs just like you
typed it, but my (prefered) home-solution is like this little example

rem ------------------------------------- sorry, power basic code
fichini="pep.ini"

open fichini for append as #1
if lof(1)\1024=0 then writeini          'restore defs if not exist
close #1

readini
        'do the work
END

SUB writeini
    open fichini for output as #1
    print#1, ";"
    print#1, ";         TODAS las opciones son controlables desde aqu?"
    print#1, ";         o simplemente editando los ficheros de datos"
    print#1, ";"
    print#1, ";"
    print#1, "fichprint=bla.prn            ;fichero de impresiones //NO TOCAR AUN"
    print#1, "fichdump=bla.$$$             ;fichero de volcados de seguridad //NO TOCAR"
    print#1, ";"
    print#1, "okfiltro=1      ;s? (1) o no (0) a filtro de distancias m?nimas"
    print#1, "diasmes=30     ; obvio"
    print#1, ";"
    print#1, "demgraf=.98     ; cobertura a partir de la cual se graban todas las pantallas"
    print#1, ";"
rem note that this extra-lines DON'T need to have a ; but this
rem remember 'them' that this a file for intro data and not to
rem play with it.
    print#1, ";"  

    print#1, "; ---------- FIN ----------"
    close #1
END SUB

SUB readini
DIM mensaje as LOCAL STRING
DIM valor as LOCAL STRING
DIM z as BYTE
    cls
        open fichini for input as #1
        do
        incr z
        line input#1, temp
                if instr(temp,";")<5 then iterate loop
                temp=lcase$(extract$(temp, ANY ";#/*[]"))
        mensaje=ltrim$(rtrim$(extract$(temp,"=")))
        valor=right$(temp,len(temp)-instr(temp,"="))
        valor=ltrim$(rtrim$(extract$(valor,chr$(9))))
        locate 1+z mod 24, 1+26*(z\24)
        print mensaje, valor;
        select case mensaje
            case "fichdump"
                fichdump=valor
            case "fichprint"
                fichprint=valor
            case "okfiltro"
                okfiltro=val(valor)
            case "diasmes"
                diasmes=val(valor)
             case "demgraf"
                demgraf=val(valor)
        case else
                beep 1
        end select
    loop until eof(1)
        close #1
END SUB
rem ------------------------------

        Best regards

        PD: Mr. Yu I have not to say that you could get it. Do
you take the lp code?



Mon, 06 Jul 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. BASIC.FAQ - Frequently Asked Questions on comp.lang.basic.misc

2. FAQ - Frequently Asked Questions in comp.lang.basic.misc

3. FAQ - Frequently Asked Questions in comp.lang.basic.misc

4. FAQ - Frequently Asked Questions in comp.lang.basic.misc

5. FAQ - Frequently Asked Questions in comp.lang.basic.misc

6. FAQ - Frequently Asked Questions in comp.lang.basic.misc

7. FAQ - Frequently Asked Questions in comp.lang.basic.misc

8. FAQ - Frequently Asked Questions in comp.lang.basic.misc

9. FAQ - comp.lang.basic.misc

10. FAQ - comp.lang.basic.misc - Repost

11. FAQ - comp.lang.basic.misc

12. FAQ - comp.lang.basic.misc

 

 
Powered by phpBB® Forum Software