February 9, 2017

Picking up where we left off yesterday, we will look at our Menu System on our Clock Calendar.

Project Mgr Menu

If you followed along on the Building a Better Desktop session then you have seen this before. I decided to review the code with you since I have made changes. Here is the xbasic code for building the menu. (please note not all links are complete)

'Date Created: 04-Nov-2009 03:43:05 PM
'Last Updated: 09-Dec-2016 07:57:28 AM
'Created By  : User
'Updated By  : NLaws
'dim xIcn as C = "a5_blue_button"
subjectlist = ""
subjectlist = table.external_record_content_GET("applicationlist", "'{I=$$folder}'+Alltrim(Menu_Name)+' |{I=$$folder.open}'+Alltrim(BTNGroup)+' |{I='+alltrim(Iname)+'}'+alltrim(File_Name)","Alltrim(Menu_Name)+' '+Alltrim(BtnGroup)+' '+File_Name","ID = 1 .and. alltrim(File_Name) <> 'Blank'")
cltlist = table.external_record_content_GET("applicationlist", "'{I=$$generic.favorite}TakeCharge Software | {I=$$folder.open}'+Alltrim(BtnGroup)+' |{I='+alltrim(Iname)+'}'+alltrim(File_Name)","Menu_name + BtnGroup + File_Name","ID = 3 .and. alltrim(File_Name) <> 'Blank'")
webList =  table.external_record_content_GET("weblist", "'{I=$$generic.bookmark}Web Bookmarks | {I=$$generic.world}'+Alltrim(Groups)+' | WEB : {I=$$generic.network}'+alltrim(Bookmark)","Groups + Bookmark","")
dim FileAddr as C
dim SHARED mymenu as C
style = <<%str%
menu.v_item_min_leftx=.25
color.menu_v_background=Dirty White
color.menu_v_left=Light Blue
color.menu_v_right=Blue White
font.menu=Tahoma,8,0
%str%
vMenuItems = <<%a%
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$code.library}Quick Launch Bar
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$code.library}Journal 
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$code.library.add}Reminders 
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$control.calendar}Schedular 
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$control.clock}Time & Billing 
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$code.library}TC Invoicing 
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$control.calculator}Calculator 
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$generic.hammer}TC File Utility Manager
{I=$$generic.favorite}TakeCharge Desktop Add-Ons | {I=$$generic.world}TC Web Bookmark Manager
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$code.library.add}Code Library
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$generic.people}TC Contact Manager | {I=$$table.add}Developer Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$generic.people}TC Contact Manager | {I=$$table.add}User Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$format.text.edit}TC Message Center | {I=$$table.add}Developer Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$format.text.edit}TC Message Center | {I=$$table.add}User Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$format.text.edit}TC Games | {I=$$table.add}Developer Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$format.text.edit}TC Games | {I=$$table.add}User Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$generic.book.closed}TC King James Bible Reader | {I=$$table.add}Developer Mode
{I=$$generic.favorite}TakeCharge Project Mgr | {I=$$generic.book.closed}TC King James Bible Reader | {I=$$table.add}User Mode
_____________________
%a%

vMenuItems = vMenuItems+ cltlist + crlf() + subjectList +  crlf() + webList + crlf()  
vMenuItems = vMenuItems + <<%a%
_____________________
%a%
dtlist = table.external_record_content_GET("applicationlist", "'{I=$$application.ms}Microsoft Desktop Apps | {I=$$folder.open}'+Alltrim(BtnGroup)+' |{I='+alltrim(Iname)+'}'+alltrim(File_Name)","Menu_name + BtnGroup + File_Name","ID = 2 .and. alltrim(File_Name) <> 'Blank'")
vMenuItems = vMenuItems+ dtlist+crlf() + <<%a%
_____________________
{DATA=TC Menu Manager}{I=$$code.script.favorite}TC Menu Manager
{DATA=TC Control Panel}{I=$$control.image}TC Control Panel
{DATA=Exit}{I=$$generic.exit}Exit
%a%
mymenu = ui_popup_styled_menu(vMenuItems, style)
if mymenu = "" then
    end 
end if
ui_freeze(.t.)
if mymenu = "{I=$$generic.hammer}TC File Utility Manager" then
    form.load("TCFileManager","popup","","center","center")
    TCFileManager.Activate()
    TCFileManager.Show()
    form.close()        
    ui_freeze(.f.)
Calendar:button43.activate()
else if mymenu = "{I=$$generic.world}TC Web Bookmark Manager" then
    form.load("Web_Manager","popup","","center","center")
    Web_Manager.Activate()
    Web_Manager.Show()
    form.close()        
    ui_freeze(.f.)
Calendar:button43.activate()
else if mymenu = "{I=$$code.library}Quick Launch Bar" then
    form.load("Project_Mgr","popup","","center","top")
    Project_Mgr.Activate()
    Project_Mgr.Show()
    form.close()        
    ui_freeze(.f.)
