Jump to content

Recommended Posts

Posted (edited)

I declare the central, most important global array/table right at the beginning of the code -- there's no possible way to bypass or ignore this declaration. To try to troubleshoot this issue, I tried testing to see if it was declared, and that func call reported the same error. Why am I seeing the error "Variable used without being declared" (see screenshot)?

The two dimensional global array/table ($G_CurrentVidList) is spelled correctly, and as I said is undeniably declared long before. Whatever screwy error I made, it was a weird one!

Here's the function that produces that error:

Func _GetFullPlayingVidInfoListAbbrev( ByRef $argOut_VidList )

;
;   This function returns a complete list of every running VLC process. The rerturn array will contain the same info,
;   in the same order, as a row in the $G_CurrentVidList table, so it can be copied into the desired entry in that
;   table with a simple loop. However, the caller could have additional columns that this function does not fill.
;
;   The key data are the PID and Window handle of every running VLC process, although the rest of that table row is
;   returned as well.
;
;   Note that the return/output array is coded generically, because we may be writing into different output tables
;   with different uses.
;

    Local $Lf_NumVLCProcs, $Lf_TotalNumProcs, $Lf_NumVLCWins, $Lf_ThisWinTitle, $Lf_ThisWinHdl, $Lf_FoundVidListIndex
    Local $Lf_PID, $Lf_ParentPID, $Lf_ThisVLCPath, $Lf_CmdLine, $Lf_VidPath, $Lf_WinHdl, $Lf_TestPID, $Lf_TestPath
    Local $Lf_Index=0, $Lf_Stat, $Lf_Drv, $Lf_Dir, $Lf_FileName, $Lf_ExtWithDot, $Lf_ExtNoDot, $Lf_ErrText
    Local $Lf_ConflictingVLC, $Lf_ActualVLCPath, $Lf_VLCExeList[1][3], $Lf_VLCExeListCount, $Lf_OurVLCPath
    Local $Lf_ReLaunchList[1][2], $Lf_ReLaunchListCount, $Lf_FoundPlayingListIndex

    Local $Lf_PlayingList[1][$Gc_NumPlayListCols], $Lf_NumArgOutCols

    $Lf_NumArgOutCols = UBound($argOut_VidList, $UBOUND_COLUMNS)
    ReDim $argOut_VidList[1][$Lf_NumArgOutCols]

    Local $Lf_VLCProcAra = ProcessList( "VLC.exe" )
    $Lf_NumVLCProcs = $Lf_VLCProcAra[0][0]
    If $Lf_NumVLCProcs = 0 Then
        Return 0
    EndIf

