Jump to content
Sign in to follow this  
Jibsbrown

Need some help understanding...

Recommended Posts

Need some help understanding why the ConsoleWrite works inside 2nd For loop but not out side. Between Audit Wiki, Help file , Forum searching (lots of code reading), and YouTube ( shout out to TutsTeach), I have not been able to find the reason why. 

$sIniPath = "installLog.ini"

; - Get section name
 $iniSctionNames = IniReadSectionNames($sIniPath)


; - Get Keys and Vaules
For $a = 1 to UBound($iniSctionNames) - 1
    $keys = IniReadSection($sIniPath , $iniSctionNames[$a])
    For $b = 1 to UBound($keys) - 1
        $oldSysInfo = IniRead($sIniPath , $iniSctionNames[1], $keys[$b][0], "")
        $PntIPInfo = IniRead($sIniPath , $iniSctionNames[2], $keys[$b][0], "")
        $NewPCInfor = IniRead($sIniPath , $iniSctionNames[3], $keys[$b][0], "")

        ;ConsoleWrite($oldSysInfo & @LF)
    Next
;ConsoleWrite($oldSysInfo & @LF)
Next


ConsoleWrite($oldSysInfo)

My intention is to use the variables later for Listboxes. Any explanation, forum post links or whatever would help. Sorry also very very new to Autoit.

Also here's the ini file.

[OldSysInfo]
4=192.168.0.4|DESKTOP-RDIU2SN|R90M05Q8
5=192.168.0.5|SD0123456789101|R9WGP9P
6=192.168.0.6|SD0123456789102|R9WGP9PT
3=192.168.0.3|DESKTOP-3RS4LKL|R9WGP9P
23=192.168.0.23|SD0123456789102|MXL1234P5I

[PrinterIp]
50=192.168.0.50
48=192.168.0.48
47=192.168.0.47

[NewSysInfo]
newPC = SD0123456789adfs|192.168.0.185|2UA1234FTR

Thank you for your time.

Share this post


Link to post
Share on other sites

Make sure that $oldSysInfo isn't empty at that time:

ConsoleWrite(">" & $oldSysInfo & "<" & @CRLF)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-09-05 - Version 1.5.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

also, you are trying to read from a sectionName with keys that are not present in that sections, so you get empty values.
In the last read you make to set the $oldSysInfo variable, you are trying to find  the key 'newPC' within the [OldSysInfo] section, and since this key is not found there, you get an empty value. Try this snippet to "see" what happens

#include <array.au3>
$sIniPath = "installLog.ini"

; - Get section name
$iniSctionNames = IniReadSectionNames($sIniPath)
; _ArrayDisplay($iniSctionNames, "$iniSctionNames")

; - Get Keys and Vaules
For $a = 1 To UBound($iniSctionNames) - 1
    $keys = IniReadSection($sIniPath, $iniSctionNames[$a])
    ; _ArrayDisplay($keys, "$keys")
    For $b = 1 To UBound($keys) - 1
        $oldSysInfo = IniRead($sIniPath, $iniSctionNames[1], $keys[$b][0], "(?) key " & $keys[$b][0] & " not found in " & $iniSctionNames[1])
        $PntIPInfo = IniRead($sIniPath, $iniSctionNames[2], $keys[$b][0], "(?) key " & $keys[$b][0] & " not found in " & $iniSctionNames[2])
        $NewPCInfor = IniRead($sIniPath, $iniSctionNames[3], $keys[$b][0], "(?) key " & $keys[$b][0] & " not found in " & $iniSctionNames[3])

        ConsoleWrite("[" & $iniSctionNames[1] & '] ' & $keys[$b][0] & '=' & $oldSysInfo & @TAB & "[" & $iniSctionNames[2] & '] ' & $keys[$b][0] & '=' & $PntIPInfo & @TAB & "[" & $iniSctionNames[3] & '] ' & $keys[$b][0] & '=' & $NewPCInfor & @LF)
    Next
    ConsoleWrite("------------------------" & @CRLF & $oldSysInfo & @CRLF & "========================" & @CRLF) ; $oldSysInfo & @LF)
Next

ConsoleWrite("> " & $oldSysInfo & " <" & @CRLF & @CRLF)

 

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Thank you Water and Chimp, the logic check helped. Realize now that what I wanted to do was this... 

