Jump to content

Should I be using Eval?


Recommended Posts

Can anyone tell me why this line doesn't compile correctly?

$sound_2_play = $install_destin & $file & $random

#include <Misc.au3>


$file1 = "cat.wav"
$file2 = "meow.wav"
$file3 = "Cat01.wav"
$file4 = "cat-meow.wav"
$file5 = "9_43B.wav"
$file6 = "9_43D.wav"
$install_source = "C:\Documents and Settings\[Name]\My Documents\Personal\AutoIt\Prank\"
$install_destin = "C:\Temp\"

;AutoItSetOption ( "TrayIconHide", 1 )
Install_Meow ()

While 1
    Sleep ( 150 )
    If _IsPressed("23") Then
        $wait = Random ( 1000 , 2000)
        Sleep ($wait)
        
        $random = Random ( 1 , 6 )
        $sound_2_play = $install_destin & $file & $random;$install_destin &
; RIGHT ABOVE HERE
        
        SoundPlay ( $sound_2_play ,1)
        MsgBox(0,"_IsPressed", "End Key Pressed", 1)
        
    EndIf
WEnd


Func Install_Meow ()
FileInstall ($install_source & $file1, $install_destin)
FileInstall ($install_source & $file2, $install_destin)
FileInstall ($install_source & $file3, $install_destin)
FileInstall ($install_source & $file4, $install_destin)
FileInstall ($install_source & $file5, $install_destin)
FileInstall ($install_source & $file6, $install_destin)
EndFunc
Link to comment
Share on other sites

  • Moderators

The source file must be a string and not a variable so that the compiler can extract the filename to include.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The interesting part about that, is that the files install perfectly. I am looking at them right now.

It seems that this line is the issue, and I get this error. I could be wrong though

$sound_2_play = $install_destin & $file & $random

C:\Documents and Settings\[name]\My Documents\Personal\AutoIt\Prank.au3(23,43) : WARNING: $file: possibly used before declaration.

$sound_2_play = $install_destin & $file &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\[name]\My Documents\Personal\AutoIt\Prank.au3(23,43) : ERROR: $file: undeclared global variable.

$sound_2_play = $install_destin & $file &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\[name]\My Documents\Personal\AutoIt\Prank.au3 - 1 error(s), 1 warning(s)

Link to comment
Share on other sites

Execute, quotes:

$sound_2_play = Execute($install_destin & "$file" & $random)

Dale

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Sadly, when I use that line, it sets my @Error to 1. I know there has to be a way to accomplish this. Thanks again, for everyone's help.

I nested improperly and Doh! I assumed you were using Random properly...

$random = Random ( 1 , 6 , 1)

$sound_2_play = $install_destin & Execute("$file" & $random)

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • Moderators

FileInstall will work properly with variables x% of the time, but if this is going to be used on other computers as a native .exe you will be upset to have to re-write them all. Take this help file warning as a fact and not a suggestion.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...