; / / / / / / / /

    Local $Lf_VLCWinAra = WinList( "[CLASS:Qt5QWindowIcon]" )
    $Lf_NumVLCWins = $Lf_VLCWinAra[0][0]
    If $Lf_NumVLCWins = 0 Then
        ReDim $argOut_VidList[1][$Lf_NumArgOutCols]
        Return 0
    EndIf


    For $i = 1 To $Lf_NumVLCWins

        $Lf_ThisWinTitle = $Lf_VLCWinAra[$i][0]
        If ( StringInStr($Lf_ThisWinTitle, "VLC media player", $STR_NOCASESENSEBASIC) > 0 ) Then

            $Lf_ThisWinHdl = $Lf_VLCWinAra[$i][1]
            $Lf_TestPID = WinGetProcess( $Lf_ThisWinHdl )
            If $Lf_TestPID <> -1 Then
                For $j = 0 To UBound($Lf_PlayingList) -1
                    If $Lf_PlayingList[$j][$Gc_PlayListPIDIx] = $Lf_TestPID Then
                        $Lf_PlayingList[$j][$Gc_PlayListWinHdlIx] = $Lf_ThisWinHdl
                        $Lf_PlayingList[$j][$Gc_PlayListTitleIx] = $Lf_ThisWinTitle
                    EndIf
                Next
            EndIf
        EndIf

    Next

    If ($Lf_NumVLCProcs = 0) Or ($Lf_NumVLCWins = 0) Then
        ReDim $argOut_VidList[1][$Lf_NumArgOutCols]
        Return 0
    EndIf

    ReDim $Lf_PlayingList[$Lf_NumVLCWins][$Lf_NumArgOutCols]
    For $i = 0 To $Lf_NumVLCWins -1

        If ($i > (UBound($Lf_PlayingList) -1)) Or ($i > (UBound($Lf_PlayingList) -1)) Then
            ExitLoop
        EndIf

        $Lf_PlayingList[$i][$Gc_VideoPathIx] = $Lf_PlayingList[$i][$Gc_PlayListPathIx]
        $Lf_PlayingList[$i][$Gc_VideoTitleIx] = _PathToTitle( $Lf_PlayingList[$i][$Gc_PlayListPathIx] )

        $Lf_FoundVidListIndex = _ArraySearch( $G_CurrentVidList, $Lf_PlayingList[$i][$Gc_PlayListPathIx] )  ; <<<<< ERROR HERE ($G_CurrentVidList Not Decl)
        If $Lf_FoundVidListIndex = -1 Then                          ; Probably a Not Found error

            If @error <> 6 Then                                     ; 6 = Not Found
                _UpdStatusMsg("_GetFullPlayingVidInfoList() -- _ArraySearch Returned @error = " & @error)
                MsgBox($MB_OK, $Gc_Title, "_GetFullPlayingVidInfoList() -- _ArraySearch Returned @error = " & @error)
                Exit
            Else
                $Lf_FoundVidListIndex = Number( _FirstUnusedVideoIndex() )
                $Lf_FoundPlayingListIndex = $i
            EndIf

        Else

            If Not IsNumber( $Lf_FoundVidListIndex ) Then
                Local $Lf_TEMPOVal = Asc( $Lf_FoundVidListIndex )
                _UpdStatusMsg("_GetFullPlayingVidInfoList() -- hEy! - $Lf_FoundVidListIndex is NON-NUMERIC, = 0x" & Hex($Lf_TEMPOVal, 3) )
                $Lf_FoundVidListIndex = Number( $Lf_FoundVidListIndex )
            EndIf

            $Lf_PlayingList[$i][$Gc_VidIndexIx] = $G_CurrentVidList[$Lf_FoundVidListIndex][$Gc_VidIndexIx]

        EndIF

        _CustomPathSplit( $Lf_PlayingList[$i][$Gc_PlayListPathIx], $Lf_Drv, $Lf_Dir, $Lf_FileName, $Lf_ExtWithDot )
        If $Lf_FileName = "" Then                                       ; If null filename, then probably DVD
            $Lf_PlayingList[$i][$Gc_VideoNameIx] = $Lf_Drv & $Lf_Dir
        Else
            $Lf_PlayingList[$i][$Gc_VideoNameIx] = $Lf_FileName & $Lf_ExtWithDot
        EndIf
        $Lf_PlayingList[$i][$Gc_VideoStateIx] = $Gc_StateInMem
        $Lf_PlayingList[$i][$Gc_VideoPreActive] = True
    Next

    If $Lf_NumVLCProcs > $G_HighestNumVLCProcs Then
        $G_HighestNumVLCProcs = $Lf_NumVLCProcs
    EndIf

    If $Lf_NumVLCProcs < $G_HighestNumVLCProcs Then
        _UpdStatusMsg("_GetFullPlayingVidInfoList() - HEY! Resulting # of processes DECREASED to #" & $Lf_NumVLCProcs)
    EndIf

    _UpdStatusMsg("_GetFullPlayingVidInfoList() - Resulting # of processes = " & $Lf_NumVLCProcs & ",  # VLC Wins = " & $Lf_NumVLCWins )

    ReDim $argOut_VidList[$Lf_NumVLCWins][$Lf_NumArgOutCols]    ; Recall that the number of return columns is variable
    For $i = 0 To $Lf_NumVLCWins -1
        For $J = 0 To $Lf_NumArgOutCols -1
            $argOut_VidList[$i][$j] = $Lf_PlayingList[$i][$j]
        Next
    Next

    Return $Lf_NumVLCWins

EndFunc

 

2019-09-09_14-38-04.jpg

Edited by Mbee
Posted

Thank you, @Danp2 !  Although the code I posted didn't include it, I'd already tried that. Strangely enough, it reported that the array was undeclared before it even entered the "IsDeclared" function!  That's what is shown in the image I posted in my OP.

This is a weird one, alright...