Global $sIniPath = "installLog.ini"
;ConsoleWrite($sIniPath)

$iniSctionNames = IniReadSectionNames($sIniPath)
; _ArrayDisplay($iniSctionNames, "$iniSctionNames")
$keys1 = IniReadSection($sIniPath, $iniSctionNames[1])
$keys2 = IniReadSection($sIniPath, $iniSctionNames[2])
$keys3 = IniReadSection($sIniPath, $iniSctionNames[3])
;_ArrayDisplay($keys1, "$keys")
ConsoleWrite($keys1[1][1])

And Chimp thank you for code below..

;_ArrayDisplay($keys1, "$keys")

Just could not get my brain to understand what the Help file was talking about. Let alone make it do anything.

Share this post


Link to post
Share on other sites

Don't know if I can add to this topic or not. So if I'm wrong please advise proper etiquette.

Need to ask for some additional understanding. 

What have I gotten wrong with the below code? ArrayDisplays shows that $keys2 has data and ConsoleWrite write the correct text, but the ListView is blank. Still using the same Ini file posted at the top of the topic.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GUIListView.au3>
#include <Array.au3>
#include <File.au3>


Global $sIniPath = "installLog.ini"
;ConsoleWrite($sIniPath)

$iniSctionNames = IniReadSectionNames($sIniPath)
 ;_ArrayDisplay($iniSctionNames, "$iniSctionNames")
 $keys2 = IniReadSection($sIniPath, $iniSctionNames[2])
_ArrayDisplay($keys2 , "$keys2")


; Create GUI
$hGUI = GUICreate("Test", 600, 500)

; Create ListView

$cLV = GUICtrlCreateListView("", 10, 10, 580, 300)

For $i = 1 To UBound($keys2) - 1
ConsoleWrite($keys2[$i][1] & @CRLF)

_GUICtrlListView_AddArray($cLV, $keys2[$i][0])
    
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

And I did try it with GUICtrlListView_AddArray($cLV, $Keys2[$i][1]) with the same result.

