Jump to content

diff

Active Members
  • Posts

    21
  • Joined

  • Last visited

Reputation Activity

  1. Like
    diff got a reaction from Leendert-Jan in Reuse function variables in other function without Global   
    Hello,
     
    feeling dumb that I can't resolve my issue, my point is to not use Global variables in bigger projects at all.
    So I have 2 functions, the first is main function and the second searching for information from websites and attaches the extracted information to variables.
     
    Func main() ...does some code... ..then later i have some code which need to use variables from web_extraction() function.. example: StringStripWS($var1, 3) Of course I get here error that variable $var1 possibly not declared EndFunc Func web_extraction() ..does some code... ...extracts information from websites.. $var1 = "extracted info 1" $var2 = "extracted info 2" etc etc. EndFunc Of course I can write at the beginning 
    Global $var1, $var2 and this will work, but how I can use $var1, $var2 which kill itself after function ends in main function?
     
    I have read a lot of information about $params in function and etc. tried everything and still receive that the variables are possibly not declared and just stay blank inside.
    Any examples how correctly to write this?
  2. Thanks
    diff reacted to Subz in Func with parameters with saving results   
    Use two parameters for example: _executionFunc($firstValue, $secondValue) and then process both values at the same time within the function.  You could also use a flag
    Basic example (note, don't really understand the need for _ArrayToString, or if you're adding, concatenating data to $collectedDataFromFirstValue)
    Global $collectedDataFromFirstValue = "" _excutionFunc($firstValue, 1) _excutionFunc($secondValue) Func _excutionFunc($_Value, $_iFlag = 0) Switch $_iFlag Case 1 $collectedDataFromFirstValue &= $_Value Case Else ;~ Do something for other values EndSwitch EndFunc  
  3. Thanks
    diff reacted to Nine in Struggling with _Word_DocPictureAdd   
    There was a number of typos in your snippet, but here a clean working example :
    #include <Word.au3> Local $oWord = _Word_Create() Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\V.doc", Default, Default, True) $oSearchRange = _Word_DocRangeSet($oDoc, -1) $oRangeFound = _Word_DocFind($oDoc, "Dijon", $oSearchRange) $oSearchRange = _Word_DocRangeSet($oDoc, $oRangeFound, $wdParagraph, 1) _Word_DocPictureAdd($oDoc, @ScriptDir & "\Pic1.jpg", Default, Default, $oRangeFound)  
  4. Like
    diff reacted to Musashi in Count duplicates by word in array   
    Here an example also with "partial search" :
    #include <Array.au3> Local $sSearch, $aResult Local $aArray = ["Peter John Doe", "Martin", "Potter", "John", "Marta", "Lola", "John"] _ArrayDisplay($aArray, "SearchArray") ; *** just to display the array $sSearch = "John" ; Parameter $iCompare = 1 ==> executes a partial search ; ---------------------------------------------------------------V----------- $aResult = _ArrayFindAll($aArray, $sSearch, Default, Default, 0, 1, 0, False) _ArrayDisplay($aResult, "$iCompare = 1") ; *** just to display the array MsgBox(BitOR(4096,96), "Result 1 :", $sSearch & " was found " & UBound($aResult) & " time(s)" & @CRLF) ; Parameter $iCompare = 2 ==> comparison match same type and same value ; ---------------------------------------------------------------V----------- $aResult = _ArrayFindAll($aArray, $sSearch, Default, Default, 0, 2, 0, False) _ArrayDisplay($aResult, "$iCompare = 2") ; *** just to display the array MsgBox(BitOR(4096,96), "Result 2 :", $sSearch & " was found " & UBound($aResult) & " time(s)" & @CRLF)  
  5. Like
    diff reacted to Melba23 in Count duplicates by word in array   
    diff,
    If you declare the array correctly and read the Help file to see that _ArrayFindAll returns an array which does not display in a MsgBox, you get this:
    #include <Array.au3> Local $aArray = ["John", "Martin", "Potter", "John", "Marta", "Lola", "John"] $sName = "John" $aFindDup = _ArrayFindAll($aArray, $sName) _ArrayDisplay($aFindDup, "", Default, 8) MsgBox(0, "", UBound($aFindDup)) which works fine for me.
    M23
×
×
  • Create New...