Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Hour Pickers for Select Lists

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hour Pickers for Select Lists

    The UDF's included below provide two methods for automatically generating hour pick-lists for HTML select lists or grid/dialog dropdown lists. (I couldn't get the text file to attach, so I am including the UDF's below).

    The first is get_hour_picker(), which will output a crlf-delimited list of hours and fractions of hours based on the input parameters. It is intended to be used for applications that need to select amounts of time (e.g., an attendance application, or job tracking, etc.), but you may find many other applications for it as well. The min_value and max_value parameters set the upper and lower limits for the number of hours. The minutes_apart parameter specifies the incremental step for each item in the list. The html_ready parameter determines whether the function should return an HTML-useable select list, or just a crlf-delimited list. This UDF takes three optional parameters:

    • min_value (default = 0) -- sets the minimum number of hours
    • max_value (default = 10) -- sets the maximum number of hours
    • minutes_apart (default = 15) -- sets the incremental step for each line item
    • html-ready (default = .f.) -- return HTML select list (.t.) or crlf-delimited list (.f.)


    The second is get_time_picker(), which will output a list of times of day based upon the input parameters. It is intended to be used for applications that need to select the time of day based over a given time-frame and incremental steps, in 12- or 24-hour format. The min_hour and max_hour parameters set the earliest and latest times in the list; the am_pm parameter sets the output format; and the minutes_apart parameter sets the incremental step for each item in the list. The html_ready parameter determines whether the function should return an HTML-useable select list, or just a crlf-delimited list. This UDF takes three optional parameters:

    • min_hour (default = "00:00:00") -- sets the earliest hour for the list
    • max_hour (default = "23:59:59") -- sets the latest hour for the list
    • am_pm (default = 12) -- sets the output format (12 = 12-hour clock; any other number = 24-hour clock)
    • minutes_apart (default = 15) -- sets the incremental step for each list item (all times use this for rounding to the nearest increment)
    • html-ready (default = .f.) -- return HTML select list (.t.) or crlf-delimited list (.f.)


    If you have any suggestions for improvements, please let me know.

    get_hour_picker()
    Code:
    'Date Created: 28-Nov-2012 09:02:13 AM
    'Last Updated: 28-Nov-2012 10:38:45 AM
    'Created By  : spilon
    'Updated By  : spilon
    FUNCTION get_hour_picker AS C (min_value = 0, max_value = 10, minutes_apart = 15, html_ready = .f.)
    	dim hourList as c
    	dim hour_increment as n = minutes_apart / 60
    	
    	for i = min_value to max_value step hour_increment
    		hourList = hourList + ut(str(i,10,2)) + crlf()
    	next i
    	
    	get_hour_picker = iif(html_ready, a5_html_list_populate(hourList), hourList)
    END FUNCTION
    get_time_picker()
    Code:
    'Date Created: 28-Nov-2012 08:51:12 AM
    'Last Updated: 28-Nov-2012 08:51:12 AM
    'Created By  : spilon
    'Updated By  : spilon
    FUNCTION Get_time_picker AS C (min_hour = "00:00:00", max_hour = "23:45:00", am_pm = 12, minutes_apart = 15, html_ready = .f.)
    	dim hour_list as c
    	dim min_value as n
    	dim max_value as n
    	dim select_value as c
    	dim hour_value as c
    	dim minute_value as c
    	dim mod_denominator as n
    	dim hour_increment as n = minutes_apart * 60
    	dim rounding_fraction as n = hour_increment / 2
    	
    	if min_hour = "" then
    		min_hour = "00:00:00"
    	end if
    	
    	if max_hour = "" then
    		max_hour = "23:45:00"
    	end if
    	
    	min_value = int((toseconds(min_hour) + rounding_fraction) / hour_increment)
    	max_value = int((toseconds(max_hour) + rounding_fraction) / hour_increment)
    	
    	mod_denominator = 3600 / hour_increment
    	
    	for i = min_value to max_value
    		minute_value = ":" + padl(ut(str((mod(i,mod_denominator) * (hour_increment / 60)))),2,"0")
    		select_value = padl(ut(str(int(i/mod_denominator),10,0)),2,"0") + minute_value
    		hour_value = select_value
    		if am_pm = 12 then
    			dim midnight_hour as n = (3600 - hour_increment) / hour_increment
    			dim before_noon as n = (3600 / hour_increment * 12) - 1
    			dim at_noon as n = (3600 / hour_increment * 13) - 1
    			
    			if i <= midnight_hour then  
    				hour_value = "12" + minute_value + " am"
    			else if i <= before_noon
    				hour_value = padl(ut(str(int(i/mod_denominator),10,0)),2,"0") + minute_value + " am"
    			else if i <= at_noon
    				hour_value = padl(ut(str(int(i/mod_denominator),10,0)),2,"0") + minute_value + " pm"
    			else 'after_noon
    				hour_value = padl(ut(str(int(i/mod_denominator) - 12,10,0)),2,"0") + minute_value + " pm"
    			end if				
    		end if
    		hour_list = hour_list + hour_value + "|" + select_value + ":00" + crlf()
    	next i
    	
    	if html_ready then
    		hour_list = *for_each(foo,"<option value=\"" + word(foo,2,"|") + "\">" + word(foo,1,"|") + "</option>",hour_list)
    	end if		
    	
    	Get_time_picker = hour_list
    END FUNCTION
    Attached Files
    Last edited by StephenP; 11-28-2012, 03:42 PM. Reason: Added HTML/Non-HTML pararmeters
    Stephen Pilon
    Associate Librarian
    Christendom College

  • #2
    Re: Hour Pickers for Select Lists

    In order to use this in a grid (for example), just add this code to the OnGridInitialize event in the Server-side Events:

    Code:
    e.rtc.time_dropdown = get_time_picker()
    Then for the dropdown field, under DropDownBox Properties, set the choices to a variable, and enter time_dropdown.
    Stephen Pilon
    Associate Librarian
    Christendom College

    Comment


    • #3
      Re: Hour Pickers for Select Lists

      Stephen,

      Would that be the same for a Dialog?
      Regards
      Keith Hubert
      Alpha Guild Member
      London.
      KHDB Management Systems
      Skype = keith.hubert


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

      Comment


      • #4
        Re: Hour Pickers for Select Lists

        Keith,

        I haven't used dialogs much yet, but I'll check it out.

        ... checking ...

        Well, it seems to work the same way in a dialog.
        Last edited by StephenP; 11-28-2012, 07:38 PM. Reason: testing the process for dialogs
        Stephen Pilon
        Associate Librarian
        Christendom College

        Comment

        Working...
        X