Edited by Jibsbrown

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jangal
      Hello friends
      This app is slow
      How to increase its speed?
       
      #include <Array.au3> #include <StringConstants.au3> #include <File.au3> #include <String.au3> Global $aWord[][2]  = [[1, "google"],[2,"hello"]]


        Global $sFileName = @ScriptDir & "\1.txt" ; 2MB Text File Local $sFileRead = FileRead($sFileName) Local $res = StringRegExp($sFileRead, "(*UCP)\b[\pL\d]{2,}", 3) _ArrayDisplay($res)   for $sWord in $res     $iIndex = _ArraySearch($aWord, $sWord, 0, 0, 0, 0, 1, 2)     ;MsgBox(0,0,$iIndex)     if $iIndex == -1 Then         Local $aFill = [[0,$sWord]]         _ArrayAdd($aWord,$aFill)        ;      Else         $aWord[$iIndex][0] +=1     EndIf   Next _ArrayDisplay($aWord)

      1.txt
    • By barkeeper
      Hi there,
      I made a script together with some great help from this community. What is does is, sit in the tray until ctrl+1 is pressed, it will ask for input (in this case a short word that contains a longer answer in the ini file it will paste, for example when answering outlook mails with default answers) now the list will become longer and longer, and learning the strings by head will get harder so I was looking into listing the search terms somewhere in the program but can't really find code to borrow for it on these forums. I was wondering if anyone here would be able to help me with it. What I'm looking for is some "bar" attached to the search bar, or some pulldown menu that lists the options that would be the most convenient view. I've attached my script here.
      #include <Misc.au3> HotKeySet("^1", "search") $zoek = "" ; if its going to be a string, its good practice to declare it as a string While 1 Sleep(1) WEnd Func _test() Local $sIni = @ScriptDir & "\antwoorden.ini" Local $sAnswer = "" $sAnswer = IniRead($sIni, "answers", $zoek, "Sorry No answer available") If StringInStr($sAnswer,"<enter>") Then $aAnswer = StringSplit($sAnswer,"<enter>",1) ; 1 = entire delimiter string is needed to mark the split $sAnswer = "" For $i = 1 To $aAnswer[0] $sAnswer &= $aAnswer[$i] & @CR Next EndIf _Sendex ($sAnswer) $zoek = "" ;Reset string EndFunc ;==>_test Func search() $zoek &= InputBox("Zoeken", "Zoekterm:") _test() EndFunc ;==>search Func _SendEx($ss) Local $iT = TimerInit() While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") If TimerDiff($iT) > 2000 Then MsgBox(262144, "Warning", "Shift, Ctrl and Alt keys need to be released to proceed!") $iT = TimerInit() ; reset the timer EndIf WEnd Send($ss) $zoek = "" ;Reset string EndFunc ;==>_SendEx [answers] password=answer rule 1<enter>rule 2 abuse=answer rule 1<enter>rule 2 VPN=answer rule 1<enter>rule 2<enter>rule 3  
      antwoorden.au3 antwoorden.ini
    • By Colduction
      Hi dear friends!, i'm sorry for creating a new thread (a new problem), i have over than 9 lists that i want to combine them to be this (in this example, there are 3 test files):


      I've written a little code for splitting main information, but i really confused how to make results as "Output.txt", here is that code:
       
      $sRegex_1 = StringRegExp(FileRead("1.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) $sRegex_2 = StringRegExp(FileRead("2.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) $sRegex_3 = StringRegExp(FileRead("3.txt"), '(?s:(?<=\=\=\r\n)(.*?)(?=\r\n\=\=))', 3) For $i = 0 To UBound($sRegex_1) - 1 ConsoleWrite($sRegex_1[$i] & @CRLF) For $j = 0 To UBound($sRegex_2) - 1 ConsoleWrite($sRegex_2[$j] & @CRLF) For $k = 0 To UBound($sRegex_3) - 1 ConsoleWrite($sRegex_3[$k] & @CRLF) Next Next Next  
    • By nacerbaaziz
      hello evrybody
      here is an example about how to split your texts using a delimiter with the ability to select how much of delimiters shows in each colum  with $i_number
      e.g
      you have a long text and you want to split it in an array
      that evry colum have a number (n) of lines
      i made a function that do that for you
      just call it with a three params
      $s_text
      your text
      $i_number
      the number that you want to put in each col
      $s_siparator
      the siparator
      default is "|"
      here is the function with example
      i hope that it will be useful for you
       
      ****
       
      #include <Array.au3> $s_txt = "some text1some text2|some text3|some text4|some text5|some text6" $array = splitText($s_txt, 2) _ArrayDisplay($array) Func splitText($s_text, $i_number, $s_siparator = "|") Local $a_TXT = StringSplit($s_text, $s_siparator) Local $a_Return[$a_TXT[0] + 1] If ($a_TXT[0] <= $i_number) Or ($i_number <= 0) Then ReDim $a_Return[2] $a_Return[0] = 1 $a_Return[1] = $s_text Return $a_Return EndIf Local $i_Processed = 1, $i_arrayProcessed = 1 Do For $i = $i_Processed To ($i_Processed + $i_number) - 1 If ($a_TXT[0] < $i) Then ExitLoop If Not ($a_Return[$i_arrayProcessed]) Then $a_Return[$i_arrayProcessed] = $a_TXT[$i] Else $a_Return[$i_arrayProcessed] &= $s_siparator & $a_TXT[$i] EndIf $i_Processed += 1 Next $i_arrayProcessed += 1 Until ($a_TXT[0] < $i_Processed) ReDim $a_Return[$i_arrayProcessed] $a_Return[0] = $i_arrayProcessed - 1 Return $a_Return EndFunc ;==>splitText
      accept my greetings
      thanks to
      @Dan_555
      for his notes
       
    • By MesterPerfect
      good morning
      this is the first post here in the autoit forums
      i hope that you can help me in my problem
      i have a JSON encoded
      it a map of my forums
      where i want to make a treeview that have the same type of map
      e.g
      a system (as category)
      windows (as sub category)
      software (as an child item in the windows category)
      .....
      i don't know how to do that
      so, i know that i can do that using the json functions
      but i need your help about how we can do it as the type that i told you
      by the way i need to put the sub info for each item in an array that give me the ability to manage my items
      e.g
      can post thread
      can reply
      message cound ...
      you just give me a small example and i can continue.
      am sorry if this against the rules of the forum.
      but i realy searched a lot but i couldn't
      i hope some one give me the way.
      thank you very much in advance
       
      here is the link of json forum
      https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/
      and here is my encoded json file
       
      { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }  
×
×
  • Create New...