Jump to content

Recommended Posts

hello sirs, please help me

i tried to create a function that read a folder files to 3d array

e.g

$array[n][0][0] = ctName

$array[n][0][1] = ctFilePath

$array[n][0][2] = crtsections number

$array[n][m][0] = KeyName

$array[n][m][1] = KeyVal

$array[n][m][2] = keySectionName

 

that the array

when i put one file into the folder all things work fine

but when i put more than one file

the last file worked fine but the others only the first key is showing

please can you help me to correct this problem

here is the example with the folder

please accept my greetings

and thanks in advance

 

array3d.zip

Edited by nacerbaaziz
added the tags
Link to post
Share on other sites
  • Moderators
3 minutes ago, Subz said:

Whats a 3d Array?

An array of arrays, if you're coming from C or Java

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

@czardas arrayworkshop is a great thread for learning more than you want,  the fruit cube is how i got comfortable manipulating stuff

 

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to post
Share on other sites

I've got the files but what I don't understand is what attributes or data you want to assign to each array dimension and what you want to store in each array cell.

AFAICT you only need a 2D array, so I must be overlooking something important to you.

A 3D array is perfect to represent, for instance, one attribute of points in cartesian coordinates: if (X, Y, Z) are point coordinates in air, the array may store, for instance, the température of air at that point.  Then the array once filled gives you T° = f(X, Y, Z).

How does this simple example apply to your data?

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to post
Share on other sites
8 minutes ago, jchd said:

I've got the files but what I don't understand is what attributes or data you want to assign to each array dimension and what you want to store in each array cell.

AFAICT you only need a 2D array, so I must be overlooking something important to you.

A 3D array is perfect to represent, for instance, one attribute of points in cartesian coordinates: if (X, Y, Z) are point coordinates in air, the array may store, for instance, the température of air at that point.  Then the array once filled gives you T° = f(X, Y, Z).

How does this simple example apply to your data?

am making an links store

and that tool has a categorys

and evry category is in a file

that file as a ini file

and what i want is to store the data in a 3d array

that the 1d to change the categorys and the 2d is to change the ini sections, and the last is to store the links information as the name of link and the url

i hope that you understand what i want

Link to post
Share on other sites

You only need a 2D array:

Category    LinkName    URL
test    faceBook    https://facebook.com/
test    twitter https://twitter.com/
test    honeygain   https://honeygain.com/
test2   google  https://google.com/
test2   gmail   https://gmail.com/
test2   youtube https://youtube.com/
test3   mx-blind    https://mx-blind.com/
test3   wordpress   https://wordpress.com/
test3   blind help  https://blindhelp.net/

This is TSV format so you can copy-paste and directly load into a 2D array. Leave the headers alone as it will simplify access.

BTW if you intent to have a large number of links, you might turn to SQLite.

Here's a SQL source file (containing SQLite-compatible statements) you can use to create the database corresponding to the table shown above:

Links.sql

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to post
Share on other sites

i liked to use the 3d because i have a treeview and list box

for that to get the info from one to one i must use a array

but if you mean that no whey to do that, then i have to change all my function .

i hope any one can help me to correct that 

Link to post
Share on other sites
4 minutes ago, nacerbaaziz said:

i liked to use the 3d because i have a treeview and list box

for that to get the info from one to one i must use a array

I provided an example of use of an array, didn't I?

I still fail to see how you would cram your data in 3 dimensions, still keeping ease of use, access, search and coding.  I'm not saying this is impossible, just that it's neither useful nor practical.

To make a parallel, think about a personal address book. A (very simple) address consists of: country, state, zipcode, city, street, number, floor, appartment number.  That's 8 entities for that simple case, many real-world addresses are much more complex.

There are two diametrally extreme ways to organize storage for addresses like that: a 2D-array where each entry (row) contains 8 columns to store the 8 components, or a 8D-array where each component represents a dimension.

A 2D-array fits well the personal use, but a 8D array is most suitable for administrative registers that lists all habitations/appartments in a large area.  Searching in a 2D array is much easier than selecting address components in a 8D-array.

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to post
Share on other sites

