Jump to content

Used to work!! Something different about new Autoit version?


deef99
 Share

Recommended Posts

This code has been working fine. Made a few changes [in green] and now it won't work at all.

Can someone help me please? Can't be a big deal for the simple change... Appreciate any help!

THIS IS THE ERROR:

G:\Avaya_OS_Ticker\OS_SkillCheck_Live_1109.au3 (68) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$vOCW = Number($aTemp[2])

$vOCW = Number(^ ERROR

#region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Outfile=G:\Avaya_OS_Ticker\CallTicker.exe

#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker

#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Date.au3>

#include <File.au3>

#include "array.au3"

#include "String.au3"

#include <Sound.au3>

#include <Constants.au3>

Opt("TrayMenuMode", 0) ; Default tray menu items (Script Paused/Exit) will not be shown.

Opt("WinTitleMatchMode", 1) ;1=start of text

HotKeySet("^z", "Terminate"); Press Ctrl z to terminate script

;LIVE Aug2011 Checks file in g:\Avaya_OS_Ticker to see if Calls waiting for Major skills and pops on agent desktop

;11-9-2011 Made changes

;2-2-2012 Seperated Newsletters and Supplements Alert

Global $result, $vskill, $vOCW, $tCur, $tday, $logfile, $hds, $hdn, $jd1, $sloop, $iq, $newlog

Global $line, $vname, $i, $aTemp[4],$aLines[3]

$message = ""

$hds = 0 ;sound variable

$jd1 = 0

$sloop = 0 ;sound loop - reset hds if we've looped 30 times.

$hdn = 0 ;check for number of loops

$vname = ""

$i = 1

;open sound file

$sound = _SoundOpen("\\ardfiles02\common\Avaya_OS_Ticker\tada.wav")

;set the MM_YYYY for log file

$tday = @MON & "_" & @MDAY

While 9 = 9

;_FileReadToArray("\\ardfiles02\common\avaya_OS_ticker\skillcheck.txt", $aLines)

_FileReadToArray("c:\temp\s.txt", $aLines)

;FileOpen($logfile, 1)

For $i In $aLines

$line = $aLines[$i]

;grab the skill, OCW,in queue

$aTemp = StringSplit($line, ",")

$vskill = Number($aTemp[1]) ;skill number

$vOCW = Number($aTemp[2]) ;time in queue

$iq = Number($aTemp[3]) ;Calls in Queue

If $vskill = 740 Or $vskill = 690 Or $vskill = 707 Then

If $vskill = 740 Then

$vname = "X NEWSLETTERS"

If $vskill = 690 Then

$vname = "X Supplements"

If $vskill = 707 Then

$vname = "X CCC"

Else

$vname = "X Other"

EndIf

EndIf

EndIf

EndIf

If $vOCW >= 150 Or $iq >= 5 Then

If $hds = 0 Then

$result = $vname & " shows OCW " & $vOCW & " seconds -- " & $iq & " Calls in Queue"

;FileWrite($logfile, $tCur & $result & @CRLF)

_SoundPlay($sound, 1)

$hds = 1

EndIf

$sloop = $sloop + 1 ;played sound set flag to no sound

$message = $vname & " has Calls in Queue!"

SplashTextOn("LOG IN IMMEDIATELY!", $message, 220, 60, 875, 12, -1, "Arial", 9, 500)

ControlSetText("LOG IN IMMEDIATELY!", "", "Static1", $message)

Sleep(2000)

Else

$hdn = $hdn + 1

EndIf

Next

If $hdn >= 6 Then

$hdn = 0

SplashOff()

Sleep(2000)

EndIf

If $hds = 1 Then

$sloop = $sloop + 1

EndIf

If $sloop >= 20 Then

$hds = 0

$sloop = 0

EndIf

If @HOUR >= 22 Then Exit

WEnd

Func Terminate()

;FileClose($logfile)

_SoundClose($sound)

Exit 0

EndFunc ;==>Terminate

Link to comment
Share on other sites

This is an extremely easy debugging - you should think a little bit ... The error is in here:

$line = $aLines[$i] $aTemp = StringSplit($line, ",")
You should check first the content of the $line variable and after that the result in $aTemp - not hard at all, all you have to do is try.

It has nothing to do with your changes.

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

I apologize. I do not understand arrays. Maybe simple for you, but mindbogling for me.

I don't even understand what you are trying to say to me. I am sorry to take up your time.

Edited by deef99
Link to comment
Share on other sites

If you use For $i In $aLines then $i will become the nth element of $aLines array in nth loop. Which means you can either use

For $element In $aLines
;grab the skill, OCW,in queue
$aTemp = StringSplit($element, ",")

or

For $i To $aLines[0]
;grab the skill, OCW,in queue
$aTemp = StringSplit($aLines[$i], ",")

And also if you add [autoit] tags before and after the code you want to share it will be easier for forum members to follow.

Sincerely,

Tip

Edited by tip

[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Link to comment
Share on other sites

Made this change in the code:

For $i In $aLines[0]

  $line = $aLines[$i]
  ;grab the skill, OCW,in queue
  $aTemp = StringSplit($line, ",")
MsgBox(4096,"",$aLines)

And now get this error:

G:Avaya_OS_TickerOS_SkillCheck_Live_1109.au3 (48) : ==> Variable must be of type "Object".:

For $i In $aLines[0]

For $i In $aLines[0]^ ERROR

Link to comment
Share on other sites

Read my answer a bit more carefully please...

One method works with "in" in the middle the other works with "to" in the middle.

I also advice you to read help files "for in next" and "for to next" sections.

Sincerely

Tip

[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Link to comment
Share on other sites

You should really take a look at the parts of your code that are simply unreachable

For example...

If $vskill = 740 Or $vskill = 690 Or $vskill = 707 Then
If $vskill = 740 Then
  ;???????????????????????????this block of code will only occur If $vskill = 740
  $vname = "X NEWSLETTERS"
  If $vskill = 690 Then ; so this cannot be
   $vname = "X Supplements"
   If $vskill = 707 Then ; or this
    $vname = "X CCC"
   Else
    $vname = "X Other"
   EndIf
  EndIf
  ;???????????????????????????this block of code will only occur If $vskill = 740
EndIf
EndIf

If '$vskill = 740' There is no possible way in the same block of code that it can be 690 and/or 707 too.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Shouldnt arrays be defined (their bounds) ?

Like

Global $line, $vname, $i, $aTemp[4],$aLines[3]

should be something like this

Global $line, $vname, $i
Dim $aTemp[4], $aLines[3]

Never use Dim to declare variables. Use Global or Local, according to where you need it declared. Dim is to be avoided.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Never use Dim to declare variables. Use Global or Local, according to where you need it declared. Dim is to be avoided.

Not that I doubt you, I would just like to know why ? :)

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

Not that I doubt you, I would just like to know why ? :)

As discussed earlier today, and referenced to post, Dim isn't the choice to use when declaring a variable. Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

As discussed earlier today, and referenced to post, Dim isn't the choice to use when declaring a variable.

Well, I learned something today. I always thought Dim was required for declaring arrays. I just tried Global to declare an array and it worked...

I suppose you still need to use ReDim for reisizing arrays, right?

#include <ByteMe.au3>

Link to comment
Share on other sites

ReDim would be used to resize the array without destroying it's contents, you can redeclare it with Global/Local if you don't need the contents retained.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

As discussed earlier today, and referenced to post, Dim isn't the choice to use when declaring a variable.

The only "why" I could find in that thread was

"AU3Check when using parameter -w6 will warn you about "Dim" being deprecated."

But sure, if Global works just as fine I'll prolly try start using that instead :)

I just always used Dim as it's kinda in the blood from doing BASIC back in the 80's, and the fact that the AU3 helpfile still says..

"Before you can start using Arrays in your script, you must define their bounds using the 'Dim' keyword."

...so, that's why I've been using it. ;)

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

