Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/08/2021 in all areas

  1. RTFC

    Code Scanner

    Hi Everyone, This is my first-ever post to this forum, and it's also the first forum I ever joined, after visiting anonymously for some time. I've been very impressed by both the level of expertise and the friendly, helpful, generous, and funny replies to OPs by the large majority of members. My main intention in joining was to share some potentially useful scripts of mine with the community. I've been programming for many years, and since a few months, also in AutoIt. On the other hand, I've no clue about posting stuff, so here goes (fingers crossed): I wrote this one to help solve dependency issues in some larger AutoIt projects of mine, but it should be equally useful for small/simple projects. It's not meant to replace AU3check, but to provide additional info on your project, and identify *possible* runtime issues that the compiler does not pick up. You then have to figure out yourself whether/where/how to change your code. Also be warned that the file I/O is tectonically slow (definitely room for improvement there). Download CodeScanner and associated UDFs in the CodeScannerCrypterBundle. This utility scans an AutoIt code project with multiple #includes and/or UDFs for inconsistencies, clashes, and various other hidden (potential) problems. It also generates MetaCode files for use with CodeCrypter and the MCf library. It does NOT alter your code; it just reads, evaluates, and reports. 36 Optional Outputs (from version 2.0😞 status report (text file), identifying: missing #includes, duplicate UDFs (lists all occurrences with their resp. parameters); issues with global definitions, unresolved function parameters... searchable treeviews of code architecture (nested #includes, nested function calls (UDF + native AUtoIt); detailed stats for each selected branch (who calls X, who is called by X) array listings (some 2-D) of: identified potential issues; unique #includes, redundant #includes; unique UDFs with calling stats; globals; all locations/definitions of UDF func def/endfunc, all calls, all #includes, all globals, all variables, all literal strings, all native AutoIt functions (with parameters) definition list of all globals identified only within UDFs, written out as script for easy inclusion at top of your script (so all globals are predefined in main code) MetaCode files (see the MetaCode thread (esp. the Tutorial) for details: '?do=embed' frameborder='0' data-embedContent>>) all results can be written to text files and read in to other scripts in their original array formats with an additionally supplied small UDF. You can edit the code to add more yourself; I'm gradually extending its functionality as/when required for my own projects. Hope it helps!
    1 point
  2. Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Moderation Team
    1 point
  3. Hm, the cause seems to be simple: StringBetween is doing what it should - it returns the text between your <div class="accordion-item"> and the first </div> without including the search-texts itself. So you'd need to find another end-string or solve it via regex. in your case, you could #include <String.au3> Global $HTML_Test $HTML_Test &= '<div class="accordion-item">' & @CRLF ; <!---- START GET--> $HTML_Test &= ' <div class="accordion-inner">' & @CRLF $HTML_Test &= ' <p>Khoá an toàn giúp bếp luôn được an toàn</p>' & @CRLF $HTML_Test &= ' </div>' & @CRLF $HTML_Test &= ' <a href="#" class="accordion-title plain">' & @CRLF $HTML_Test &= ' <button class="toggle">' & @CRLF $HTML_Test &= ' <i class="icon-angle-down"></i>' & @CRLF $HTML_Test &= ' </button>' & @CRLF $HTML_Test &= ' <span>Khoá an toàn</span>' & @CRLF $HTML_Test &= ' </a>' & @CRLF $HTML_Test &= '</div>' & @CRLF ;<!---- END GET --> Global $aSearch = _StringBetween($HTML_Test, '<div class="accordion-item">', '</a>' & @CRLF & '</div>') If IsArray($aSearch) Then For $i = 0 To UBound($aSearch) - 1 ConsoleWrite('!-> SB Return: ' & $aSearch[$i] & @CRLF) Next Else ConsoleWrite('! SB: No strings found. ' & @CRLF) EndIf so you'll get the inner text. Of course the closing </a> gets lost because it is included in the $sEnd-String. Or with a regex: #include <String.au3> Global $HTML_Test $HTML_Test &= '<div class="accordion-item">' & @CRLF ; <!---- START GET--> $HTML_Test &= ' <div class="accordion-inner">' & @CRLF $HTML_Test &= ' <p>Khoá an toàn giúp bếp luôn được an toàn</p>' & @CRLF $HTML_Test &= ' </div>' & @CRLF $HTML_Test &= ' <a href="#" class="accordion-title plain">' & @CRLF $HTML_Test &= ' <button class="toggle">' & @CRLF $HTML_Test &= ' <i class="icon-angle-down"></i>' & @CRLF $HTML_Test &= ' </button>' & @CRLF $HTML_Test &= ' <span>Khoá an toàn</span>' & @CRLF $HTML_Test &= ' </a>' & @CRLF $HTML_Test &= '</div>' & @CRLF ;<!---- END GET --> ; Global $aSearch = _StringBetween($HTML_Test, '<div class="accordion-item">', '</a>' & @CRLF & '</div>') $aSearch = StringRegExp($HTML_Test, '(?s)<div class="accordion-item">(.*)</div>',3) If IsArray($aSearch) Then For $i = 0 To UBound($aSearch) - 1 ConsoleWrite('!-> SB Return: ' & $aSearch[$i] & @CRLF) Next Else ConsoleWrite('! SB: No strings found. ' & @CRLF) EndIf best regards, Marc
    1 point
  4. Please elaborate on why you need to do this.
    1 point
  5. jchd

    DllStructs strange behavior

    That's the problem with pointers: whatever rock-solid vault you save it in, the "thing" the pointer points to (a block of memory) has to be kept alive until further use of the pointer, else anything bad can happen. I don't recall that AutoIt uses a garbage collector. I believe the allocated block is just returned to the system. If you allocate a much larger block, an exception almost always results because the system is more likey to require an allocation fitting the hole made by releasing the initial block. For $i = 1 To 5 Test() Next Func Test() Local $pStruct = DllStructGetPtr(CreateStruct()) ConsoleWrite($pStruct & @CRLF) Local $tStruct = DllStructCreate('wchar Test[1000000];', $pStruct) ConsoleWrite('Value: ' & $tStruct.Test & @CRLF & @CRLF) EndFunc Func CreateStruct() Local $tStruct = DllStructCreate('wchar Test[1000000];') ConsoleWrite(DllStructGetPtr($tStruct) & @CRLF) DllStructSetData($tStruct, 'Test', 'test') Return $tStruct EndFunc Yields an access violation at the second loop every time I ran it: 0x05F97020 0x05F97020 !>13:40:26 AutoIt3.exe ended.rc:-1073741819
    1 point
×
×
  • Create New...