Calendar:button43.activate()
else if mymenu = "{I=$$code.library.add}Code Library" then
    form.load("TCAppMgr2","popup","","center","center")
    TCAppMgr2.Activate()
    TCAppMgr2.Show()
    form.close()        
    ui_freeze(.f.)
Calendar:button43.activate()
else if mymenu = "{I=$$code.library.add}Reminders" then
    form.load("Reminder","popup","","center","center")
    Reminder.Activate()
    Reminder.Show()
    form.close()
Calendar:button43.activate()
else if mymenu = "{I=$$control.clock}Time & Billing" then
    form.load("TimerDialog","popup","","center","center")
    TimerDialog.Activate()
    TimerDialog.Show()
    form.close()
Calendar:button43.activate()
else if mymenu = "{I=$$control.calculator}Calculator" then
    t = table.open("calc_detail")
    t.pack()
    t.close()
    xbasic_wait_for_idle()
    form.load("cdcTapeCalc","popup","cdcTapeCalc","center","center")
    cdcTapeCalc.Activate()
    cdcTapeCalc.Show()
    cdcTapeCalc:vlineitem.Activate()    
    form.close()
Calendar:button43.activate()
else if mymenu = "{I=$$code.library}TC King James Bible Reader" then
    form.load("TC_KJB_Reader","popup","","center","center")
    TC_KJB_Reader.Activate()
    TC_KJB_Reader.Show()
    form.close()
Calendar:button43.activate()
else if mymenu = "{I=$$generic.bookMark}My Book Marks" then    
    form.load("MyBookmarks","popup","","center","center")
    MyBookmarks.Activate()
    MyBookmarks.Show()
    form.close()
Calendar:button43.activate()
else if mymenu = "{I=$$table.add}Enter Company Info" Then
    filename = "c:\TC_Suite\License Files\C83476CT8W.txt"
    result = file.exists(filename)
    if result = .f. then
        'Enter No License Code Here'
    else
        ui_freeze(.t.)
        if is_object("items_overdue") then
            :items_overdue.hide()
        end if
        form.load("CompanyInformationForm","popup","","center","center")
        CompanyInformationForm.Activate()
        CompanyInformationForm.New_record()
        CompanyInformationForm.Show()
        form.close()
        ui_freeze(.f.)
    end if
Calendar:button43.activate()
else if mymenu = "{I=$$table.add}Enter Contact Info" Then
    filename = "c:\TC_Suite\License Files\C83476CT8W.txt"
    result = file.exists(filename)
    if result = .f. then
        'Enter No License Code Here'
    else
        ui_freeze(.t.)
        if is_object("items_overdue") then
            :items_overdue.hide()
        end if
        form.load("ContactEntryForm","popup","","center","center")
        ContactEntryForm.Activate()
        ContactEntryForm.New_record()
        ContactEntryForm.Show()
        form.close()
        ui_freeze(.f.)
    end if
Calendar:button43.activate()
else if mymenu = "{I=$$generic.people}Contacts by Company" Then
    filename = "c:\TC_Suite\License Files\C83476CT8W.txt"
    result = file.exists(filename)
    if result = .f. then
        'Enter No License Code Here'
    else
        ui_freeze(.t.)
        if is_object("items_overdue") then
            :items_overdue.hide()
        end if
        form.load("ContactsbyCompany","popup","","center","center")
        ContactsbyCompany.Activate()
        ContactsbyCompany.Show()
        form.close()
        ui_freeze(.f.)
    end if
Calendar:button43.activate()
else if mymenu = "{I=$$generic.people}Contacts Activities" Then
    filename = "c:\TC_Suite\License Files\C83476CT8W.txt"
    result = file.exists(filename)
    if result = .f. then
        'Enter No License Code Here'
    else
        ui_freeze(.t.)
        if is_object("items_overdue") then
            :items_overdue.hide()
        end if
        form.load("People_cdc","popup","","center","center")
        People_cdc.Activate()
        People_cdc.Show()
        form.close()
        ui_freeze(.f.)
    end if
Calendar:button43.activate()
else if mymenu = "{I=$$format.text.edit}Quick Note Organizer" Then
    filename = "c:\TC_Suite\License Files\C83476CT8W.txt"
    result = file.exists(filename)
    if result = .f. then
        'Enter No License Code Here
    else
        ui_freeze(.t.)
        if is_object("People_cdc") then
            :people_cdc.hide()
        end if
        form.load("QuickNoteOrganizer","popup","","center","center")
        QuickNoteOrganizer.Activate()
        QuickNoteOrganizer.Show()
        form.close()
        ui_freeze(.f.)
    end if
