Jump to content

Recommended Posts

Posted

Im trying to move data from a 1D array with over 1000 entries into a 2D array that is 11 Cols wide.

I have got the following

;This takes the log file and creates the first array
If FileExists(@ScriptDir&'\log.db') Then
    $file = FileOpen(@ScriptDir&'\log.db',0)
        $fRead = FileRead($file)
    FileClose($file)
    $aMega = StringSplit($fRead,Chr(9)&Chr(13))
endif

;Define second array
dim $avArray[1][11] 
For $aCount = 1 To $aMega[0]    ;cycle all records
        ReDim $avArray[UBound($avArray) + 1][11] ;Increase rowcount by total +1
        For $aRow = 1 To 11
            $aCol = $aRow -1
            $avArray[1] [$aCol]= $aMega[$aRow]
        Next
Next

However this does add data to the first line but i cant seem to get it to continue on to fill the next line and onwards..

Can anyone take a look at my code and tell me where i have gone wrong?

Posted

If i understood you correctly...

This should do the trick..

#include <array.au3>
If FileExists(@ScriptDir&'\log.db') Then
    $file = FileOpen(@ScriptDir&'\log.db',0)
        $fRead = FileRead($file)
    FileClose($file)
    $aMega = StringSplit($fRead,Chr(9)&Chr(13))
endif

;Define second array
dim $avArray[1][11] 
For $aCount = 1 To $aMega[0]    ;cycle all records
        ReDim $avArray[UBound($avArray) + 1][11] ;Increase rowcount by total +1
        For $aRow = 1 To 11
            $aCol = $aRow -1
            $avArray[$aCount] [$aCol]= $aMega[$aCount]
        Next
    Next
    _ArrayDisplay($avArray)

If you have any more question i'll be happy yo help

Posted

Thanks for the reply Oren. Ive tried the code and whilst it does fill the array, it doesn't do it in the way i need.

The amended code does the following

|1|1|1|1|1|1|1|1|1|1|1|

|2|2|2|2|2|2|2|2|2|2|

|3|3|3|3|3|3|3|3|3|3|3|

|4|4|4|4|4|4|4|4|4|4| etc

i need it to do the following

|1|2|3|4|5|6|7|8|9|10|11|

|12|13|14|15|16|17|18|19|20|21|22

|23|24|25|26|27|"8|29|30|31|32|33|

and onwards upto the end of the 1d array (1160 ish entries)

Sorry i seem to be struggling to explain what i need :)

Posted

Well OK

This program request some mathematics ..

Anyway

#include <array.au3>

;This takes the log file and creates the first array
If FileExists(@ScriptDir&'\log.db') Then
    $file = FileOpen(@ScriptDir&'\log.db',0)
        $fRead = FileRead($file)
    FileClose($file)
    $aMega = StringSplit($fRead,Chr(9)&Chr(13))
endif

;Define second array
dim $avArray[1][11] 
;ConsoleWrite($aMega[0])  ;; something that helpet me to build it 
For $aCount = 1 To $aMega[0]/11+1    ;cycle all records ;; Needed only to get to $aMega[0]/11 , and a + if its in the middle of the last 11 charcters...
         For $aRow = 1 To 11
            $aCol = $aRow -1
    ;       ConsoleWrite(@LF&($aCount-1)*11+$aRow)   ;; something that helpet me to build it 
            if (($aCount-1)*11+$aRow)<=$aMega[0] Then ;; Added a check to see if we didnt got to the end of the $aMefa array
            $avArray[$aCount-1] [$aCol]= $aMega[($aCount-1)*11+$aRow]
                Else
            _ArrayDisplay($avArray)
            Exit
            EndIf
        Next
ReDim $avArray[UBound($avArray) + 1][11] ;Increase rowcount by total +1;; Movbed Down to spear a useless ReDim
Next
    _ArrayDisplay($avArray)

Its not the best efficent well designed scripst, But its beacouse i wanted to continue your script and not to build a new one.. I added some noted , and i letft my consolewrite command so you'll know what helpet me to build it.

Posted (edited)

You sir are a genius :) the script does exactly what i had in mind.

+1 Kudos to you.

And i am aware that my programming skills are appalling but im learning... slowly >_<

I had zero experience with any languages 7 months ago ( and 10 year old know more about math than i do) and im constantly amazed at what Auto It can do :idiot:

cheers

Edited by Azazash
Posted

Yes Yes enjoy..

Autoit is a good language.. Keep on learning..

Actually when i said the script is not perfect i talket about my adds to the script as i see your script is good...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...