"This Variable has not been assigned a value" help? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
lolzbroz6
Posts: 35
Joined: 08 Sep 2018, 17:18

"This Variable has not been assigned a value" help?

11 Oct 2018, 14:42

So I have a simple troll spammer that a friend asked me to make for him (he's not good with coding) and I thought it would be easy by using ahk's simple SendInput command
and setting it to toggle but apparently, I've messed something up. The code is below and I have used this toggle code before (but with different commands inside) and it worked perfectly now it doesn't and it shows up the error "This variable has not been assigned a value" I'm sure it is a simple and easy to fix problem but I cannot figure it out for the life of me :)

Code: Select all

#NoEnv
#Warn
SendMode Input 
SetWorkingDir %A_ScriptDir%

*e::
    toggle := !toggle
    if (toggle) {
        SendInput {t}
        SendInput {r}
        SendInput {o}
        SendInput {l}
        SendInput {l}
        SendInput {Enter}
        return	
    }
Thanks For Any And All Help!!
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: "This Variable has not been assigned a value" help?  Topic is solved

15 Oct 2018, 12:20

It's because you're using #Warn.

You should Initialize a variable before attempting to store a value to it, like this: toggle := 0.

That creates the variable, and then stores a value of 0 to it. Now the variable exists and is ready to use.

This line toggle := !toggle says: If toggle is equal to 1, set its value to zero, or if toggle is equal to zero, set its value to 1.

Without fist initializing the variable and assigning a value, there is nothing to check for yet as it doesn't exist.

If you comment out (or remove) #Warn, the script will not display any errors.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 302 guests