|
Post by rickold on Jul 30, 2009 20:02:05 GMT -5
Why doesn't this work? The code from the companion works fine. When I try to call it as a subroutine, it fails.
Sec$="User" Ent$="Name" Strng$="Billy Bob" FileNam$="testme.ini"
Call Writetoini Sec$, Ent$, Strng$, Filenam$, Rez as long Print rez
Sec$="User" Ent$="Address" Strng$="15812 N 62nd place" FileNam$="testmen.ini"
call Writetoini Sec$, Ent$, Strng$, Filenam$, rez as long Print rez
end
Sub Writetoini Section$, Entry$, String$, Filename$, result CallDLL #kernel32, "WritePrivateProfileStringA", _ Section$ As ptr, _ Entry$ As ptr, _ String$ As ptr, _ FileName$ As ptr, _ result As long end sub
|
|
|
Post by JohnDavidson on Jul 30, 2009 23:58:59 GMT -5
Alyce will be Out of office for a while but you can post code questions the Liberty BASIC Community Forum . The call to to the Sub and the Sub branch are malformed. call Writetoini Sec$, Ent$, Strng$, Filenam$, rez as long should be call Writetoini Sec$, Ent$, Strng$, Filenam$ the Sub branch should be Sub Writetoini Section$, Entry$, String$, Filename$ I've also noticed you expect a return from the Sub, rez. Functions return info Subs do not. You might want to read Subroutines and Gosubs and Function Fundamentals. John
|
|
|
Post by rickold on Jul 31, 2009 14:46:11 GMT -5
Thanks, John I had tried that at first and again last night. It still doesn't work. The result value is still 0 (Failed) and there is no ini file created. As I stated earlier, the code itself works fine outside the Subroutine.
Sec$="User" Ent$="Name" Strng$="Billy Bob" FileNam$="testme.ini"
Call Writetoini Sec$, Ent$, Strng$, Filenam$
Sec$="User" Ent$="Address" Strng$="15812 N 62nd place" FileNam$="testme.ini"
call Writetoini Sec$, Ent$, Strng$, Filenam$
end
Sub Writetoini Section$, Entry$, String$, Filename$ CallDLL #kernel32, "WritePrivateProfileStringA", _ Section$ As ptr, _ Entry$ As ptr, _ String$ As ptr, _ FileName$ As ptr, _ result As long print result end sub
|
|
|
Post by JohnDavidson on Jul 31, 2009 22:38:43 GMT -5
In Liberty BASIC's Setup Menu > Preferences there is an Enable Compiler Reporting. With this option turned on LB reports Similar Variables.
In your code it reports: FileNam$ - Filenam$ Filename$ - FileName$
Give this a try: Sec$="User" Ent$="Name" Strng$="Billy Bob" FileNam$="testme.ini"
Call Writetoini Sec$, Ent$, Strng$, FileNam$
'Sec$="User" 'Ent$="Address" 'Strng$="15812 N 62nd place" 'FileNam$="testme.ini" ' 'call Writetoini Sec$, Ent$, Strng$, FileNam$
end
Sub Writetoini Section$, Entry$, String$, FileName$ CallDLL #kernel32, "WritePrivateProfileStringA", _ Section$ As ptr, _ Entry$ As ptr, _ String$ As ptr, _ FileName$ As ptr, _ result As long print result end sub
|
|