Jump to content

Declaring a blank array.


Recommended Posts

Hi Team,

 

I am new to programming and new to AutoIT as well. I'm currently working on a Chat Monitoring Bot that has a Dynamic Table on it that adds Columns every time a new Chat has appeared. Problem is I cannot declare a blank array. Kinda solve the problem but my code is too long. Just wanted to see if anyone can help me simplify my code.

$oTable2 = _IETableGetCollection($oIE,95)
$aTableData2 = _IETableWriteToArray($oTable2)
;_ArrayDisplay($aTableData2)

$iCols2 = UBound($aTableData2, $UBOUND_COLUMNS)
$ChatSession = $iCols2-1

msgbox(0,"No. of Chat Session",$ChatSession, 1)
$oSp.Speak("We currently have " & $ChatSession & "active Chat sessions.")



if $ChatSession = 1 Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

ElseIf $ChatSession = 2  Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

ElseIf $ChatSession = 3  Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

   $cust3 = $aTableData2[0][3]
   $agent3 = $aTableData2[3][3]
   $sTime3 = $aTableData2[5][3]

ElseIf $ChatSession = 4  Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

   $cust3 = $aTableData2[0][3]
   $agent3 = $aTableData2[3][3]
   $sTime3 = $aTableData2[5][3]

   $cust4 = $aTableData2[0][4]
   $agent4 = $aTableData2[3][4]
   $sTime4 = $aTableData2[5][4]

ElseIf $ChatSession = 5  Then

   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

   $cust3 = $aTableData2[0][3]
   $agent3 = $aTableData2[3][3]
   $sTime3 = $aTableData2[5][3]

   $cust4 = $aTableData2[0][4]
   $agent4 = $aTableData2[3][4]
   $sTime4 = $aTableData2[5][4]

   $cust5 = $aTableData2[0][5]
   $agent5 = $aTableData2[3][5]
   $sTime5 = $aTableData2[5][5]

 

 

Edited by MozQue
insert to code tag
Link to comment
Share on other sites

Hello. Just do this.

Local $acusts[$ChatSession]
Local $agents[$ChatSession]
Local $aTimes[$ChatSession]

For $i=0 to $ChatSession-1
    $acusts[$i]=$aTableData2[0][$i+1]
    $acusts[$i]=$aTableData2[3][$i+1]
    $aTimes[$i]=$aTableData2[5][$i+1]
Next

Saludos

Link to comment
Share on other sites

1 hour ago, faustf said:
28 minutes ago, Danyfirex said:

Hello. Just do this.

Local $acusts[$ChatSession]
Local $agents[$ChatSession]
Local $aTimes[$ChatSession]

For $i=0 to $ChatSession-1
    $acusts[$i]=$aTableData2[0][$i+1]
    $acusts[$i]=$aTableData2[3][$i+1]
    $aTimes[$i]=$aTableData2[5][$i+1]
Next

Saludos

having errors ==> Variable used without being declared.:

 

Link to comment
Share on other sites

Personally, I don't see the point of transferring data from one array to separate variables or other arrays.  But there may be good reasons that I cannot foresee.  In any case you could also use this :

; this is required if you want to normally use the variables created with the assign function, since they are not declared anywhere
#AutoIt3Wrapper_Run_AU3Check=n

For $i = 1 To $ChatSession
  Assign ("cust" & $i,$aTableData2[0][$i],$ASSIGN_CREATE)
  Assign ("agent" & $i, $aTableData2[3][$i],$ASSIGN_CREATE)
  Assign ("time" & $i, $aTableData2[5][$i],$ASSIGN_CREATE)
Next

 

Link to comment
Share on other sites

@MozQue Provide a runable script for testing. Write just your returned error say nothing to be able to help you.

 

Saludos

Link to comment
Share on other sites

1 hour ago, Danyfirex said:

@MozQue Provide a runable script for testing. Write just your returned error say nothing to be able to help you.

can provide the whole script as it contains a username and passwords.

1 hour ago, Danyfirex said:

 

Saludos

 

Link to comment
Share on other sites

Change the user names and passwords to something that isn't a real one, that should have been obvious to you.

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

#include <Array.au3>
#include <IE.au3>
#include <Date.au3>
#include <MsgBoxConstants.au3>


;-- Variables
Global $oIE,$oIE2,$oIE3,$uname,$pass,$submit,$sMyString,$oLinks,$supportnow,$session,$refresh,$oTable,$aTableData
global $iCols,$ChatWaiting,$oTable2,$aTableData2,$iCols2,$ChatSession, $iCols3, $ChatSession3
Global $cust1, $cust2, $cust3, $cust4, $cust5, $cust6, $cust7, $cust8, $cust9, $cust10, $cust11, $cust12, $cust13, $cust14, $cust15
Global $agent1, $agent2, $agent3, $agent4, $agent5, $agent6, $agent7, $agent8, $agent9, $agent10, $agent11, $agent12, $agent13, $agent14, $agent15
Global $sTime1, $sTime2, $sTime3, $sTime4, $sTime5, $sTime6, $sTime7, $sTime8, $sTime9, $sTime10, $sTime11, $sTime12, $sTime13, $sTime14, $sTime15
Global $report, $reportarea, $getreport, $oTable3, $aTableData3

