Jump to content
Sign in to follow this  
cypher175

_FileReadToArray - MULTIPLE ARRAYS FROM ONE FILE..?

Recommended Posts

cypher175

Is there anyway to get more than one array from a single txt file with _FileReadToArray by using some kinda markers in the text file that lets _FileReadToArray know from where to where in the txt file to Read each Array from..??

Ex:

<ARRAY#1>

AAAAAAAAAA

BBBBBBBBBB

CCCCCCCCC

</ARRAY#1>

<ARRAY#2>

DDDDDDDDD

EEEEEEEEEE

FFFFFFFFFFF

</ARRAY#2>

<ARRAY#3>

GGGGGGGGG

HHHHHHHHH

IIIIIIIIIIIIIIII

</ARRAY#3>

Share this post


Link to post
Share on other sites
Melba23

cypher175,

I do not believe you can get _FileReadToArray to do that, but there is an easy work around.

Load your file into an initial array with _FileReadToArray. Then use _ArraySearch to find your "end of array" flag. Loop through the elements above that flag index, copying them into another array while deleting them from the first. Repeat the process until you have your separate arrays and no elements remain in the initial array.

That should be trivial to code.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
cypher175

lol wut...??

Posted Image

can you give me a code example please, that sounds kinda confusing to me at the moment, i've been up for quite a while, need 2 get sum sleep.. lol :P

Share this post


Link to post
Share on other sites
BrettF

Something like...

#include <Array.au3>
Global $aText[16]
Global $aOut[1][1]
$counter = 0
$count = 0
$totalc = 0
$aText[0] = 15
$aText[1] = "<ARRAY#1>"
$aText[2] = "AAAAAAAAAA"
$aText[3] = "BBBBBBBBBB"
$aText[4] = "CCCCCCCCC"
$aText[5] = "</ARRAY#1>"
$aText[6] = "<ARRAY#2>"
$aText[7] = "DDDDDDDDD"
$aText[8] = "EEEEEEEEEE"
$aText[9] = "FFFFFFFFFFF"
$aText[10] = "</ARRAY#2>"
$aText[11] = "<ARRAY#3>"
$aText[12] = "GGGGGGGGG"
$aText[13] = "HHHHHHHHH"
$aText[14] = "IIIIIIIIIIIIIIII"
$aText[15] = "</ARRAY#3>"

For $i = 1 To $aText[0]
    If StringRegExp ($aText[$i], "(?i)</.*?>") Then
        ContinueLoop
    ElseIf StringRegExp ($aText[$i], "(?i)<[^/].*?>") Then
        $counter += 1
        $count = 0
    Else
        If $count > $totalc Then $totalc = $count
        ReDim $aOut[$counter + 1][$totalc + 1]
        ConsoleWrite ("[" & $counter & "][" & $totalc & "] = " & $aText[$i] & @CRLF)
        $aOut[$counter][$count] = $aText[$i]
        $count += 1
    EndIf
Next

$aOut[0][0] = $counter

_ArrayDisplay ($aOut)

No real need for that massive picture, but you could have a go yourself... :P

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.