 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ZugZugZealot
Joined: 31 May 2008 Posts: 2
|
Posted: Sat May 31, 2008 10:21 pm Post subject: IniRead Issue |
|
|
I'm making a script, that I'll be adding in a colloberative script for people to use for a game. The game has saving and loading in it. I've already made a script that you can do CTRL + NumpadDot and it will load from the .ini file, and after that type out the code, then press CTRL + NumpadDot and it will save it.
However, what I'm trying to build, is the same concept, but without overwriting the existing load code. I'm trying to make it so that it will add upon it. Theoretically with the code I have, and the current state of the .ini file it should end up loading "Zug" and save to key "4".
But for some reason it stops at the second if check, when it should go to the else. Either the "If" statement is whacko and proceeds it as if it were true when it's not. But the scenario more than anything, is that the Iniread is returning an error. It seems to be right to me. Anyways...
The script...
| Code: |
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
;Initial Key Position Check
if (var !=0 & var !=1) ;start the check *works
{
var = 0
iniread, code, SaveCode.ini, SaveCode, 1
loop
{
if (code := "ERROR") ;no load code
{
skey := 1
lkey := 0
msgbox, phase 2 ;troubleshoot
break
}
else ;find load and save position
{
skey := 1
lkey := 0
msgbox, phase 3 ;troublshoot
loop
{
if (code := "ERROR") ;end check if true
{
break
}
else ;search loop
{
lkey = %lkey% + 1
skey = %skey% + 1
iniread, pos, Save Code.ini, SaveCode, %skey%, --
}
}
}
}
}
;Load/Save
^NumpadDot::
if (var = 0 & lkey = 0) ;load, display no load code
{
send {enter}
send {raw}No load code found.
send {enter}
var := 1
}
else if (var = 0 & lkey > 0) ;load, enter load code
{
iniread, code, SaveCode.ini, SaveCode, %lkey%
send {enter}
send {raw}-load %code%
send {enter}
var := 1
}
else if (var = 1) ;save
{
send {shift down}{home}{shift up}{ctrl down}c{ctrl up}{left}
iniwrite, %clipboard%, saveCode.ini, SaveCode, %skey%
lkey := %lkey% + 1
skey := %skey% + 1
send /w eota
send {space}{enter}
var := 0
}
|
And the contents in the .ini...
| Code: |
[SaveCode]
1=Blarg
2=Larp
3=Zug
|
If someone can figure out what's wrong with it and tell me how to fix it or if there's a mysterious function I don't know about to make this simpler and tell me about it, I'd appreciate it. |
|
| Back to top |
|
 |
Zed Gecko
Joined: 23 Sep 2006 Posts: 98
|
Posted: Sat May 31, 2008 11:38 pm Post subject: |
|
|
Itīs not an IniRead issue, itīs an If issue.
| Code: | | if (code := "ERROR") ;no load code |
should be
| Code: | | if (code = "ERROR") ;load code |
_________________ 1) All my code can be reused in ANY way. 2) Please check the help and the forum-search, before posting questions; the answer is out there... |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Jun 02, 2008 10:17 pm Post subject: |
|
|
So changing the if statement as suggested fixed the if statement, then I ran into some other problem, but I manage to resolve them. I got it to load Zug, then save into key 4.
The final product looks like this...
| Code: |
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
;Initial Key Position Check
if (var !=0 & var !=1) ;initialization of check
{
var := 0
iniread, code, SaveCode.ini, SaveCode, 1
loop
{
if (code = "ERROR") ;check for no existing code
{
skey := 1
lkey := 0
break
}
else ;proceed to search for latest load code and define save position
{
skey := 1
lkey := 0
loop
{
if (code = "ERROR") ;end loop when found
{
goto, END
}
else ;check next line
{
lkey := lkey + 1
skey := skey + 1
iniread, code, SaveCode.ini, SaveCode, %skey%
}
}
}
}
}
END:
return
;Load/Save ;ctrl + numdot: display no found code
; queue for save
^NumpadDot::
if (var = 0 && lkey = 0)
{
send {enter}
send {raw}No load code found.
send {enter}
var := 1
return
}
else if (var = 0 && lkey > 0) ;ctrl + numdot: enter latest code
; queue for save
{
iniread, code, SaveCode.ini, SaveCode, %lkey%
sleep 10
send {enter}
send -load %code%
send {enter}
var := 1
return
}
else ;ctrl + numdot: save to latest load + 1,
; add one to latest save and load
; queue for load
{
send {shift down}{home}{shift up}{ctrl down}c{ctrl up}{left}
sleep 10
iniwrite, %clipboard%, saveCode.ini, SaveCode, %skey%
lkey := lkey + 1
skey := skey + 1
send /w eota
send {space}{enter}
var := 0
return
}
|
For anyone who wants an example for how to continually add upon an .ini file rather than continually overwriting, here is one.[/code] |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|