Page 1 of 1
Posted: Wed Oct 02, 2002 4:04 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
How to read the second line of cpguitar.ini
First line is read correct
What am I doing wrong?
Using W95
;-----------
cpguitar.ini
1
0
;--------------
IF ReadFile(0, appdir$+"cpguitar.ini") = 0
; no ini available
else
ini_tuning.s = Trim(ReadString())
setgadgetstate(7,val(ini_tuning)) ; reading first line correct
; ExeTuning()
ini_mididevice.s= Trim(ReadString()) ; reading second line
setgadgetstate(#cmbMidiDevice,val(ini_mididevice))
; ExeMidiDevice()
messagerequester("Info",ini_mididevice,0) ; second line is not read
endif
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Wed Oct 02, 2002 4:17 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
Hi Cor,
Just to be clear, you are saying you have a file called cpguitar.ini and in this file it contains:
1
0
The number 1 is on the first line and 0 is on the second?
If this is the way you have it set up then it works fine here.
Just to test, if I change first line to 5 and second line to 7 then ini_tuning=5 and ini_mididevice=7 as expected.
----------
Visit the PB Resources Site at
http://www.reelmediaproductions.com/pb
Posted: Wed Oct 02, 2002 4:57 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
Maybe the .ini file is not using CR/LF but only one of them?
El_Choni
Posted: Wed Oct 02, 2002 5:30 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
It was written using:
writestringN("1")
writestringN("0")
Code: Select all
IF CreateFile(1, appdir$+"cpguitar.ini") & startup=0
WriteStringN( str( getgadgetstate(7) ) ) ; Tuning
WriteStringN( str( getgadgetstate(#cmbMidiDevice) ) ) ; Midi Device
CloseFile(1)
endif
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Wed Oct 02, 2002 11:31 pm
by BackupUser
Restored from previous forum. Originally posted by Fangbeast.
Originally posted by cor
It was written using:
writestringN("1")
writestringN("0")
Code: Select all
IF CreateFile(1, appdir$+"cpguitar.ini") & startup=0
WriteStringN( str( getgadgetstate(7) ) ) ; Tuning
WriteStringN( str( getgadgetstate(#cmbMidiDevice) ) ) ; Midi Device
CloseFile(1)
endif
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Just my 2 cents worth but... if you are going to use a file called .INI, why not structure it as a proper INI file format and use the examples at Paul's site to read and write ini files??
Fangles
Posted: Thu Oct 03, 2002 2:35 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.
I'd take a look at the "Preference.pb" program in
the samples directory.
Works the same as an INI file, but uses only a
couple of PB commands.
--blueb
Posted: Thu Oct 03, 2002 3:21 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
Now I used the preferences commands and it is working.
Still the fact why the original code is NOT working!!!!!
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Thu Oct 03, 2002 3:27 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> Still the fact why the original code is NOT working!!!!!
Your original code works fine for me... try this as proof:
Code: Select all
If CreateFile(1, "zzz.ini")
WriteStringN(Str(1)) ; Tuning
WriteStringN(Str(2)) ; Midi Device
CloseFile(1)
EndIf
;
If ReadFile(0, "zzz.ini") = 0
; no ini available
Else
ini_tuning.s = Trim(ReadString())
Debug Val(ini_tuning) ; reading first line correct
; ExeTuning()
ini_mididevice.s= Trim(ReadString()) ; reading second line
Debug Val(ini_mididevice)
; ExeMidiDevice()
MessageRequester("Info",ini_mididevice,0) ; second line is not read
EndIf
PB - Registered PureBasic Coder
Posted: Thu Oct 03, 2002 3:30 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> IF CreateFile(1, appdir$+"cpguitar.ini")
& startup=0
Try changing
& to
And, and it might work.
& is only used for number maths.
And is used for comparing commands.
See:
http://www.purebasic.com/documentation/ ... ables.html
PB - Registered PureBasic Coder
Posted: Thu Oct 03, 2002 5:29 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
I had a call to a procedure between the next readstring.
That was causing the problem.
Thanks for your suggestions i solved the problem.
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Fri Oct 04, 2002 12:10 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> I had a call to a procedure between the next readstring.
> That was causing the problem.
> Thanks for your suggestions i solved the problem.
Did you also fix the
& issue? Because your code is buggy if you're
still using it... here's proof:
Code: Select all
; Only the first test will work, but both should!
a=1 : b=2
If a=1 And b=2 : Debug "Test 1: a=1 and b=2" : EndIf
If a=1 & b=2 : Debug "Test 2: a=1 and b=2" : EndIf
PB - Registered PureBasic Coder
Posted: Fri Oct 04, 2002 1:36 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
Thanks PB
I did changed it.
Using Windows 98 SE
Registered PB version : 3.30 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com