Jump to content

Eror Variable used without being declared


alaisa22
 Share

Recommended Posts

Hello guys Im having problem in my code here, erro is "Variable used without being declared". Hope you can help me, Im a newbie here in AutoIt. Any help will be much appreciated. :lmao:

Here is my code. :D;) ;)

#include <Date.au3>

Func datetime()

$sec=string(@SEC)

$min=string(@MIN)

$hour=(@HOUR)

$day=string(@MDAY)

$mon=string(@MON)

$year=string(@YEAR)

If $hour="00" then

$hour="24"

Else

$hour=string(@HOUR)

Endif

$time = $hour & ":" & $min & ":" & $sec

$date = $year & "." & $mon & "." & $day

$dt=$time & " / " & $date

Return ($dt)

EndFunc

Func _FindTextInFile($sFile, $sText, $iCasesense = 0)

Local $FO, $FR, $aStr

If Not FileExists($sFile) Then Return SetError(1, 0, 0)

$FO = FileOpen($sFile, 0)

If $FO = -1 Then Return SetError(2, 0, 0)

$FR = FileRead($FO)

If @error > 0 Then

FileClose($FO)

Return SetError(3, 0, 0)

EndIf

FileClose($FO)

$aStr = StringSplit(StringStripCR($FR), @LF)

For $i = 1 To $aStr[0]

If StringInStr($aStr[$i], $sText, $iCasesense) Then Return $i

Next

Return 0

EndFunc

CLIENT IMMEDIATELY.")

$date = datetime()

$FTIF = _FindTextInFile("C:\xxxxxxxxxxxxxx - " & $date, "[" & $time & "] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.")

If @error Then

MsgBox(0, "Error!", "Error Code: " & @error)

ElseIf Not $FTIF Then

MsgBox(0, "No Match", "Critical Error Found. "$date, 2)

Else

MsgBox(0, "Match", "Critical Error Found at line #: " & $FTIF & " Dated " & $date)

EndIf

Link to comment
Share on other sites

  • Developers

You mean that you get a error that $time isn't declared?

It is only a local variable in the DateTime() func thus not available at the point you are trying to use it.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...