Alpha DevCon 2018
Results 1 to 17 of 17

Thread: supercontrol clock in realtime

  1. #1
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default supercontrol clock in realtime

    How to make the clock running in real time?

    A cal_field with expression of upper(totime(toseconds(time()),11,0)) only show a digital time.
    I added the expression within the supercontrol events, but did not get the clock running either.

    Any help is appreciated.

    I upload my test file.

  2. #2
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: supercontrol clock in realtime

    Hi Razali,

    Change the Timer intervals to 1 and the expression for the calc clock field to totime(toseconds(time()),12,2).

    There is a moving clock example in Samples/Xbasic folder.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  3. #3
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default Re: supercontrol clock in realtime

    Thank you Keith for the information. I saw the sample but could not get the right expression. I hope to make use of the given supercontrol in V9.

    Thanks again.

    Regards,

    Razali

  4. #4
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default Re: supercontrol clock in realtime

    Hello Keith,

    I could not get the calc clock to work. The supercontrol clock seem can not bind any calc field. Where do you place the expression?

    Thanks,

    Razali

  5. #5
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: supercontrol clock in realtime

    Razali,

    Using your sample I placed the following in the OnTimer event and set the timer in the form properties to 60 seconds as the clock only shows in minutes any way.

    Code:
    thistime = now()
    xdialog1.refresh()
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  6. #6
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default Re: supercontrol clock in realtime

    Dear Kim,

    It is working now. The clock is 'alive'.
    Thanks for the tips.

    This message board is certainly dynamic , active and supported by many knowledgeable and helpful programmers.


    Regards,

    Razali

  7. #7
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default Re: supercontrol clock in realtime

    Dear Tim,

    I apologize and sorry for typing your name incorrectly.

    I think I was too happy with your tips, which save my time in doing my current project.

    Thanks again for your help.

    Regards,

    Razali

  8. #8
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: supercontrol clock in realtime

    Hi Tim,

    Thanks for
    Code:
    thistime = now()
    xdialog1.refresh()
    I found that I had to also put this in the OnInit event as the clock was not visible when the form was opened.

    Although the clock does refresh to the computer time, how do you fix the clock to prevent the user from moving the hands?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  9. #9
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,381

    Default Re: supercontrol clock in realtime

    Here is a function that produces a clock on a fully dockable panel.

    Code:
    'Date Created: 22-Apr-2008 03:31:37 AM
    'Last Updated: 22-Apr-2008 03:31:37 AM
    'Created By  : lance
    'Updated By  : lance
    function dp_clock as v ()
    with vars 
    'Notice that the code in this function is wrapped in a 'with vars...end with' statement.
    'Local_variables() are passed in when the function is called. 
    'Because of the 'with vars' statement, this code is executing in the same variable frame as the Xdialog so it can
    'see all of the variables in the Xdialog.
    DIM SHARED cl as T
    DIM cl_Clock as P
    cl=time("",now())
    DIM cl_Clock.events as C = <<%str%
    function onTimeSelect as v (ptr as p)
        
        ' Generated code. Do not delete!
        ' ------------------------------------------------------------------------
        if eval_valid("ptr.variableName") then
            dim sv as p
            sv = session_variables()
            evaluate_template("sv."+ptr.variableName+" = if(typeof(sv."+ptr.variableName+")=\"T\",ptr.time,ptr.shortTime)")
        end if
        ' ------------------------------------------------------------------------
    end function
    
    function onMeridianChange as v (ptr as p)
        
    end function
    %str%
    
    if typeof(cl) = "Y" then
        DIM cl_Clock.shortTime as Y = cl
    else
        DIM cl_Clock.time as T = cl
    end if
    DIM cl_Clock.variableName as C = "cl"
    
    dim dlg_panel_body as c 
    dlg_panel_body = <<%dlg%
    {background=Pale Blue}
    {timer=increment}
    {interval=1}
    {stretch=height,width}
    {TimePicker=40,15cl_Clock}{watch=cl!update_cl_Clock};
    {stretch=}
    {stickto=bottom,left}
    %dlg%
    dim dlg_panel_event as c 
    dlg_panel_event = <<%code%
    if a_dlg_button = "increment" then
    
        cl_Clock.shortTime=time("",now())
    
    
        
    
    end if
    
    
     
    %code%
    'ui_dlg_panel() is like ui_modeless_dlg_box(), except that it is used to launch xdialogs that are hosted in Panels.
    ui_dlg_panel("panel5",dlg_panel_body,dlg_panel_event)   
    end with         
    end function
    For information on using dockpanels see 'user defined dock panels' in learning xdialog database

  10. #10
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: supercontrol clock in realtime

    Good morning Lance,

    How do you use this function?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  11. #11
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,381

    Default Re: supercontrol clock in realtime

    Good Morning Keith,

    I use xdialog a lot, find it a lot better than using forms, and with HTML you can make them look very good. One of the main uses in my application is menu screens, I create MDI xdialogs as they can be minimized, maximized etc. The main xdialog has data relevant to that day and various dock panels around that show other information and menu items, one of which is a clock as above. The code to do the dock_panels is:
    Code:
    'This XML string defines the Dock Panels that get installed for this MDI window.
    'In this example we have two user defined Dock Panels, and one of the built in Alpha Five Dock Panels (the Database Explorer).
    'Each <panel> tag in the XML string defines a panel.
    'Name - the name that appears in the title bar of the panel
    'Icon - the icon that is displayed when the panel is minimized
    'Install - the xbasic code to run to instantiate the panel.
    '    In this case the functions that instantiate Panel1 and Panel2 are local function defined in this script.
    '    When Alpha Five insantiates the Dock Panels it cannot see local functions in this script, so it cannot see the dockpanel_1() and
    '    docpanel_2() functions. Therefore we have to use the ui_dlg_eval() function to call the functions IN THE CONTEXT of the MDI Xdialog.
    '    ui_dlg_eval() takes two arguments: the dialog title, and the expression to evaluate in the context of the specified dialog.
    '    Note that we use a placeholder '__dlg_title__' for the dialog title, and then we do a stritran() to replace the 
    '    placeholder with the actual value of the dialog title.
    '    Note also that we pass in local_variables() to the two functions that open the Dock Panels so that these functions can operate in the same
    '    variable namespace as the MDI Xdialog (i.e. the Dock Panels can see and set variables in the MDI Xdialog).
    
    
    
    dim xml_Panels as c 
    xml_Panels = <<%xml%
    <panels>
            <panel name="Panel2" description="Upcoming tasks" icon="$a5_open" install="dp_todo(local_variables())" />
        <panel name="Panel3" description="Current Jobs" icon="$$database"  install="dp_jobs(local_variables())" />
        <panel name="Panel4" description="Calendar" icon="$$control.calendar" install="dp_cal()" />
        <panel name="Panel5" description="Clock" icon="$$control.clock" install="dp_clock()" />
        <panel name="Panel6" description="Open Items" icon="$$presentation.form" install="dp_openitems(local_variables())" />
        <panel name="Panel7" description="Estimates" icon="$$presentation.form" install="dp_estimates(local_variables())" />
        <panel name="Panel8" description="menu1" icon="$$presentation.form" install="dp_casc_menu(local_variables())" />
    
    </panels>
    
    
    %xml%
    
    'Replace the placeholder with the actual dialog title.
    xml_Panels = stritran(xml_Panels,"__dlg_title__",dlg_title)
    
    ui_modeless_dlg_box(dlg_title,<<%dlg%
    {icon=A5_ball_green}
    {timer=increment}
    {interval=60}
    {mdichild=mymdiclass}
    {startup=init}
    {on_activate=onactivate}
    {stretch=width,height}
    {HTMLForm=1,3htmlform}
    {stretch=}
    {lf};
    
    
    %dlg%,<<%code%
    if a_dlg_button = "increment" then
    tim=time()
        select 
     	case tim<"11:59" 
        daytime="morning"
        case tim>"12:00" .and. tim<"18:00"
        daytime="afternoon"
        case tim>"18:00"
        daytime="evening"
        
    end select
    message ="Good "+daytime+" "+w_upper(word( user_name(),1))
    tables.outstpay=getpayTable()
    outsttotal=tablesum("invoice header","due_date<date()+10","outstanding")
    outtotaltxt=transform(outsttotal,"$$,$$$,$$$.99")     
    end if
    if a_dlg_button = "init" then 
            'show the toolbar
            dim pDummy as p 
            pDummy.dummy = ""
            dim contextName as c 
            contextName = "Mdi_Example" + session_get()
           topparent.Maximize() 
           
            'create a new context for menus and toolbars.
            'any menus and toolbars that are intialized after the context has been created are 
            'NOT shown when the code that initializes them is executed.
            'They are shown however, when the context is set.
            
            ui_context_create(contextName,"MDI_TEST")
            'toolbar_name = a5_system_toolbar_show(pDummy,toolbar_string)
            
            'show the menu
            'the ui_expand_branched() function is used to expand certain menu 'macros' (such as recent file list, or window list)
            'at runtime.
            ui_top_menu(ui_expand_branches(menu_string),event_string)
            
            
            
            'This is the command that actually loads into memory the Dock Panels specified in the XML string 'xml_panels'
            ui_context_panels_load(contextName,xml_Panels)
            
            'This command restores the position of all Dock Panels.
            'The position is automatically saved when the MDI window is closed.
            ui_context_panels_restore(contextName,.t.)
            'Note: The very first time this script is run, no Dock Panels will be shown until the user explicitly launches them
            'from the 'Task List' menu item. 
            'If you want to open Dock Panels automatically when the window is launched for the first time, see commented code below
            'in the 'onActivate' event handler
            
            
    
            'set the context - this will explicitly display a set of menus and toolbars that have been saved under a 
            'named context
            ui_context_set(contextName)
            
            'bind the context to the session so that when the session is activated, it automatically does a 
            'ui_context_set() to show the toolbars and menus that 'belong' to it, and then when the session is 
            'destroyed, it automatically does a ui_context_destroy() 
            ui_context_session_bind(contextName)
            
    end if 
    
    
    if a_dlg_button = "activate"      
           a_dlg_button = ""   
               
           'if flagFirstTimeRun then 
           '	this is the code to programmatically open a Dock Panel.
    	   '    ui_dock_panel_show("Panel1",.t.)
           '	ui_dock_panel_show("Panel2",.t.)
           '	set firstTimeRun to .f. and store value somewhere so that it can be read every time this script is run. 
           '	(you could store it in the registry)
           'end if 
    end if
    I have not checked if this will run 'out of the box' but doubt it as it will try and load other dock_panels and the MDI class is not defined so - More information can be found in the learning xdialog sample database

  12. #12
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,381

    Default Re: supercontrol clock in realtime

    Keith (and others),

    This produces a standalone dialog box with a clock in it. This could be put into a toolbar if required.

    Code:
    DIM SHARED cl as T
    DIM cl_Clock as P
    cl=time("",now())
    DIM cl_Clock.events as C = <<%str%
    function onTimeSelect as v (ptr as p)
        
        ' Generated code. Do not delete!
        ' ------------------------------------------------------------------------
        if eval_valid("ptr.variableName") then
            dim sv as p
            sv = session_variables()
            evaluate_template("sv."+ptr.variableName+" = if(typeof(sv."+ptr.variableName+")=\"T\",ptr.time,ptr.shortTime)")
        end if
        ' ------------------------------------------------------------------------
    end function
    
    function onMeridianChange as v (ptr as p)
        
    end function
    %str%
    
    if typeof(cl) = "Y" then
        DIM cl_Clock.shortTime as Y = cl
    else
        DIM cl_Clock.time as T = cl
    end if
    DIM cl_Clock.variableName as C = "cl"
    
    dim dlg_panel_body as c 
    dlg_panel_body = <<%dlg%
    {can_exit=close}
    {background=Pale Blue}
    {timer=increment}
    {interval=1}
    {stretch=height,width}
    {TimePicker=40,15cl_Clock}{watch=cl!update_cl_Clock};
    {stretch=}
    {stickto=bottom,left}
    %dlg%
    dim dlg_panel_event as c 
    dlg_panel_event = <<%code%
    if a_dlg_button = "increment" then
    
        cl_Clock.shortTime=time("",now())
    
    
        
    
    end if
    if a_dlg_button = "close" then
        ui_modeless_dlg_close("clock")
    end if
    
     
    %code%
    ui_modeless_dlg_box("clock",dlg_panel_body,dlg_panel_event)

  13. #13
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default Re: supercontrol clock in realtime

    Hi Lance,

    the clock looks great and useful.

    How do we add the numeric input like the supercontrol clock?

    Thanks

    Razali

  14. #14
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,381

    Default Re: supercontrol clock in realtime

    Hi Razali,

    As the title of this thread suggests this is a clock in realtime, ie it counts in minutes of the day. You can set the initial time to something different by setting cl in line 3 to any time value

  15. #15
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: supercontrol clock in realtime

    Hi Lance,

    That is very cute. Whilst you can move the hands they jump back to the current time.

    This can be run from an OnActivate event of say, the Main Menu. Once run it will stay active throughout the session or until you close it.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  16. #16
    Member
    Real Name
    Razali Yahaya
    Join Date
    Oct 2007
    Location
    Banting, Malaysia
    Posts
    64

    Default Re: supercontrol clock in realtime

    Lance,

    I mean how to have a digital clock (real time) show up beneath the traditional hand clock?

    Thanks

  17. #17
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,395

    Default Re: supercontrol clock in realtime

    Quote Originally Posted by adamry View Post
    Lance,

    I mean how to have a digital clock (real time) show up beneath the traditional hand clock?

    Thanks
    At this line:
    {stickto=bottom,left}

    change it to:
    {stickto=bottom}
    {justify=center}
    [25cl_clock.shorttime];

    And you will be able to see the millisecond countdown
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Where did the supercontrol templates go?
    By jopowers68 in forum Alpha Five Version 9 - Desktop Applications
    Replies: 9
    Last Post: 06-20-2009, 05:11 PM
  2. Using a supercontrol
    By Edward W Larrabee in forum Alpha Five Version 9 - Desktop Applications
    Replies: 7
    Last Post: 07-11-2008, 10:21 AM
  3. SuperControl -- Map
    By gschepp in forum Alpha Five Version 9 - Desktop Applications
    Replies: 0
    Last Post: 04-30-2008, 10:16 AM
  4. SuperControl
    By jkukuda in forum Alpha Five Version 9 - Desktop Applications
    Replies: 5
    Last Post: 04-30-2008, 07:46 AM
  5. Realtime support options?
    By tlyon in forum Alpha Five Version 4
    Replies: 3
    Last Post: 06-06-2000, 08:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •