topten Posted August 12, 2015 Posted August 12, 2015 for $i = 1 to 10 nextHow can I add all the appearing numbers (strings, data) to array? So that later I could say$i[0] = 1$i[1] = 2etcNote: Here I am showing may be very abstract example. In fact I will have a list of strings which will be appearing from the loop- so how can I get them into array?
Moderators Melba23 Posted August 12, 2015 Moderators Posted August 12, 2015 topten,Do you mean something like this?#include <Array.au3> Global $aArray[10] For $i = 1 To 10 $aArray[$i - 1] = $i Next _ArrayDisplay($aArray, "Loaded", Default, 8)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
topten Posted August 12, 2015 Author Posted August 12, 2015 (edited) I myself not sure about it I will try to explainFor example you are getting some list of words from the loop (regexp)$infoarray = StringRegExp($info, '(.*?);', 3)for $i = 0 to Ubound ($infoarray)-1; here $infoarray[i$] is my resulted stringAnd here I need this string to be written into some $y, so later when I get $y[0] - I have first string written into $y, and $y[1] - second string written into $y etcnext Something like that ... Edited August 12, 2015 by topten
Moderators Melba23 Posted August 12, 2015 Moderators Posted August 12, 2015 topten,That makes no sense at all. You have an array of results in $infoarray - why do you need to get these values into another array before accessing them? If you will be overwriting the initial array then just copy it into another like this:#include <Array.au3> $aInfoArray = StringSplit("0123456789", "") _ArrayDisplay($aInfoArray, "Initial return", Default, 8) $aCopyArray = $aInfoArray ; Copy the array _ArrayDisplay($aCopyArray, "Copy", Default, 8)If that is not the answer then I suggest you try and write some pseudo-code (plain language logic flow) so that we can better understand what it is you want to do - because if you have trouble formulating it how are we supposed to understand?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
topten Posted August 12, 2015 Author Posted August 12, 2015 I try to paraphrase, may be I have missed something$data = fileread ("words.txt") $g = StringRegExp($data, '(.*?);', 3) ; the words are separated by ";" for $i = 0 to Ubound($g)-1 $g[$i] - here is every word I am getting from the list $word = $g[$i] getspecialdatafromtheword ($word) ; here I am getting special data which is accordingly to this word (my custom function) ;;;;;;;;;; And here I need $specialdata write into some $y so that later I could get from $y[0] first $specialdata from $y[1] get second special data from $y[2] get third special data etc;;;;;;;;;; next func getspecialdatafromtheword ($word) ;;;;;; my function Return $specialdata endfuncI hope this is more clear. Is such possible?
Moderators Melba23 Posted August 12, 2015 Moderators Posted August 12, 2015 topten,Perhaps this:expandcollapse popup#include <Array.au3> #include <StringConstants.au3> #include <MsgBoxConstants.au3> ; Simulate reading file $sData = "0123456789" ; Simulate RegEx split into "words" $g = StringSplit($sData, "", $STR_NOCOUNT) ; The "data" array _ArrayDisplay($g, "Words", Default, 8) ; Create array to hold "special data" - same size as the data array Global $y[UBound($g)] ; Now loop though the data For $i = 0 To UBound($g) - 1 ; Extract "word" $word = $g[$i] ; Save "special data" into new array $y[$i] = _getspecialdatafromtheword($word) Next ; The "special data" array _ArrayDisplay($y, "Special data", Default, 8) ; And to show that they 2 arrays are linked For $i = 0 To UBound($g) - 1 MsgBox($MB_SYSTEMMODAL, $i, $g[$i] & @CRLF & $y[$i]) Next Func _getspecialdatafromtheword($sWord) ; Get the "special data" Return "Special data for " & $sWord EndFuncAny closer?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
jchd Posted August 12, 2015 Posted August 12, 2015 What Melba examplified, or use _ArrayColInsert($g, 1) and store in $g[$i][1] data from word read in $g[$i][0]. That would be simpler IMVHO. 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 hereRegExp tutorial: enough to get startedPCRE 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)
topten Posted August 13, 2015 Author Posted August 13, 2015 Great thanx Melba23, that works like a charmGreat thanx jchd for your solution
Moderators Melba23 Posted August 13, 2015 Moderators Posted August 13, 2015 topten,Glad I could help.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now