Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetQmItemNames fetches content from system folder
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 = 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:

Function qm_snippet_navList
Copy      Help
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
This function?
QM file Export Options.

I cannot reproduce.
Which System folder items it fetches?
Run this macro. What it displays in output?
Copy      Help
str process_pth="\RR_QM_enhancements\__ACTIVE__\QM_popupmenu"
QMITEM q; qmitem(process_pth 0 q 1); out
Yes, it is that function.

I did an output of what was fetched:

Copy      Help
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:
Copy      Help

it is a folder (subfolder of '__ACTIVE__')


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:

But "GetQmItemPath" does not skip the system folders.

I think this is the problem.


Function qm_snippet_navList
Copy      Help
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 "")
,,midclick_menuname.findreplace(basemenu_name "")
,,str x.getmacro(c 7)
,,int qid=val(x)
,,str fullpath
,,GetQmItemPath qid fullpath
,,GtPathOrFolder(fullpath before_bslash after_bslash)
,,if(findrx(_s regx_filefolder)>=0)
,,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)
nav_list.Sort(4 0)
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")
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.
Function GetQmItemsInFolder
Copy      Help
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.

type __GQIF_DATA ARRAY(int)*a ARRAY(int)*aLevel htv
d.htv=id(2202 _hwndqm)

EnumQmFolder folder 0 &GQIF_Enum &d

Function GQIF_Enum
Copy      Help
function# iid QMITEM&q level __GQIF_DATA&d

;skip some folders
if q.itype=5
,sel( 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
if d.aLevel

Macro Macro2233
Copy      Help
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

This works PERFECTLY!!!
updated, added aLevels.

This saves me even more time, the levels addition makes this even better!

Thank you very very much for your effort in this!!!
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.
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 (
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
Copy      Help
,int u=val(_s)
,;; SD2    
,GetQmItemPath u fullpath
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.

GetQmItemPath _i

ok! thank you!!!
Or in GetQmItemPath replace the case VT_I4 line:
,case [VT_I4,VT_I2] iid=item.iVal

Forum Jump:

Users browsing this thread: 1 Guest(s)