It's not that they're never assigned a value. You can see in the code that they are eventually assigned a value. It's just that they haven't already been assigned a value before the first time their contents are used. It's not a problem in this case because their un-initialized value, which is null, is fine.
You can't just put it all at the top or all at the bottom. You need the part that needs to be executed at the start of the script in the top section (
Code: Select all
settimer,updatedscript,500
#maxthreadsperhotkey 999999999
#noenv
#persistent
#singleinstance force
#warn
sendmode input
setworkingdir %a_scriptdir%
fileread, contents, g:\List1.txt
if not errorlevel
{
sort, contents
filedelete, g:\List1.txt
fileappend, %contents%, g:\List1.txt
contents := ""
}
sleep 300
fileread, outputvar, g:\List1.txt
sort, outputvar, u
filedelete, g:\List1.txt
sleep 300
fileappend, %outputvar%,g:\List1.txt
menu, tray, add , Pause, pause
menu, tray, add , Exit, exit
menu, tray, icon , AutoCorrect.ico,, 1
menu, tray, nostandard
menu, tray, tip, AutoCorrect
settimer, lbl, 5000
return
lbl:
FileGetTime, tmstmp, %A_ScriptDir%\List1.txt
if (oldtmstmp != tmstmp AND flag)
Msgbox The file has changed!
oldtmstmp := tmstmp, flag := 1
return
pause:
suspend, toggle
if (a_issuspended)
menu, tray, icon , AutoCorrect pause.ico
else
menu, tray, icon , AutoCorrect.ico
return
exit:
exitapp
#p::
suspend, toggle
if (a_issuspended)
menu, tray, icon , AutoCorrect pause.ico
else
menu, tray, icon , AutoCorrect.ico
return
#a::
autotrim on
clipboardold = %clipboardall%
clipboard =
send ^c
clipwait 1
if errorlevel
return
stringreplace, hotstring, clipboard, ``, ````, all
stringreplace, hotstring, hotstring, `r`n, ``r, all
stringreplace, hotstring, hotstring, `n, ``r, all
stringreplace, hotstring, hotstring, %a_tab%, ``t, all
stringreplace, hotstring, hotstring, `;, ```;, all
clipboard = %clipboardold%
inputbox, hotstring, AutoCorrect, Automatic entry,,,,,,,, :*:%hotstring%::
if errorlevel <> 0
return
fileappend, `n%hotstring%, g:\List1.txt
reload
#m::
autotrim on
clipboardold = %clipboardall%
clipboard =
send ^c
clipwait 1
if errorlevel
return
stringreplace, hotstring, clipboard, ``, ````, all
stringreplace, hotstring, hotstring, `r`n, ``r, all
stringreplace, hotstring, hotstring, `n, ``r, all
stringreplace, hotstring, hotstring, %a_tab%, ``t, all
stringreplace, hotstring, hotstring, `;, ```;, all
clipboard = %clipboardold%
inputbox, hotstring, AutoCorrect, Manual entry,,,,,,,, ::%hotstring%::
if errorlevel <> 0
return
fileappend, `n%hotstring%, g:\List1.txt
reload
#/::
autotrim on
clipboardold = %clipboardall%
clipboard =
send ^c
clipwait 1
if errorlevel
return
stringreplace, hotstring, clipboard, ``, ````, all
stringreplace, hotstring, hotstring, `r`n, ``r, all
stringreplace, hotstring, hotstring, `n, ``r, all
stringreplace, hotstring, hotstring, %a_tab%, ``t, all
stringreplace, hotstring, hotstring, `;, ```;, all
clipboard = %clipboardold%
inputbox, hotstring, AutoCorrect, Mid text manual entry,,,,,,,, :?:%hotstring%::
if errorlevel <> 0
return
fileappend, `n%hotstring%, g:\List1.txt
reload
#include g:\List1.txt
updatedscript:
filegetattrib,attribs,%a_scriptfullpath%
ifinstring,attribs,a
{
filesetattrib,-a,%a_scriptfullpath%
sleep,500
reload
}
return