Does this function contain any errors, please?

#include <iniex.au3>
#include <Array.au3>
#include <File.au3>
#include <fileOptions.au3>
Global $A_StoreDataRead[1][1][3]
Global $StoreDataDir = @ScriptDir & "\store_data"
Store_GetData()
Func Store_GetData($DataDir = $StoreDataDir)

    ReDim $A_StoreDataRead[1][1][3]

    Local $find = _FileListToArrayRec($DataDir, "*.CTG", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    If $find[0] <= 0 Then Return SetError(1, 0, 1)


    Local $iAll = 0, $i = 1, $CrntPath = "", $sectionsRead, $SectionRead, $crntPathOpen, $CrntPathRead, $crntFileName
    For $iFiles = 1 To $find[0]

        $CrntPath = $find[$iFiles]
        $crntFileName = _GetFileName($CrntPath)
        $crntPathOpen = FileOpen($CrntPath)
        $CrntPathRead = FileRead($crntPathOpen)
        If @error Then
            FileClose($crntPathOpen)
            ContinueLoop
        EndIf
        FileClose($crntPathOpen)

        $sectionsRead = _IniReadSectionNamesFromString($CrntPathRead)
        If @error Then ContinueLoop
        $iAll += 1
        $i = 1
        For $scs = 1 To $sectionsRead[0]
            $i += 1
            ReDim $A_StoreDataRead[$iAll + 1][$i][3]
            If $sectionsRead[$scs] = "categoryInfo" Then
                $A_StoreDataRead[$iAll][0][0] = _IniReadFromString($CrntPathRead, "categoryInfo", "categoryName", "")
                $A_StoreDataRead[$iAll][0][1] = $crntFileName
                $i -= 1
            Else
                $A_StoreDataRead[$iAll][$i - 1][0] = _IniReadFromString($CrntPathRead, $sectionsRead[$scs], "linkName", "")
                $A_StoreDataRead[$iAll][$i - 1][1] = _IniReadFromString($CrntPathRead, $sectionsRead[$scs], "LinkValue", "")
                $A_StoreDataRead[$iAll][$i - 1][2] = $sectionsRead[$scs]
                $A_StoreDataRead[$iAll][0][2] = $i - 1
            EndIf
            MsgBox(64, "result", $A_StoreDataRead[$iAll][0][0] & @CRLF & $A_StoreDataRead[$iAll][0][1] & @CRLF & $A_StoreDataRead[$iAll][0][2] & @CRLF & $A_StoreDataRead[$iAll][$i - 1][0] & @CRLF & $A_StoreDataRead[$iAll][$i - 1][1] & @CRLF & $A_StoreDataRead[$iAll][$i - 1][2])
        Next
    Next
    $A_StoreDataRead[0][0][0] = $iAll

    MsgBox(64, "", $A_StoreDataRead[1][0][0] & @CRLF & $A_StoreDataRead[1][0][1] & @CRLF & $A_StoreDataRead[1][0][2])
    MsgBox(64, "", $A_StoreDataRead[1][1][0] & @CRLF & $A_StoreDataRead[1][1][1] & @CRLF & $A_StoreDataRead[1][1][2])
    MsgBox(64, "", $A_StoreDataRead[1][2][0] & @CRLF & $A_StoreDataRead[1][2][1] & @CRLF & $A_StoreDataRead[1][2][2])
    MsgBox(64, "", $A_StoreDataRead[1][3][0] & @CRLF & $A_StoreDataRead[1][3][1] & @CRLF & $A_StoreDataRead[1][3][2])

    MsgBox(64, "", $A_StoreDataRead[2][0][0] & @CRLF & $A_StoreDataRead[2][0][1] & @CRLF & $A_StoreDataRead[2][0][2])
    MsgBox(64, "", $A_StoreDataRead[2][1][0] & @CRLF & $A_StoreDataRead[2][1][1] & @CRLF & $A_StoreDataRead[2][1][2])
    MsgBox(64, "", $A_StoreDataRead[2][2][0] & @CRLF & $A_StoreDataRead[2][2][1] & @CRLF & $A_StoreDataRead[2][2][2])
    MsgBox(64, "", $A_StoreDataRead[2][3][0] & @CRLF & $A_StoreDataRead[2][3][1] & @CRLF & $A_StoreDataRead[2][3][2])

    MsgBox(64, "", $A_StoreDataRead[3][0][0] & @CRLF & $A_StoreDataRead[3][0][1] & @CRLF & $A_StoreDataRead[3][0][2])
    MsgBox(64, "", $A_StoreDataRead[3][1][0] & @CRLF & $A_StoreDataRead[3][1][1] & @CRLF & $A_StoreDataRead[3][1][2])
    MsgBox(64, "", $A_StoreDataRead[3][2][0] & @CRLF & $A_StoreDataRead[3][2][1] & @CRLF & $A_StoreDataRead[3][2][2])
    MsgBox(64, "", $A_StoreDataRead[3][3][0] & @CRLF & $A_StoreDataRead[3][3][1] & @CRLF & $A_StoreDataRead[3][3][2])


    Return 1
EndFunc   ;==>Store_GetData

 

Link to post
Share on other sites

hello again

i found the problem, and i wanted to share it with you

here is the corrected function

thank you all to your help

with my greetings

func Store_GetData($DataDir = $StoreDataDir)

ReDim $A_StoreDataRead[1][1][3]

local $find = _FileListToArrayRec($DataDir, "*.CTG", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    If not (isArray($find)) Then return SetError(1, 0, 1)
local $iAll = 0, $i = 1, $IcrntSec = 1, $CrntPath = "", $sectionsRead, $SectionRead, $crntPathOpen, $CrntPathRead, $crntFileName
for $iFiles = 1 to $find[0]

$crntPath = $find[$iFiles]
$crntFileName = _GetFileName($crntPath)
$crntPathOpen = FileOpen($crntPath)
$CrntPathRead = FileRead($crntPathOpen)
if @Error then
fileClose($crntPathOpen)
ContinueLoop
endIf
fileClose($crntPathOpen)

$SectionsRead = _IniReadSectionNamesFromString($CrntPathRead)
if @Error then ContinueLoop
$iAll += 1
$i = 1
for $scs = 1 to $SectionsRead[0]
$i += 1
if $IcrntSec < $i then
ReDim $A_StoreDataRead[$iAll+1][$i][3]
$IcrntSec = $i
else
ReDim $A_StoreDataRead[$iAll+1][$IcrntSec][3]


endIf
if $SectionsRead[$scs] = "categoryInfo" then
$A_StoreDataRead[$iAll][0][0] = _IniReadFromString($CrntPathRead, "categoryInfo", "categoryName", "")
$A_StoreDataRead[$iAll][0][1] = $crntFileName
$i -= 1
else
$A_StoreDataRead[$iAll][$i-1][0] = _IniReadFromString($CrntPathRead, $SectionsRead[$scs], "linkName", "")
$A_StoreDataRead[$iAll][$i-1][1] = _IniReadFromString($CrntPathRead, $SectionsRead[$scs], "LinkValue", "")
$A_StoreDataRead[$iAll][$i-1][2] = $SectionsRead[$scs]
$A_StoreDataRead[$iAll][0][2] = $i-1
endIf

next
next
$A_StoreDataRead[0][0][0] = $iAll

return 1
endFunc

 

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

    No registered users viewing this page.

  • Similar Content

    • By TheAlienDoctor
      Hi, I was looking into creating a script that would detect if a file exists, then move it (and in some cases rename it, depending on the file) as well as write to a log file.
      The issue is, there is a lot of files that need to be moved, sometimes some files will exist and others won't depending on the use-case. However if a file does exist, it will always be going into the same directory with the same name.
      Currently I have an array nested inside of the array, with each array inside that array having both the old and new directory, and then a For loop to actually run through and do the file transferring. The issue I am having is how to call the Array inside of the array, because how do I specify  which the old directory is and which the new is?
      Global $FileTransfer[2000] = [Global $Dir1[2] = ["original dir 1", "new dir 1"], Global $Dir2[2] = ["original dir 2", "new dir 2"]] For $FileTransfer = [0] To [1] Step +1 If FileExists({original dir}) Then FileMove({original dir}, new dir, 1) FileOpen("log.latest.txt", 1) FileWrite("log.latest.txt", "{original dir} found, moved it to new dir." & @CRLF) FileClose("log.latest.txt") Else FileOpen("log_latest.txt", 1) FileWrite("log_latest.txt", "{original dir} not found, ignoreing it." & @CRLF) FileClose("log_latest.txt") EndIf Next I have put what I want the old and new directory to be for each array in {}, so hopefully its easier to tell which part is working and whats not.

      I am still reasonably new to AutoIT, any help is appreciated. Thankyou
    • By arunkw
      I have a spreadsheet - daily routine which has two columns: activity and time as shown here
      | Activity             | Time     | |----------------------|----------| | Sleep               |  6:00 am | | Toilet              |  6:15 am | | Get ready for gym  |  6:30 am | | Exercise            |  7:50 am | | ... more things      |  9:00 pm | | ... still more       | 10:45 pm | | Sleep               |  6:00 am |   I wanted to find out, say in C1 which activity is current for me using now() I.e., if it’s 6:45am on my watch, it should show me Exercise  in C1 Thanks to Adam D. PE, this formula works like magic to get the result =VLOOKUP(MOD(NOW(),1),{B2:B,A2:A},2,1)   Now, I want to reproduce same result in autoit, how to do that? To have easy solution say, I copy-paste spreadsheet data in array directly in code, right? Use for loop and run the above vlookup function and show the answer using tooltip. How to achieve this? please help.  
    • By goku200
      I have an Autoit script that lists files from a folder into an array list. Is there a way to separate the filenames by an underscore and include the id, version, name and date into separate columns in Excel.
      Example of filename:
      12345_v1.0_TEST Name [12345]_01.01.2022.html
      12345 would be in one column
      v1.0 would be in another column
      TEST Name [12345] would be in another column
      01.01.2022 would be in another column
      .html would be in another column
      Note: filenames always change each day.
      Here is my code that lists the files into column C and then writes the column Headers into Column D, E, F, G. Just need some help with separating them into columns by the _ delimiter
       
    • By mLipok
      Usually when I collect data from DataBase I need to give EndUser a possibility to select rows which should be taken in the processing loop.
      I was searching on the forum and I'm not able to find any UDF or even example of how to select data from array.
      I have my own solutions but I think they are not worth posting on the forum as it is very old code and I am looking for a better solution.

      Could anybody point me to some examples/solutions ?

      Thank you in advance.
      @mLipok
    • By EmilyLove
      I have a string containing the full path of an executable and an array of executables without their paths. I am trying to compare the string to the list in the array and if a match is found, remove it from the array. The entry get removed from the array successfully, and after checking its return result, uses it to update the ubound if it succeeded, but it doesn't want to update to the new value. Any ideas what I am doing wrong? It acts like it is read-only.
      #include <Array.au3> #include <File.au3> Local $sApp_Exe = "F:\App\Nextcloud\nextcloud.exe" Local $aWaitForEXEX = [3, "Nextcloud.exe", "nextcloudcmd.exe", "QtWebEngineProcess.exe"] For $h = 1 To $aWaitForEXEX[0] If StringInStr($sApp_Exe, $aWaitForEXEX[$h]) <> 0 Then $iRet = _ArrayDelete($aWaitForEXEX, $h) If $iRet <> -1 Then $aWaitForEXEX[0] = $iRet ;this line doesn't work. $aWaitForEXEX[0] doesn't update and shortly gives Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _ArrayDisplay($aWaitForEXEX) EndIf Next  
×
×
  • Create New...