Jump to content

Recommended Posts

Good morning guys, i hope that you're all well.
guys, i have a problem and i hope that you can help me
i've created an 3d array
the array Contain a Categories info
as folow
$array[n][0][0] = Categorie name
$array[n][0][1] = Categorie file path
$array[n][0][2] = Categorie contents number

$array[n][m][0] = link name
$array[n][m][1] = link url
$array[n][m][2] = link section name

in my tool i want to add an option to delete a Category
as you know the Categorie mean that must delete a region from the array
when i tried to use _arrayDelete
with the 2d array it work well
but here i couldn't find any way to do that, can any one help me please?
thanks in advance.

Share this post


Link to post
Share on other sites

None of the _Array functions work with anything other than a 1D or 2D array, some only work with 1D. 3D arrays are hardly ever necessary, and in your case definitely not needed, a 2D array with 3 columns could easily replace that 3D array.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

@BrewManNH
when i try to put it in 2d array I found it hard to deal with it.
because in my tool their is an treeview i must put the categories
and a list box to put the links name
until now all that i can put it in a 2d array
but when i want to do any other operation i will find a hardest to do it
Because I will rely on reading the treeview item  index and use its numbers to handle the categories into the array
please if you have any other simple Suggestion or other way give it to me.

 

Share this post


Link to post
Share on other sites

Show your code


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

You seem to love complicated life.


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)

Share this post


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

You seem to love complicated life.

I've shared the code, I hope you read it and try to give me solutions, because I do not like complicated life, but I could not find another solution in my mind.

Share this post


Link to post
Share on other sites

I've read, downloaded, analyzed, found correct way, provided example code and alternate solution. Enough for me.


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)

Share this post


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

I've read, downloaded, analyzed, found correct way, provided example code and alternate solution. Enough for me.

please can you help me an other one

just i want to find a easy way because am a bgnr in programation.

I apologize for the weight of my understanding and hope you can help me

I repeat my apologies

Share this post


Link to post
Share on other sites

Sorry but after 30 months of frequentation of this forum and AutoIt you are expected to have taken the time and pain to learn the basics and even more than that.  I'm unsure you're willing to learn by yourself even if I understand you have more difficulties than most of other people around.


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)

Share this post


Link to post
Share on other sites

@jchd
i know that sir, but am  doing everything I can to learn.
Unfortunately i can't read the pdf files to learn also i can't see a videos, that because am using the screen readers to work
am a blind man
for that am trying to lirn from the questions and examples, this is the only way that i can do.

I apologize if you are bothering me with my trivial questions, but be sure that I have not found a way to learn i've only this way

Share this post


Link to post
Share on other sites

hello again

i found a simple way and it worked with me

that what i did

thanks all to your help

func Store_GetData($DataDir = $StoreDataDir)

ReDim $A_StoreDataRead[1][7]

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
ReDim $A_StoreDataRead[$iAll+1][7]
$i_StoreDataSectionsMax = $iAll
for $scs = 1 to $SectionsRead[0]
if $SectionsRead[$scs] = "categoryInfo" then
$A_StoreDataRead[$iAll][0] = _IniReadFromString($CrntPathRead, "categoryInfo", "categoryName", "")
$A_StoreDataRead[$iAll][1] = $crntFileName
else
if $A_StoreDataRead[$iAll][3] = "" then
$A_StoreDataRead[$iAll][3] = _IniReadFromString($CrntPathRead, $SectionsRead[$scs], "linkName", 0)
else
$A_StoreDataRead[$iAll][3] &= "|" & _IniReadFromString($CrntPathRead, $SectionsRead[$scs], "linkName", 0)
endIf
if $A_StoreDataRead[$iAll][4] = "" then
$A_StoreDataRead[$iAll][4] = _IniReadFromString($CrntPathRead, $SectionsRead[$scs], "LinkValue", 0)
else
$A_StoreDataRead[$iAll][4] &= "|" & _IniReadFromString($CrntPathRead, $SectionsRead[$scs], "LinkValue", 0)
endIf
if $A_StoreDataRead[$iAll][5] = "" then
$A_StoreDataRead[$iAll][5] = $SectionsRead[$scs]
else
$A_StoreDataRead[$iAll][5] &= "|" & $SectionsRead[$scs]
endIf
$A_StoreDataRead[$iAll][2] = $i-1
endIf

