Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetQmItemsInFolder, also fetches outside specified folder
#1
Macro Macro11
Code:
Copy      Help
QMITEM q
str p="\test1"
str s
ARRAY(QMITEMIDLEVEL) a; int i
if(!GetQmItemsInFolder(p &a)) end "failed"
for i 0 a.len
,_i=a[i].id
,qmitem(_i 0 &q 1|8)
,GetQmItemPath q.name s
,out s


I am having a bit of trouble to reproduce the issue, so I just copy and paste the output of GetQmItemsInFolder.

When attempting to output the contents of '\test1' which is a folder in the root of the qm itemslist, I get this output

\______FUNCTIONS\regex, find, replace\RegexMenu\test_and_info_and_basescripts\sub2
\test1\sub2\test1@
\______FUNCTIONS\dlg_functions\inputfield_validation_functions\__OLD\other_temporary_testversions\test2
\test1\sub2\test1@\test2\Macro8
\test1\sub2\test1@\test2\Macro3
\test1\sub3
\test1\sub3\test3

The bold blue paths are paths outside '\test1' which I do not want  (I suspect it could be something to to do with \test in the bold paths (?))
When I look in the help file I see that GetQmItemsInFolder also accepts +id , when I try an integer or integer stored in an variant or string GetQmItemsInFolder errors.

ROOT
|
|
|--test1   <========= need contents of this folder
|   |
|   |-...
|   |-...
|
|
|--______FUNCTIONS <====== BUT some items of within this folder also get's included in 'a[]'
|         |
|         |
|         |- ...
|         |- ...
|         |- ...

My questions
1. Am I using GetQmItemsInFolder incorrectly?
2. What is +id and how do I use it? (I assume using the id of 'test1' of in stead of 'test1' itself might constrain the results within 'test1')
#2
GetQmItemPath _i s
#3
Sorry I gave wrong example, this is the correct one I am trying to use but it gives me 'expected string' error

Macro Macro11
Code:
Copy      Help
QMITEM q
str p="\test1"
_i=qmitem(p 0 &q 1|8)
ARRAY(QMITEMIDLEVEL) a; int i
if(!GetQmItemsInFolder(_i &a)) end "failed" ;; <============ 'Expected string...'
for i 0 a.len
,_i=a[i].id
,qmitem(_i 0 &q 1|8)
,GetQmItemPath q.name s
,out s
This works:  GetQmItemPath _i s

But when using _i in GetQmItemsInFolder I get the following error:
"expected string    Example converting a numeric variable N to string: str S=N."

#GetQmItemsInFolder    $folder  |   ARRAY(QMITEMIDLEVEL)&a  |  [flags]
folder - folder name, path or +id. Gets all if folder is "".

(I am trying to target the id of the folder in stead of it's path because when using path I get results of items outside the specified folder.)

Is there a way to pass the ID of the folder in GetQmItemsInFolder?
#4
Code:
Copy      Help
if(!GetQmItemsInFolder(+_i &a)) end "failed"
#5
Thank you! It works.
Still getting some (wrong) outside results, but now I know what +id means.
#6
try using full path of the folder in str p=
#7
_i in wrong place. Try my code. If GetQmItemPath  does not work with _i, maybe it is old version, I'll post new version.
#8
Ok....

It now works!!! meaning I now get the contents of the specified folder only!
I swear the first time retried GetQmItemPath _i s I got unwanted results (results from outside specified folder).
Then I tried the +id method and still got unwanted results (but at least no "expected string" error)
I just retried the GetQmItemPath _i s method again just now, and all works!!!

I don't know what I did or what is causing within my QM setup that this happened.
(the only thing I did was restart pc before trying it the last time).

I am still thankful  for the advice my script now works as intended and I know what +id means now.
Thank you both!


Forum Jump:


Users browsing this thread: 1 Guest(s)