 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Freighter
Joined: 07 Sep 2006 Posts: 64
|
Posted: Thu Nov 22, 2007 6:29 am Post subject: Treeview retrieval crashing script |
|
|
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 |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu Nov 22, 2007 9:21 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2739 Location: Australia, Qld
|
Posted: Thu Nov 22, 2007 9:29 am Post subject: |
|
|
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.) |
|
| Back to top |
|
 |
Freighter
Joined: 07 Sep 2006 Posts: 64
|
Posted: Fri Nov 23, 2007 10:05 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|