next
next
$A_StoreDataRead[0][0] = UBound($A_StoreDataRead)-1
return 1
endFunc

 

Share this post


Link to post
Share on other sites

👍

If it works, then it's good enough. :)

 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Hi nacerbaaziz :)

Though you found another way, I won't throw away the post I prepared and it took me a lot of time, let's go.

I downloaded your code to test it and well... the lack of indentation made it really hard to debug.
After "re-indentating" it, I started to play a bit with the treeview and the list box.

So imagine my surprise when I delete all 3 items in the treeview and there are still elements in the listbox !

It means something goes wrong with the delete part, especially after I quit the script, there are still 2 .CTG files when they should have been all deleted, the 3 of them.

You are using czardas function _DeleteRegion() to delete from your 3D array, but have you carefully tested it with a simpler example ? And what about the error handling ?

czardas programmed 6 different errors and you don't even test if your call to _DeleteRegion() returns an error ?
Please add a test on @error and you'll be surprised of what you'll see...

This being said, let's be positive. Here is a personal example which explains how to delete all region corresponding to an index in one of the 3 dimensions :

#include <Array.au3>
#include <ArrayWorkshop.au3>

$index1 = 5
$index2 = 2
$index3 = 2

Global $aArray3D[$index1][$index2][$index3], $aDisplay[0]

For $i1 = 0 to $index1 - 1
    For $i2 = 0 to $index2 - 1
        For $i3 = 0 to $index3 - 1
            $aArray3D[$i1][$i2][$i3] = $i1 & "-" & $i2 & "-" & $i3
            _ArrayAdd($aDisplay, $aArray3D[$i1][$i2][$i3])
        Next
    Next
Next

_ArrayDisplay($aDisplay, "Before delete", Default, $ARRAYDISPLAY_NOROW)

_DeleteRegion($aArray3D, 1, 3) ; delete index #3 in 1st dimension (1st index is #0)
If @error Then Exit Msgbox(0, "", "_DeleteRegion error = " & @error)

$aBound = __GetBounds($aArray3D) ; get the bounds of each dimension
If @error Then Exit Msgbox(0, "", "__GetBounds error = " & @error)

Global $aDisplay[0] ; erase and recreate the display array

For $i1 = 0 to $aBound[1] - 1
    For $i2 = 0 to $aBound[2] - 1
        For $i3 = 0 to $aBound[3] - 1
            _ArrayAdd($aDisplay, $aArray3D[$i1][$i2][$i3])
        Next
    Next
Next

_ArrayDisplay($aDisplay, "After delete", Default, $ARRAYDISPLAY_NOROW)

As you can see below, in the left column, there were 20 elements before deletion.
And in the right column, there are only 16 elements after deletion, all index 3 from the 1st dimension has been deleted.

456799739_beforeandafterdeleteregion.png.23def93a1a65ce822e3e02b609b39c50.png

Now let's apply it to your code :

_DeleteRegion($A_StoreDataRead, $selectedItem, 0, $A_StoreDataRead[$selectedItem][0][2]+1)
If @error Then Exit Msgbox(0, "", "_DeleteRegion error = " & @error)

First of all, see the test on @error ?
It will return an "error 6" (@error = 6 Invalid Range, see czardas function)

This is because your call to _DeleteRegion() should have been like this :

_DeleteRegion($A_StoreDataRead, 1, $selectedItem) ; 1 = 1st dimension, i.e the Category dimension
If @error Then Exit Msgbox(0, "", "_DeleteRegion error = " & @error)

Now you'll find that deletion goes correctly and all .CTG files are deleted after you delete the 3 items from the treeview. Also you can add a kind of "ArrayDisplay" like I did, it will show you what's the content of your 3D array before, then after deletion.

