07-10-2008, 03:58 PM
Thanks Gintaras!!!!
Your example was clear and allowed me to make my own taglist creator. This will eventually be part of a form that a user will fill out to categorize various data with their own individual tags.
Right now it only mes 's the selected tag but this will eventually be part of a form that a user will fill out to categorize various data with their own individual tags.
I hope this will be useful to others.
I will eventually put the .txt file in an xml or .ini file for each user
Any suggestions on how to more quickly delete all the tags. Is there a function to get all the contents of a ListBox and put it into a string or an Array. As you will see below, I kind of do it in a roundabout way (clear it, then count it, then create new array)
Thanks again for all your help!!!
Stuart
Function TagListDialog
Your example was clear and allowed me to make my own taglist creator. This will eventually be part of a form that a user will fill out to categorize various data with their own individual tags.
Right now it only mes 's the selected tag but this will eventually be part of a form that a user will fill out to categorize various data with their own individual tags.
I hope this will be useful to others.
I will eventually put the .txt file in an xml or .ini file for each user
Any suggestions on how to more quickly delete all the tags. Is there a function to get all the contents of a ListBox and put it into a string or an Array. As you will see below, I kind of do it in a roundabout way (clear it, then count it, then create new array)
Thanks again for all your help!!!
Stuart
Function TagListDialog
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 5"
str lb3 e5
e5="Enter New Tag Here..."
if(dir("$my qm$\TagList.txt"))
,lb3.getfile("$my qm$\TagList.txt")
else lb3.setfile("$my qm$\TagList.txt")
if(!ShowDialog("TagListDialog" &TagListDialog &controls)) ret
str SelectedTag = lb3
SelectedTag.replacerx("^\d+ " "")
if SelectedTag = "-1"; ret; else mes SelectedTag
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 193 189 "Tag List"
;1 Button 0x54030001 0x4 94 72 48 14 "OK"
;2 Button 0x54030000 0x4 144 72 48 14 "Cancel"
;4 Button 0x54032000 0x0 94 20 98 14 "Add Tag"
;5 Edit 0x54030080 0x200 94 4 98 14 "Enter New Tag Here...."
;7 Button 0x54032000 0x0 94 54 98 12 "Clear Tag List"
;6 Button 0x54032000 0x0 94 38 98 14 "Delete Selected Tag"
;3 ListBox 0x54230101 0x200 2 2 90 186 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030000 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4 ;;Update
,,str AddTag
,,AddTag.getwintext(id(5 hDlg))
,,str AddTagBracket.format("%s[]" AddTag)
,,AddTagBracket.setfile("$my qm$\TagList.txt" -1);;adds new tag with bracket to file
,,str TagList.getfile("$my qm$\TagList.txt");; gets updated TagList from file
,,ARRAY(str) TagArray=TagList; int i;;puts updated TagList into array for display in ListBox
,,int hlb=id(3 hDlg)
,,SendMessage hlb LB_RESETCONTENT 0 0;;clears current ListBox
,,for i 0 TagArray.len;;populates ListBox with Updated TagList(placed into Array)
,,,LB_Add hlb TagArray[i]
,case 6
,,hlb=id(3 hDlg)
,,_i=LB_SelectedItem(hlb)
,,if(_i>=0) SendMessage hlb LB_DELETESTRING _i 0;;deletes selected item from taglist
,,;update taglist
,,_i=LB_GetCount(hlb)
,,ARRAY(str) NewTagArray
,,NewTagArray.create(_i)
,,for i 0 _i
,,,str tag
,,,LB_GetItemText(hlb i tag)
,,,NewTagArray[i]=tag
,,str NewTagList= NewTagArray
,,out NewTagList
,,NewTagList.setfile("$my qm$\TagList.txt" 0);;replaces prior TagList with NewTagList
,case 7;; Clear TagList
,,if(mes("Are you sure you want to delete the entire TagList?" "" "YNC!")!='Y') ret
,,hlb=id(3 hDlg)
,,SendMessage hlb LB_RESETCONTENT 0 0
,;,update taglist with empty list
,,_i=LB_GetCount(hlb)
,,ARRAY(str) EmptyArray
,,EmptyArray.create(_i)
,,str notags
,,for i 0 _i
,,,LB_GetItemText(hlb i notags)
,,,EmptyArray[i]=notags
,,str EmptyTagList= EmptyTagList
,,EmptyTagList.setfile("$my qm$\TagList.txt" 0);;replaces prior TagList with NewTagList
,,
,case IDOK
,case IDCANCEL
ret 1