Announcement

Collapse
No announcement yet.

Automatically change label in a specific time

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

  • Automatically change label in a specific time

    Is there a way to change the text at a specific time
    For example,the label displays a text from 8 to 9 am and shows another text at 9 to 10 am
    Forgive me for my weak English
    Thanks


  • #2
    Hi eh.zamani

    Put this Code in the way you want it to be executed like ( On Show or On timer ).

    Code:
    sTime = tonumber(System.GetTime(TIME_FMT_HOUR));
    
    if (sTime >=8 and sTime <= 9) then
     
    Label.SetText("Label1","your text between 8 and 9")
    
    elseif (sTime >= 9 and sTime <= 10) then
    
    Label.SetText("Label1","your text between 9 and 10")
    
    end

    Comment


    • #3
      Originally posted by sameer valva View Post
      Hi eh.zamani

      Put this Code in the way you want it to be executed like ( On Show or On timer ).

      Code:
      sTime = tonumber(System.GetTime(TIME_FMT_HOUR));
      
      if (sTime >=8 and sTime <= 9) then
      
      Label.SetText("Label1","your text between 8 and 9")
      
      elseif (sTime >= 9 and sTime <= 10) then
      
      Label.SetText("Label1","your text between 9 and 10")
      
      end
      Thank you
      Can I do this every day?
      I mean for example, on Saturdays a specific text will be displayed on specific hours and on Sunday, and another text will be displayed at specific times

      Comment


      • #4
        First you need to read the manual of AMS where you can find all of these codes easily and learn the basics of the program.
        Second you should try to do it yourself and when you fail you can ask the question with your code and guys here are very generous for giving you solutions and teach you why your code didn't work and so you can learn.
        This is the way i do my work, i try to figure it myself with the help of the manual ,or search for similar questions in the forum,and when i fail i post my problem with my Code to learn what is wrong with my code.

        This is the Code that you need :
        Code:
        sTime = tonumber(System.GetTime(TIME_FMT_HOUR));
        sDay = tonumber(System.GetDate(DATE_FMT_DAYOFWEEK));
        
        if (sDay == 1) then -- number of the day in the week. the first day is sunday
        
            if (sTime >=8 and sTime <= 9) then
            
            Label.SetText("Label1","your text between 8 and 9")
            
                elseif (sTime >= 9 and sTime <= 10) then
                
                Label.SetText("Label1","your text between 9 and 10")
            
            end
            
        end

        Comment


        • #5
          Originally posted by sameer valva View Post
          First you need to read the manual of AMS where you can find all of these codes easily and learn the basics of the program.
          Second you should try to do it yourself and when you fail you can ask the question with your code and guys here are very generous for giving you solutions and teach you why your code didn't work and so you can learn.
          This is the way i do my work, i try to figure it myself with the help of the manual ,or search for similar questions in the forum,and when i fail i post my problem with my Code to learn what is wrong with my code.

          This is the Code that you need :
          Code:
          sTime = tonumber(System.GetTime(TIME_FMT_HOUR));
          sDay = tonumber(System.GetDate(DATE_FMT_DAYOFWEEK));
          
          if (sDay == 1) then -- number of the day in the week. the first day is sunday
          
          if (sTime >=8 and sTime <= 9) then
          
          Label.SetText("Label1","your text between 8 and 9")
          
          elseif (sTime >= 9 and sTime <= 10) then
          
          Label.SetText("Label1","your text between 9 and 10")
          
          end
          
          end
          I am a teacher and I spend all my time to studying on my work .I'm building a project for classroom. I do not have time to learn this program accurately.
          In my country, in such cases, they will help each other without contributing or obligation to each other.
          Thank u but you also do not care if you do not want to help.better than obligation

          Comment


          • #6
            No one here is saying that we will not help, just saying you can get your result faster if you read the manual than asking since your questions are basics.
            Any way we are here to help each other and learn from the experts.
            If you needed more help just ask.
            Its better to explain your project so guys here can give the best way to achieve your goal.

            Comment


            • #7
              There's a plethora of forum examples dealing with Date/Time retrieval far too numerous to list. A quick forum search will turn up a bunch of stuff, together with quite a few plugins and DLLs developed by members over the years, that deal with this topic.

              Sameer has pointed out the built-in AMS functions useful for your request. And these will certainly do the job. It's up to you to learn how to apply them. Personally speaking, I'd use pua Lua for something like this, instead. For which you can look into the following functions:
              Code:
              os.time()
              os.clock()
              os.difftime()
              os.date()
              
              [B]eg.[/B]
              sReturn = os.date(); -- [I]returns date in xx/xx/xx format + time in 00:00:00 format[/I]
              sReturn = os.date("%H:%M:%S"); [I]-- returns time in 00:00:00 format[/I]
              Details required for understanding the aforementioned functions can be found via the documentation at:

              http://lua-users.org/wiki/DateAndTime
              http://www.lua.org/manual/5.3/manual.html#pdf-os.time
              http://www.lua.org/manual/5.3/manual.html#pdf-os.date
              http://www.lua.org/manual/5.3/manual...df-os.difftime
              https://www.lua.org/pil/22.1.html

              Again, it's up to you to put in the time required to understand how to apply these functions. As Sameer has already alluded, further help with specific aspects of your code will be forthcoming, once you understand enough about the basics, to be able to create and upload an APZ example which demonstrates you're on track. But no-one here's going to build it for you.

              Also, very useful for this kind of thing, look into the Lua Date & Time Library (zipped and attached below).
              .
              ..................................


              Originally posted by eh.zamani View Post
              I'm building a project for classroom. I do not have time to learn this program accurately.
              How on earth to you expect to successfully create and maintain a project, if you can't make time to study the basic precepts required for understanding the code? Are we to assume that you expect someone to build it for you??? Sameer's given you pointers for one approach. And above are pointers to get you started using another approach. But it's up to you to put in whatever time's required to understand the concepts and to begin bringing something to fruition.


              ... Thank u but you also do not care if you do not want to help.better than obligation
              Are you kidding me! Sameer provided you with a code sample and offered some sage advice about how to best proceed. And your response is to throw it back in his face? On your very first thread, no less? Very uncool. You'd do well to demonstrate some grace when seeking help. Or don't ask in the first place.


              In my country, in such cases, they will help each other without contributing or obligation to each other.
              Well bully for you, man. Are they as equally ungracious as you? And just an FYI, most here in this community will freely give help, donating both time and expertise without obligation. We try however, not to make a point of virtue-signalling how wonderful we are.

              And yes, we do ask that you make an effort to help yourself, first. But if looking for someone to do your 'homework' for you, then you're in the wrong place.


              I am a teacher ...
              Then act like one.
              Attached Files

              Comment


              • #8
                My Man BioHazard

                Comment


                • #9
                  BioHazard
                  Thank you so much for help i will never forget this
                  But this is not my homework. My homework is learning science for better teaching in class.Science related to the classroom such as math, physics and chemistry
                  My project was almost complete and I did not get any help from anyone except that you helped. Of course, if I did not add this code to the project, there would be no problem either.
                  I will definitely try to learn the software well, but the help you gave me is helping you to the human or fellow, not doing the homework.
                  If the parents of my students in need my help about anything related to the classroom, I will help them without any beholden or obligated, and I will not tell them to go and learn yourself.
                  I'm listening to you, although i do not need to learn this software, I will learn it.and please you also listen to me, which helping to a fellow or humanism is not doing his homework
                  Be in God's protection honorable professors

                  Comment

                  Working...
                  X