Good luck :)

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By nooneclose
      I need to dynamically resize my 2d array while looping. 
      I know this code:
      ReDim $rArray[UBound($rArray) + 1] works for the rows, however, I also need to increase the columns. How would i go about increasing both rows and columns while looping? 
    • By Zaoka
      Hi guys
      Need little help with filtering.
      I'm trying to filter specific weeks from power pivot table using this code recorded with Excel VBA :
       
      #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\....\Orders.xlsb") $oWorkbook.PivotTables("PivotTable1").PivotFields( _ "[Report 2].[Week].[Week]").VisibleItemsList = Array( _ "[Report 2].[Week].&[10]", "[Report 2].[Week].&[11]", _ "[Report 2].[Week].&[12]", "[Report 2].[Week].&[13]", _ "[Report 2].[Week].&[14]", "[Report 2].[Week].&[15]") But get error
      error: Array(): undefined function. Not sure how to resolve this.
    • By LxP
      I'm trying to pass a nested array to a function, such that the function alters the inner array.
      I was surprised to find that this minimal reproducible example, despite its use of ByRef, seems to pass a copy of the inner array to the function:
      #include <Array.au3> ; a boring old array Local $aInnerArray[5] = [1, 2, 3, 4, 5] ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] ; intention: take a nested array and alter its inner array ; reality: the inner array seems to be getting copied Func ChangeIt(ByRef $aOuter) Local $aInner = $aOuter[0] $aInner[2] = 0 EndFunc ; Expected: [1, 2, 3, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✔ _ArrayDisplay($aInnerArray, 'Before') ; $aOuterArray passed by-ref, should receive reference to $aInnerArray ; Therefore should change $aInnerArray to [1, 2, 0, 4, 5] ChangeIt($aOuterArray) ; Expected: [1, 2, 0, 4, 5] ; Actual: [1, 2, 3, 4, 5] ✘ _ArrayDisplay($aInnerArray, 'After') I suspect that either:
      the copy is taking place in the first line of the function (I couldn't find a way to access the inner array without first assigning it to a variable though); or ByRef doesn't propagate into inner levels of the data structure being passed, which seems less likely to me. Could someone please point me in the right direction to get this working as intended?
      Update: the answer
      ; WRONG: ; a one-element array containing a reference to the other array Local $aOuterArray[1] = [$aInnerArray] The assumption I made about this code is wrong—it actually copies $aInnerArray into $aOuterArray, so there are now two unrelated $aInnerArray instances.  It is not possible to store arrays in other arrays by reference.
      If it is necessary to refer to a mutable array in multiple places, consider holding it in a global variable.  Where a collection of mutable arrays needs to be accessed in multiple places (as in my case), consider storing them in a global array and referring to each sub-array by index (also known as the Registry pattern).
    • By VinMe
      HELLO All,
      is there any function in Auto it to Remove the repeating  strings separated by ","  which is present in the array.
      ex.
      Available state
      a[0]= D97,D96,,D85,D86,D85,D86,D85,D86,D85,,D86,D85,D86,D85,D86
      a[1]=D85,D24,,,,,D85
      Required state
      a[0]= D97,D96,D85,D86,
      a[1]=D85,D24
      thank  you in advance!
      vin!
    • By D2thunder
      Hi all, I wasnt active in this Forum forum for Years. 😅
      Since I need something with Json in AutoIt i write a little UDF to save a variable to file to read it with another language - and back. After a while until my other script grows i thought - lets integrate all variables wich is possible, because i want have arrays to.
      This is my first public UDF in Autoit - normaly my AutoIt scripts are quick an dirty.... - like the examples for this udf. - someone want to write nice examples?
      I tried to write this UDF properly, cared for processing speed, low mem consumption as possible, a short code, and a high usability without beeing very familiar with arrays.
      What is it for? - convert nearly all types of variables to a json string for saving it in a file or to an ini. Read it back in to a same formated variable and preserv variable types. All array types are supported with nested arrays, the only restriction is ram and array/stringsize - and time if the array is very big. You can use Filters for variable types and some other options.
      If anyone found a bug or any suggestions, please post it.
       
      get Json.au3 from here Json.au3
       
       
      JsonVar 2019.01.25.1.zip
×
×
  • Create New...