Calendar:button43.activate()
else if mymenu = "{I=$$format.text.edit}Print Open Item Rpt" Then
    filename = "c:\TC_Suite\License Files\C83476CT8W.txt"
    result = file.exists(filename)
    if result = .f. then
        'Enter No License Code Here
    else
        if is_object("People_cdc") then
            :people_cdc.hide()
        end if
        if is_object("items_overdue") then
            :items_overdue.hide()
        end if
        query.filter = ""
        query.order = ""
        prompt_result = ui_get_print_or_preview("Preview ")
        If prompt_result = "Print" then
            :Report.Print("upcoming_events",query.filter,query.order)
        Else if prompt_result = "Preview" then 
            :Report.SaveAs("upcoming_events","PDF",query.filter,query.order,"",.T.)
        End if
    end if
Calendar:button43.activate()
else if mymenu = "TC Menu Manager" Then
    form.load("MenuManager","popup","","center","center")
    MenuManager.Activate()
    MenuManager.Show()
    form.close()
else if mymenu = "TC Control Panel" Then
    ui_freeze(.t.)
    parentform.close()
    controlpanel.show()
    A5_WINDOWBAR_SHOW() 
    a5.show()
    ui_freeze(.f.)
else if mymenu = "Exit" Then
    a5.close()
else
    if word(mymenu,1,":",1) = "WEB" then
        tbl = table.open("weblist")
        tbl.batch_begin()
        tbl.fetch_first()
        while .NOT. tbl.fetch_eof()
            if alltrim(tbl.Bookmark) = word(mymenu,2,"}",1)
                CLine = tbl.File_location
            end if
            tbl.Fetch_Next()
            end while
            tbl.Batch_End()
        tbl.close()
        if len(Alltrim(Cline)) = 0 then
            ui_msg_box("Sorry", "The Web page address was not saved."+crlf()+"Use the edit button to save the web address")
            end
        end if
        URL_var = Alltrim(Cline)
        sys_open(URL_var)
    else
        dim useshell as C
        tbl = table.open("applicationlist")
        tbl.batch_begin()
        tbl.fetch_first()
        while .NOT. tbl.fetch_eof()
            'ui_msg_box("",""+mymenu)
            if Alltrim(tbl.File_name) = Alltrim(mymenu) then
                useshell = ""
                CLine = Alltrim(tbl.File_location)
                if Alltrim(tbl.cmd_strg) <> "" then
                    useshell = CLine + " " + Alltrim(tbl.cmd_strg)
                end if
            end if
        tbl.Fetch_Next()
        end while
        tbl.Batch_End()
        tbl.close()
        if file.filename_parse(CLine,"E") = ".exe"
            if useshell = "" then
                sys_shell(CLine,1)
            else 
                sys_shell(useshell,1)
            end if
        else
            if left(Alltrim(CLine),3) = "www" then
                URL_var = Alltrim(Cline)
                sys_open(URL_var)
            else
                sys_open(CLine)
            end if    
        end if
    end if
end if




end

Now the popup menu is not different, the code to create it is, so all we need to concern ourselves with today is  the list building code at the top of the script. SubjectList and CltList are built from records in our Application List Table and Web List is from or Web List Table. Each list is assigned to a variable which is then passed to our popup menu. The difference in this code and the previous example is the grouping. Previously the menu order was mixed, some built by code and some hard coded and none in any specific order. Now the code puts all code built list at the top and hard coded menu options at the bottom. Also, the list is ordered so that new entries to Application List or Web List tables sort correctly keeping the menu form creating duplicate menu levels. The image above shows menu choices from the Application List table.

Now lets look at another new feature which is our Menu Manager.

Command String Bldr-01

In general this is a simple form which needs little or no explanation. Look at the button the green arrow points to. ‘Build Command String’. This is for Alpha Software developers who are not sure how to build a command string for the desktop icon . When you click the button the screen help switches (thanks to a conditional object) to a series of smart fields which step the user through creating the command string.

Command String Bldr -02

Now when the application is selected from the popup menu on the calendar it loads without showing the Alpha Software stuff. For those who know how to write a command string they simply need to fill in the field manually.  Here is how the code which creates the string is written.

cmd_string.text = chr(34)+Alltrim(vAP)+chr(34)+" -"+Alltrim(vSP)+if(vSP="splash","-splash="+chr(34)+Alltrim(vSPName)+chr(34),"")+" -tittle="+Alltrim(vTittle)+chr(34)+" -icon="+Alltrim(vIconName)+chr(34)

The next thing I wanted to look at is the File Utility Manager. Again no major breakthrough’s here.

Project Mgr Utilities

This form, a tag style file utility system with Quick Launch, file utilities, search features and soon to have one click back up and restore is a simple way to organize and control your projects. Another feature it will have is version control. Each backup will allow you to assign a version control id and when a restore is  necessary the backup’s are listed in descending version id order.

That’s all for today. If you are a business and need help with an Alpha Software program, contact us. Are rates are reasonable and our work is guaranteed.

Phone:713 417-6831

EMail: NLawson@cdc-takecharge.com