Posts: 769
Threads: 263
Joined: Jul 2012
I am a bit lost here, when I use the command: GetQmItemNames to fetch everything within a folder that is not placed within the systemfolder it still fetches foldernames that are in the systemfolder in stead of the defined path to be processed.
I have a folder called "window" and "listbox" within the folder to be processed:
\RR_QM_enhancements\__ACTIVE__\QM_popupmenu
( \RR_QM_enhancements = at root level)
Ï check the extracted items for the existance of \RR_QM_enhancements\__ACTIVE__\QM_popupmenu in the beginning of the extracted item.
Because system folder contents are fetched, those items do not match the following in the beginnig, and get left out:
\RR_QM_enhancements\__ACTIVE__\QM_popupmenu
Function qm_snippet_navList
str process_pth="\RR_QM_enhancements\__ACTIVE__\QM_popupmenu"
str all_items
GetQmItemNames(process_pth all_items)
Is there a sure shot way to get the correct full paths of everything within a folder, including:
- item=macro/folder
- item level
I could do this easily with the "GetQmItemNames" command because the result has "[" and "]" for indicating folder items and "." (dots) for their level.
I am using the portable version 2.4.0.3
Posts: 12,090
Threads: 142
Joined: Dec 2002
This function?
QM file Export Options.
I cannot reproduce.
Which System folder items it fetches?
Run this macro. What it displays in output?
str process_pth="\RR_QM_enhancements\__ACTIVE__\QM_popupmenu"
QMITEM q; qmitem(process_pth 0 q 1); out q.name
Posts: 769
Threads: 263
Joined: Jul 2012
Yes, it is that function.
I did an output of what was fetched:
qm_snippet_navList fullpath: \RR_QM_enhancements\__ACTIVE__\QM_popupmenu\qmpop_dialog_clips\checkbox
qm_snippet_navList fullpath: \System\Functions\Window (*)
qm_snippet_navList fullpath: \RR_QM_enhancements\__ACTIVE__\QM_popupmenu\qmpop_dialog_clips\ddlb
qm_snippet_navList fullpath: \System\Functions\Control\ComboBox, ListBox\ListBox (*)
qm_snippet_navList = function
fullpath = container (variable)
The paths marked with the (*) should not be there in stead these should be retrieved:
fullpath: \RR_QM_enhancements\__ACTIVE__\QM_popupmenu\qmpop_dialog_clips\window
fullpath: \RR_QM_enhancements\__ACTIVE__\QM_popupmenu\qmpop_dialog_clips\listbox
both foldernames ('window' and 'listbox') are lowercase
When I run the provided code I get only one output:
it is a folder (subfolder of '__ACTIVE__')
edit:
Maybe this is the problem:
I used this code to get the item names to be stored in container "all_items":
GetQmItemNames(base_pth all_items)
Then I strip the "[" and "]" and "." and get the path using the function:
GetQmItemPath
But "GetQmItemPath" does not skip the system folders.
I think this is the problem.
edit2
Function qm_snippet_navList
GetQmItemNames(process_pth all_items)
str regx_current_lvl_folder="^\["
foreach _s all_items
,if(findrx(_s regx_current_lvl_folder)>=0)
,,str c=_s
,,;c.replacerx(regx_cleanup_item_1 "")
,,c.replacerx(regx_cleanup_item_2 "")
,,c.replacerx(regx_cleanup_item_3 "")
,,
,,;;SD5
,,midclick_menuname=c
,,midclick_menuname.findreplace(basemenu_name "")
,,
,,;;SD4
,,str x.getmacro(c 7)
,,int qid=val(x)
,,
,,;;SD2
,,str fullpath
,,GetQmItemPath qid fullpath
,,
,,;;SD3
,,GtPathOrFolder(fullpath before_bslash after_bslash)
,,
,,;;SD6
,,if(findrx(_s regx_filefolder)>=0)
,,,isfilefolder="folder"
,,else
,,,isfilefolder="file"
,,
,,level=CharAmountCount(_s level_char)
,,out F"{_s.getmacro(getopt(itemid) 1)} fullpath: {fullpath}"
,,if(findrx(fullpath basename)>=0)
,,,;; 1 2 3 4 5 6 7
,,,;; [id] [full_item_pth] [after last bslash 'qmpop_%NAME%'] [menu item ID] [middle click menu name] [file / folder] [level]
,,,str sd1(cnt) sd2(fullpath) sd3(after_bslash) sd4(qid) sd5(midclick_menuname) sd6(isfilefolder) sd7(level)
,,,nav_list.AddRowSA(0 7 &sd1 0)
,,,;;SD1
,,,cnt=cnt+1
;
nav_list.Sort(4 0)
Posts: 769
Threads: 263
Joined: Jul 2012
The following code get's the path.:
GetQmItemPath qid fullpath
Before the above code is executed I first retrieved the macro ID, then used that ID stored in "qid" to retrieve the full path (in container "fullpath")
Posts: 12,090
Threads: 142
Joined: Dec 2002
str x.getmacro(c 7)
Finds folder with same name in System folder.
GetQmItemNames gets item names. Need to create similar function to get item ids instead. Almost everyting is the same.
Posts: 12,090
Threads: 142
Joined: Dec 2002
Function GetQmItemsInFolder
;/
function $folder ARRAY(int)&a [ARRAY(int)&aLevel]
;Gets QM items in a QM folder and subfolders.
;folder - folder name or path ("\folder1\folder2"). Use "" to include all macros.
;a - variable that receives item ids. Use <help>qmitem</help> or <help>str.getmacro</help> to get item properties.
;aLevel - optional array that receives item levels relative to folder.
a=0
type __GQIF_DATA ARRAY(int)*a ARRAY(int)*aLevel htv
__GQIF_DATA d
d.a=&a
d.aLevel=&aLevel
d.htv=id(2202 _hwndqm)
EnumQmFolder folder 0 &GQIF_Enum &d
Function GQIF_Enum
;/
function# iid QMITEM&q level __GQIF_DATA&d
;skip some folders
if q.itype=5
,sel(q.name) case ["private","System"] ret 1
,;if(!SendMessage(d.htv TVM_GETNEXTITEM TVGN_CHILD q.htvi)) ret 1 ;;skip empty folders
ARRAY(int)& a=d.a
a[]=iid
if d.aLevel
,&a=d.aLevel
,a[]=level
example
Macro Macro2233
out
str process_pth="\RR_QM_enhancements\__ACTIVE__\QM_popupmenu"
ARRAY(int) a
GetQmItemsInFolder(process_pth a)
int i; str fullpath
for i 0 a.len
,;out _s.getmacro(a[i] 1)
,GetQmItemPath a[i] fullpath
,out fullpath
Posts: 769
Threads: 263
Joined: Jul 2012
THANK YOU VERY VERY MUCH!!!!
This works PERFECTLY!!!
Posts: 12,090
Threads: 142
Joined: Dec 2002
Posts: 769
Threads: 263
Joined: Jul 2012
THANK YOU AGAIN!!!!
This saves me even more time, the levels addition makes this even better!
Thank you very very much for your effort in this!!!
Posts: 12,090
Threads: 142
Joined: Dec 2002
QM 2.4.1 will have function with this name, very similar. Will need too delete this GetQmItemsInFolder and slightly change code that uses it.
Posts: 769
Threads: 263
Joined: Jul 2012
Sorry to ask it here, but I do not think it is a bug that's why I asked here:
I altered the "GetQmItemsInFolder" code to work with the current beta version (2.4.1.0).
The problem I have, is the a[i].id is not an integer or not recognized as an integer?
When using the function "GetQmItemPath" in combination with the a[i].id, I get the error:
Quote:Error (RT) in <open "qm_snippet_FirstStart /2071">qm_snippet_FirstStart: incorrect argument. <help #IDP_ERR>?
When I use the val(a[i].id) function, I get the error: "expected string expression"
But when I converted the a[i].id to a string (_s) and then put it into an integer container (u), it works.
See below code, how I used it. (below a[i].id is qm_itm[i].id)
If I used qm_itm[i].id directly I get the error as described above.
Function qm_snippet_FirstStart
,_s=qm_itm[i].id
,int u=val(_s)
,;; SD2
,GetQmItemPath u fullpath
Posts: 12,090
Threads: 142
Joined: Dec 2002
GetQmItemPath first parameter is VARIANT. The VARIANT can contain string or int, but a[i].id is word. Need either change something in GetQmItemPath, or assign a[i].id to an int variable.
_i=a[i].id
GetQmItemPath _i
Posts: 769
Threads: 263
Joined: Jul 2012
Posts: 12,090
Threads: 142
Joined: Dec 2002
Or in GetQmItemPath replace the case VT_I4 line:
,case [VT_I4,VT_I2] iid=item.iVal
|