;--Variables for Chat count
Global $sAgent1,$sAgent2,$sAgent3,$sAgent4,$sAgent5,$sAgent6,$sAgent7,$sAgent8,$sAgent9,$sAgent10,$sAgent11,$sAgent12,$sAgent13,$sAgent14,$sAgent15
Global $sAHT1,$sAHT2,$sAHT3,$sAHT4,$sAHT5,$sAHT6,$sAHT17,$sAHT8,$sAHT9,$sAHT10,$sAHT11,$sAHT12,$sAHT13,$sAHT14,$sAHT15
Global $sCount1,$sCount2,$sCount3,$sCount4,$sCount5,$sCount6,$sCount7,$sCount8,$sCount9,$sCount10,$sCount11,$sCount12,$sCount13,$sCount14,$sCount15

RunWait('taskkill /F /IM "iexplore.exe"')

_IEErrorHandlerRegister()
Sleep(1000)
$oIE = _IECreate("https://secure.logmeinrescue.com/account/login",0,1)
Sleep(1000)
_IELoadWait($oIE)
Sleep(2000)

Sleep(1000)

$uname = _IEGetObjByName ($oIE, "Email")
$pass = _IEGetObjByName($oIE, "Password")
$submit = _IEGetObjById($oIE, "btn-login-continue")

Sleep(2000)
_IEFormElementSetValue ($uname, "**************")
_IEFormElementSetValue($pass, "**************")")
Sleep(1000)
_IEAction($submit, "click")
Sleep(2000)

;$oIE2 = _IECreate("https://secure.logmeinrescue.com/Account/My",1)
$sMyString = "Launch Admin Center"
$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
 Next

local $oSp = ObjCreate("SAPI.SpVoice")
$oSp.speak("Initializing")

sleep(1000)
;$oIE3 = _IECreate("https://secure.logmeinrescue.com/US/AdminCenter/Console",1)

$supportnow = _IEGetObjById($oIE, "nodeid_g_4220757")
 _IEAction($supportnow, "click")

Sleep(500)
$session = _IEGetObjById($oIE, "Sessions_div")
_IEAction($session, "click")
Sleep(500)


while 1
Sleep(3000)
$refresh = _IEGetObjById($oIE, "refresh_div_text")
local $refresh1 = $refresh.innertext
MsgBox(0,"",$refresh1,1)
If $refresh1 = "Refresh" Then
sleep(500)
_IEAction($refresh, "click")
Sleep(500)
;Else
;MsgBox(0,"Refresh Status","Refresh not found")
;ExitLoop
EndIf

;-- get the waiting chat table
$oTable = _IETableGetCollection($oIE,94)
$aTableData = _IETableWriteToArray($oTable)
;_ArrayDisplay($aTableData)

;--get number of chat waiting
$iCols = UBound($aTableData, $UBOUND_COLUMNS)
;If $iCols = 2 Then
$ChatWaiting = $iCols-1
   msgbox(0,"No. of Chat Waiting",$ChatWaiting, 1)

If $ChatWaiting > 0 Then
   $oSp.Speak("IM Team, we have" & $ChatWaiting & ",chat waiting, please assist")
endIf

;--get longest time waiting
local $Count = UBound($aTableData,2)
;MsgBox(0,"",$Count)
If $Count >=2 Then
$longestWaitTime = $aTableData[3][1]

;local $minutes = _ArrayToString($aTableData[3][1])
  ; MsgBox(0,"",$minutes)
   ;MsgBox(0,"Wait Time",$longestWaitTime,1)
   ;$oSp.Speak("for" & $longestWaitTime & ",please assist.")
EndIf

$oTable2 = _IETableGetCollection($oIE,95)
$aTableData2 = _IETableWriteToArray($oTable2)
;_ArrayDisplay($aTableData2)

$iCols2 = UBound($aTableData2, $UBOUND_COLUMNS)
$ChatSession = $iCols2-1

msgbox(0,"No. of Chat Session",$ChatSession, 1)
$oSp.Speak("We currently have " & $ChatSession & "active Chat sessions.")


;$oIE2 = _IECreate("C:\Users\pbuera938\Downloads\dashboard.html",1,1,1,1)
;local $chatters = _IEGetObjById($oIE, "activeChat")
;_IEPropertySet($chatters,"innertext",$ChatSession)

if $ChatSession = 1 Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

ElseIf $ChatSession = 2  Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

ElseIf $ChatSession = 3  Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

   $cust3 = $aTableData2[0][3]
   $agent3 = $aTableData2[3][3]
   $sTime3 = $aTableData2[5][3]

ElseIf $ChatSession = 4  Then
   $cust1 = $aTableData2[0][1]
   $agent1 = $aTableData2[3][1]
   $sTime1 = $aTableData2[5][1]

   $cust2 = $aTableData2[0][2]
   $agent2 = $aTableData2[3][2]
   $sTime2 = $aTableData2[5][2]

   $cust3 = $aTableData2[0][3]
   $agent3 = $aTableData2[3][3]
   $sTime3 = $aTableData2[5][3]

   $cust4 = $aTableData2[0][4]
   $agent4 = $aTableData2[3][4]
   $sTime4 = $aTableData2[5][4]
Endif   
Wend

 

Edited by MozQue
Link to comment
Share on other sites

  • Moderators

As has already been pointed out @MozQue hard coding your comcast credentials for all to see isn't the most intelligent approach. You might want to remove those.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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