AutoHotkey Community

It is currently May 27th, 2012, 10:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: November 22nd, 2007, 7:29 am 
Offline

Joined: September 7th, 2006, 10:42 am
Posts: 65
Simply put this script loops directories and adds them to a treeview.

The purpose (when finished) will calculate the size of all the folders that are checked and save the checked list for later use.

The issue is when i go to retrieve the checked boxes the program/script crashes/disappears

Not sure if limitation or a bug if anything else I would like a workaround
thanks

Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.

FileRead, DirsToInclude, %A_ScriptDir%\SavedcDirs.ini
gui, add, treeview, Checked w500 r30
gui, add, button,, SaveList
gui, add, button, x+10, getProperties


getFolder("C:")
gui, show
return

getFolder(PFolder, PID = 0){
global DirsToInclude
Loop, %PFolder%\*.*, 2, 0
{
  ;msgbox %A_LoopField%,  %A_LoopFileName%,%A_LoopFileLongPath%
  if A_LoopFileLongPath in %DirsToInclude%
    isChecked = true
  SPID := TV_Add(A_LoopFileName, PID, isChecked)
  getFolder(A_LoopFileLongPath, SPID)
}
}

getFullPath(TID){
  TV_GetText(ItemText, ItemID)
  ItemID := TV_GetParent(ItemID)
  FolderName := getFullPath(ItemID) . "\" . ItemText
  Return FolderName
}

buttonSaveList:
ItemID = 0
Loop
{
  ItemID := TV_GetNext(ItemID, "Checked")
  if not ItemID  ; No more items in tree.
    break
  FolderToCheck := getFullPath(ItemID)
  listvars
  pause
  MsgBox The next Item is %ItemID%, whose text is "%FolderToCheck%".
}
Return

buttongetProperties:
msgbox works
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2007, 10:21 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
The "buttonSaveList" button seems to cause a stack overflow when any of the checkboxes are checked (I don't know why the OS doesn't show a stack overflow dialog, but that's what the program debugger says). This appears to be related to getFullPath() calling itself, which isn't a problem per se, but apparently the recursion is too deep or infinite.

The function getFullPath() never uses its incoming parameter TID, which might indicate it has a flaw. Perhaps try debugging that function to see why it recurses so deeply.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2007, 10:29 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
I got exception code c00000fd (stack overflow); didn't need to run a debugger.

The recursion of getFullPath() is infinite, since it calls itself regardless of whether TV_GetParent() returned zero (meaning no parent.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2007, 11:05 am 
Offline

Joined: September 7th, 2006, 10:42 am
Posts: 65
Yeah I didnt get any message at all, it was just dropping back to the folder
Wow i totally missed the TID thing
Thank you Chris and lexikos

Code:
getPath(ItemID){
  TV_GetText(ItemText, ItemID)
  If ItemID != 0
  {
    ItemID := TV_GetParent(ItemID)
    FolderName := getPath(ItemID) . "\" . ItemText
  } else
    FolderName := "C:" . FolderName
  Return FolderName
}


PS sorry for posting in the wrong area


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, robotkoer, specter333, Yahoo [Bot] and 77 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group