Sign in to follow this  
Followers 0
alaisa22

Eror Variable used without being declared

2 posts in this topic

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

Share this post


Link to post
Share on other sites



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0