DrewSS

Persistant variables

7 posts in this topic

Hello,

Can someone please tell me why this isnt working or how to get this particular part working?

After ending this loop: For $masterRe = 1 To UBound($masterArray) -1

This variable content dissapears: $queueM1

For example, this part does not work:

If $match1 = "Yes" And $queueM1 = "US_L1_Call Center System Alerts" Or $queueM1 = "US_L1_Customer Support System Alerts" And Not ($statusM1 = "RETAILER STATUS") Then
        FileWrite($RF_Updates1, "Replace" & "," & $master_st & "," & $incidentID1 & "," & $incidentticket1 & "," & "Old Description" & "," & $descriptionM1 & "," & "New Description" & "," & $T_desc & @CRLF)
    EndIf

$dbday = StringReplace(_NowCalcDate(), "/", "-")
$sFilePath_list_master = @ScriptDir & "\master.xls"
$trendsreport = @ScriptDir & "\result-" & $dbday & ".csv"
$RF_Updates= @ScriptDir & "\RF_Updates.csv"
$RF_Updates1 = FileOpen($RF_Updates, 1)
$RF_New = @ScriptDir & "\RF_New.csv"
$RF_New1 = FileOpen($RF_New, 1)
Local $masterExO = _Excel_Open()
    Local $masterEx = _Excel_BookOpen($masterExO, $sFilePath_list_master)
    Local $masterArray = _Excel_RangeRead($masterEx, Default, $masterEx.ActiveSheet.Usedrange.Columns("A:K"), 1, True)

Local $trendArray
_FileReadToArray($trendsreport, $trendArray)
For $T = 2 To Ubound($trendArray) -1
    $T1 = StringSplit($trendArray[$T], ",")
    $T_st = StringRight($T1[1], 8)
    $T_desc = $T1[8]

    Local $match1 = "No"
    For $masterRe = 1 To UBound($masterArray) -1
    $incidentID1 = $masterArray[$masterRe][0]
    $incidentticket1 = $masterArray[$masterRe][1]
    $chainM1 = $masterArray[$masterRe][3]
    $queueM1 = $masterArray[$masterRe][10]
    $statusM1 = $masterArray[$masterRe][7]
    $descriptionM1 = $masterArray[$masterRe][5]
    $categoryM1 = $masterArray[$masterRe][6]
    $master_st = ""
        If Not ($chainM1 = "") Then
            $master_st = $masterArray[$masterRe][3] & "-" & $masterArray[$masterRe][4]
        ElseIf $chainM1 = "" And $queueM1 = "US_L1_Call Center System Alerts" Or $queueM1 = "US_L1_Customer Support System Alerts" Then
            $master_st = StringLeft($descriptionM1, 8)
        EndIf
        If $T_st = $master_st Then
            $match1 = "Yes"
        ;   MsgBox($MB_SYSTEMMODAL, '', $match1 & "-" & $T_st & "-" & $master_st )
        EndIf
        ;If $queueM1= "US_L1_Call Center System Alerts" Or $queueM1 = "US_L1_Customer Support System Alerts" Then MsgBox($MB_SYSTEMMODAL, '1', $queueM1 & "-" & $match1 & "-" & $queueM1 & "-" & $statusM1  )
    Next
    If $queueM1= "US_L1_Call Center System Alerts" Or $queueM1 = "US_L1_Customer Support System Alerts" Then MsgBox($MB_SYSTEMMODAL, '2', $queueM1 & $match1 & $master_st & "-" & $statusM1)
    ;MsgBox($MB_SYSTEMMODAL, '', $match1 & "-" & $queueM1 & "-" & $statusM1 )
    If $match1 = "Yes" And $queueM1 = "US_L1_Call Center System Alerts" Or $queueM1 = "US_L1_Customer Support System Alerts" And Not ($statusM1 = "RETAILER STATUS") Then
        FileWrite($RF_Updates1, "Replace" & "," & $master_st & "," & $incidentID1 & "," &  $incidentticket1 & "," & "Old Description" & ","  & $descriptionM1 & "," & "New Description" & "," & $T_desc & @CRLF)
    EndIf
    If $match1 = "No" And Not ($master_st = "") Then
        FileWrite($RF_New1, $trendArray[$T] & @CRLF)
    EndIf

        ;_ArrayDisplay($masterArray)
Next

Share this post


Link to post
Share on other sites



There is only a single line where this variable is being set.

$queueM1 = $masterArray[$masterRe][10]
So it seems that $masterArray[$masterRe][10] is empty.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes, thats correct - out of 50 thousand records, many of the time that cell will be empty - but occasionally it will have the values i'm looking for.

however it looks like after the 2nd loop ends, that variable, along with all the other variables from $masterArray[$masterRe] lose their values. Is this some sort of global, local, thing?

 

Does the logic look or seem correct?

Share this post


Link to post
Share on other sites

Variables do not lose their content. You either assign another value to them or you try to access the variable outside of its scope.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks again water :-D

That was exactly it; the last re-assignments were empty spaces and it was totally confusing me!

 

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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