The problem with using Dim is that you can accidentally reuse variable names in a function that are declared in the global scope that shouldn't be redeclared in the function. This can happen if you're using functions from somewhere else, or one of your own functions you're using in another script. It's always better to implicitly declare your variables in the proper scope, and never use Dim if you can avoid it.

Below is a small example of using Dim inside a function and how it will affect a global variable for those that are still confused.

Global $A = 1
ConsoleWrite("Before running function _Test: Global $A = " & $A & @LF)
_Test()
ConsoleWrite("After _Test: Global $A = " & $A & @LF)
_Test1()
ConsoleWrite("After running _Test1: Global $A = " & $A & @LF)

Func _Test()
    ConsoleWrite("Inside the function _Test and before using Dim: $A = " & $A & @LF)
    Dim $A = 5, $B = 3 ; $A is global, $B is local (try accessing it outside this function)
    ; do something with variable $A
    ConsoleWrite("Inside the function _Test and after using Dim: $A = " & $A & @LF)
    ConsoleWrite("Inside the function _Test and after using Dim: $B = " & $B & @LF)
EndFunc   ;==>_Test
Func _Test1()
    ConsoleWrite("Inside the function _Test1 and before using Local: $A = " & $A & @LF)
    Local $A = 2, $B = 5
    ; do something with variable $A
    ConsoleWrite("Inside the function _Test and after using Dim: $A = " & $A & @LF)
    ConsoleWrite("Inside the function _Test and after using Dim: $B = " & $B & @LF)
EndFunc   ;==>_Test1

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I redeclared it in the _Test1 function. It's a local variable because, as you stated, if you try to use it outside a function that it's declared in you get the error that it hasn't been declared. Take out the declaration statement in _Test1 and it will give you an error.

As a note to others, where I stated never use Dim if you can avoid it, you can always avoid using Dim to declare variables if you follow what I said before that and declare the variables in the scope that you want them to be valid.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I redeclared it in the _Test1 function. It's a local variable because, as you stated, if you try to use it outside a function that it's declared in you get the error that it hasn't been declared. Take out the declaration statement in _Test1 and it will give you an error.

As a note to others, where I stated never use Dim if you can avoid it, you can always avoid using Dim to declare variables if you follow what I said before that and declare the variables in the scope that you want them to be valid.

Doh!

I thought I'd gotten away with deleting that post before it was read :) was only a few seconds before I realized my mistake.

For the record, I posted that this line "$B is local (try accessing it outside this function)"

was incorrect and it was global, but infact I had messed around with the code turning 'Dim' into 'Global'.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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