Posted (edited)

@Mbee No, the image shows that you are using IsDeclared() incorrectly. I tried to show you the correct syntax in my earlier post. Compare that to your screenshot to see the difference.

Edit: Another possibility is that the variable is being removed by Au3Stripper. If that's the issue, you can resolve it using the #Au3Stripper_Ignore_Variables directive.

Edited by Danp2
Posted
  On 9/9/2019 at 9:32 PM, Danp2 said:

@Mbee No, the image shows that you are using IsDeclared() incorrectly. I tried to show you the correct syntax in my earlier post. Compare that to your screenshot to see the difference.

Edit: Another possibility is that the variable is being removed by Au3Stripper. If that's the issue, you can resolve it using the #Au3Stripper_Ignore_Variables directive.

Expand  

Thank you again, @Danp2! I very much appreciate your correction regarding the correct syntax for the IsDeclared() Function. With that call corrected, it is indeed finding that the table is undeclared. So, regarding your #Au3Stripper_Ignore_Variables suggestion, where should I insert that directive? After I declare the array, or in the function that encounters the error, or both?  I'm about to try both, but I thought I'd ask in the meantime...

 

Posted

Well, I tried the "both" option and the inside the function alternatives, but they don't help. Would you kindly provide more assistance, please?

Posted (edited)
  On 9/9/2019 at 10:22 PM, Danp2 said:

Might be good if you post the line of code where $G_CurrentVidList is being declared. Au3Stripper may not be the cause, but if you place the input cursor within the Au3 directive and then press F1, it should take you to a help file entry for Au3Stripper.

Expand  

Here's the declaration:

Global $G_CurrentVidList[$L_CombinedCount][$Gc_NumVidListCols]

The "$L_CombinedCount" variable will always be greater than zero by this point. If it were <= 0, I would have exited already.

I'd already seen the help file for the Au3Stripper directive in question, and the following looks syntactically correct:

#Au3Stripper_Ignore_Variables=$G_CurrentVidList

However, after my earlier learning experience, I also tried:

#Au3Stripper_Ignore_Variables="$G_CurrentVidList"

Neither one worked. I also tried spaces around the equal sign, with no improvement.

Let me see if I understand what we're trying to do in order to work around this issue. My supposition is that the main AutoIt build process is such that the interpreter (perhaps there's a more appropriate term?)  examines every statement or variable expression. One of those checks is to confirm that the variable in question is within the current scope, which of course also includes ensuring that the variable is declared in the first place.

This check is going wrong for some reason with my global table. So as a workaround, we want a way to tell the interpreter to either skip that check or force it to think it has passed the check. Here's where my meager knowledge store comes up short. Is it possible that the Au3Stripper is functioning at the wrong build layer and there's an alternative workaround? One that more directly addresses the interpreter itself or it's output?

Please educate me, good madam or sir!

 

Edited by Mbee
Posted

Like I said earlier, I may have misdirected you when I mentioned Au3stripper. I would suggest that we step back and examine your development environment --

  • What's your Autoit version?
  • Are you running the script from within Scite? If so, do you have the full version installed?
  • Are you using #include to pull in any custom scripts/UDFs?
  • Is AU3Check being executed when / if you run the script from Scite?
  • etc
Posted

You know, kind @Danp2, I'm more and more suspicious of my own code, and arguably I should have been more so before creating this thread. I think I probably have a tricky logic sequence or error, which is vastly more probable than an issue with our beloved AutoIt system.

My brain has turned to goo, and even if not, I'd say let's drop this until I have a more solid base upon which to stand. I am exceptionally grateful for your intelligent assistance!

Thanks again

Posted

Please post the head of your main source, where you have #includes and Global declarations.

Most probably a reference to the variable is made in code from an include sitting before the varirable declaration.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Is your Debug.Script an include into a main script? If it is do you put the #include line before the global declarations? If so, then that is the problem, move the #include line below the global declarations.

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!

  Reveal hidden contents

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

Posted (edited)

In your main AU3 file:

Use:

#Au3Stripper_Parameters=/MO /RSLN

to be sure that compiled version and ***_stripped.au3 have the same content

Use:

#AutoIt3Wrapper_Run_AU3Check=Y
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

to initially/quickly check your code before runtime.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...