Two scripting questions *solved*
Totte
Posts: 13,955
Hello,
I've been digging into scritping and I've found two things I trip on, maybe someone knows. This is on OS X btw,
(1) DzDir seems to trip on directory names beginning with !, is this a known thing ? If I set a directory full path to a directory named !Base sets, DzDir::exists() returns false, but the same directory wirhout ! in the beginning, is OK.
(2) Can you do recursion in DZScript, or is that a no no? I tried to implement a directory weeder the same way I always do, but I get a total lockup. Is the something you need to carefully consider?
Post edited by Totte on
Comments
OK, the path was a very tricky one, looks like there is something when running the script in the debugger, that every second run it failed, wasn't the !, was every second run.
And the recursive I looked at Qt to get some hints, debugging and seeing where it freaks out.
1) DzDir handles directories with a leading exclamation mark like it does any other directory, with any other leading character*; PowerLoader is a script that makes extensive use of one such folder. *The character that you do need to be cautious of is a period, as it can have a special meaning when used in a path; i.e., dot (".") - the current directory, and dotdot ("..") - the parent directory.
2) Recursion of what? Directories? See the File Listing sample. The same basic pattern can be applied to various hierarchical data structures; e.g., see the Node Properties sample. If you are in fact "weeding," as you say, you'll wan't to be mindful of scanarios where you iterate over a dynamic list; e.g., removing items from a list that you are also iterating over.
Hard to say what you're seeing in the debugger without more detail.
-Rob
Rob, I solved it, it does all work. Recursion was a weird effect that when I had called the Progress sheet, the routine that was recursivly called locked up, but it wasn't recursion, but the progress sheet that was the bad guy ;-)