ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Display Time HH:MM AM/PM format

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

  • Display Time HH:MM AM/PM format

    Hi,

    We have a requirement where the user has to enter the time in HH:MM AM/PM format and once the user enters HH the cursor automatically should be pointed to MM i.e. ":" should be in protected mode.

    I have tried with editcode and editmast but was not able to achieve this.

    Could someone please let me know how to achieve the same?

    The screen looks as below:

    Position to: Date = 0/00/00 Time = 00:00 AM (AM/PM)

    Thanks in advance.

    Regards,
    Rahul

  • #2
    Re: Display Time HH:MM AM/PM format

    The fast and easy way is to have them as 2 seperate fields.

    Comment


    • #3
      Re: Display Time HH:MM AM/PM format

      Hi,

      Is there no other way since I was able to mask the date field as 00/00/00 and when the user was entering the date the cursor would move from DD to MM to YY and keeping the "/" as protected.

      Thanks
      Ravindra

      Comment


      • #4
        Re: Display Time HH:MM AM/PM format

        There is a way to do this, but it takes two separate record formats in your display file. The first record format has two fields, one for the hours and one for the minutes. They are display type "B" (both input & output). The other record format has an output-only field that contains the whole time. It is properly formatted with an edit word to display the colon in the middle. This record format has the OVERLAY keyword specified.

        In your RPG, you need to have a data structure that maps the 4-digit field to the two 2-digit fields. First, WRITE the first record format. Then write the overlay format. then read the first format. The input enabled fields will be overlain by the output-only field, But will still be able to accept input.

        It's late, so I'm not sure that makes sense. Let me know if you have any questions.
        "Time passes, but sometimes it beats the <crap> out of you as it goes."

        Comment


        • #5
          Re: Display Time HH:MM AM/PM format

          Hi,

          The suggestion to make two record formats solved 90% of my problem but even after I am doing an OVERLAY ':' part is not coming.

          Please find attached below the code snippet I have created for both DDS and RPGLE.
          Attached Files

          Comment


          • #6
            Re: Display Time HH:MM AM/PM format

            Dude, From my learning I think EDTMASK shud work, but as u said it had some probs with it even after trying it, wud like to say Use the most simple way, two different fields for HH and MM. and hardcode ':' in the display file. in between the fields.
            <HH> : <MM> <field> -- dentoes field
            A failure teaches you more than what a success does.

            Comment


            • #7
              Re: Display Time HH:MM AM/PM format

              Replace EXFMT F01 with READ F01.

              EXFMT is a combination of a write and a read, so you are essentially writing F01, writing F02, re-writing F01, then reading F01. So your writing of F02 is being ignored, basically.
              "Time passes, but sometimes it beats the <crap> out of you as it goes."

              Comment


              • #8
                Re: Display Time HH:MM AM/PM format

                Hi,

                When I am trying to READ then it is bombing saying that a record format should be written before it has to be read.

                The sequence I have given was as follows:

                WRITE F01
                WRITE F02
                READ F01

                Thanks for your help.

                Regards,
                Ravindra

                Comment


                • #9
                  Re: Display Time HH:MM AM/PM format

                  Here's code that illustrates what I was attempting to explain:

                  Code:
                  ***********************************************************************                             
                  *                               Readme                                *                             
                  ***********************************************************************                             
                  *        Midrange Computing Programs Associated With Article          *                             
                  *                                                                     *                             
                  *                   Published in the 08/94 Issue                      *                             
                  ***********************************************************************                             
                  *                  Transfer to AS/400 Instructions                    *                             
                  ***********************************************************************                             
                                                                                                                      
                  This data file contains the source members for the Midrange Computing                               
                  article you requested. In order to use these programs, you should have                              
                  the corresponding text from the magazine. Once this file is on your                                 
                  AS/400, the following steps need to be performed to get each source                                 
                  member to a state from which you can compile them.                                                  
                                                                                                                      
                  1) Copy this data file to a source physical file as a single member                                 
                     using the CPYF command being sure to use the FMTOPT value of *CVTSRC                             
                     and the SRCOPT values of *SEQNBR and *DATE. Here is an example of a                              
                     CPYF command that would work for downloaded file B088905:                                        
                                                                                                                      
                     CPYF FROMFILE(B088905) TOFILE(your library/your source file) +                                   
                            MBROPT(*ADD) FMTOPT(*CVTSRC) SRCOPT(*SEQNBR *DATE)                                        
                                                                                                                      
                  2) Read the section below labeled "Members in File" to determine the                                
                     members and their type that will have to be created by SEU. You will                             
                     create each member in the list and include the corresponding section                             
                     of this file that contains the member. Determining the beginning and                             
                     end of a member is done by searching for the beginning statements:                               
                                                                                                                      
                  ***********************************************************************                             
                  * Begin member - XXXXXXXXXX, Type - XXXXXXXXXX                        *                             
                  ***********************************************************************                             
                                                                                                                      
                     and ending statements:                                                                           
                                                                                                                      
                  ***********************************************************************                             
                  * End member - XXXXXXXXXX                                             *                             
                  ***********************************************************************                             
                                                                                                                      
                     Include all statements between these two statements in your                                      
                     created member.                                                                                  
                                                                                                                      
                  3) Compile each member. Use PDM or the appropriate CRTxxxxxxx command.                              
                  4) Delete the data file originally downloaded and the source member                                 
                     created in step one.                                                                             
                                                                                                                      
                  ************************ IMPORTANT NOTICE *****************************                             
                                                                                                                      
                  The programs you have downloaded were originally published in a                                     
                  previous issue of Midrange Computing.                                                               
                                                                                                                      
                  We do not recommend using any programs without the text from the                                    
                  original article. Installation and use of these programs without the                                
                  associated text is done so entirely at your own risk.                                               
                                                                                                                      
                  Back issues of Midrange Computing are available in hard copy or soft                                
                  copy (via the Mentor library). The Mentor product contains all back                                 
                  issues, ready for your online search, reading and copying. You can                                  
                  order back issues or the Mentor library by calling 1-800-477-5665.                                  
                  Mentor will contain articles up through the issue published the month                               
                  prior to your order.                                                                                
                  ***********************************************************************                             
                  *                           --- Members ---                           *                             
                  * Source Member Name  Source Member Type                              *                             
                  ***********************************************************************                             
                  * XMS003DF            DSPF                                            *                             
                  * XMS003RG            RPG                                             *                             
                  ***********************************************************************                             
                  ***********************************************************************                             
                  * Begin Member - XMS003DF  , Type - DSPF                              *                             
                  ***********************************************************************                             
                       A*===============================================================                              
                       A* To compile:                                                                                 
                       A*                                                                                             
                       A*      CRTDSPF    FILE(XXX/XMS003DF) SRCFILE(XXX/QDDSSRC)                                     
                       A*                                                                                             
                       A*===============================================================                              
                       A*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7                              
                       A                                      DSPSIZ(24 80 *DS3)                                      
                       A                                      CA03(03)                                                
                       A          R DSP01                                                                             
                       A            MM             2Y 0B  4 10                                                        
                       A            DD             2Y 0B  4 13                                                        
                       A            YY             2Y 0B  4 16                                                        
                       A          R DSP02                                                                             
                       A                                      CLRL(*NO)                                               
                       A            MMDDYY         6Y 0O  4 10EDTCDE(Y)                                               
                       A                                      DSPATR(UL)                                              
                  ***********************************************************************                             
                  * End Member - XMS003DF                                               *                             
                  ***********************************************************************                             
                  ***********************************************************************                             
                  * Begin Member - XMS003RG  , Type - RPG                               *                             
                  ***********************************************************************                             
                        *===============================================================                              
                        * To compile:                                                                                 
                        *                                                                                             
                        *      CRTRPGPGM  PGM(XXX/XMS003RG) SRCFILE(XXX/QRPGSRC)                                      
                        *                                                                                             
                        *===============================================================                              
                        *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7                              
                       FXMS003DFCF  E                    WORKSTN                                                      
                       I           IDS                                                                                
                       I                                        1   60MMDDYY                                          
                       I                                        1   20MM                                              
                       I                                        3   40DD                                              
                       I                                        5   60YY                                              
                       C           *INKC     DOUEQ*ON                                                                 
                       C                     WRITEDSP01                                                               
                       C                     WRITEDSP02                                                               
                       C                     READ DSP01                    99                                         
                       C                     ENDDO                                                                    
                       C                     MOVE *ON       *INLR                                                     
                  ***********************************************************************                             
                  * End Member - XMS003RG                                               *                             
                  ***********************************************************************
                  "Time passes, but sometimes it beats the <crap> out of you as it goes."

                  Comment

                  Working...
                  X