Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2004
    Posts
    3

    Problem with If's: visible labels and time

    Dear Users,

    I am very new to MediaPlay, having been with MS Access for quite awhile and been very disappointed with my attempts to distribute Access databases. Anyway, I am trying to convert a project I had in Access to MediaPlay. But I am having what seems to me a ridiculous problem:

    Page.StartTimer(1000)

    nWeekday = System.GetDate(DATE_FMT_DAYOFWEEK);

    nMonth = System.GetDate(4);

    If (nMonth == 1) Then (strMonth = "January") AND (Label.SetText("Label1", strMonth)) End;


    If (System.GetTime(1)>.5) Then Label.SetVisible (lblGoodMorning, false) End


    I keep getting an error when compiling, telling me to put '=' near different places, and after I do, what I want to happen does not happen.

    What I am trying to do with the two If statements is this:

    (1) create nested If statements in order to put as text in a label the current month and day of the week (as part of the entire current date on the user's computer: day of week, name of Month, day, year[4 digits]); and,
    (2) to allow only one of three labels to be visible depending on the time of day. That is, if it is before noon and after midnight, then display the label which says: "Good morning," if after noon but before 5 PM, allow the label which states: "Good afternoon," to be visible, and then after 5 PM and before midnight, to have "Good Evening," appear.

    I do have a working clock on my opening page already.

    Any suggestions would be greatly appreciated.

    Very truly,
    edsager

  2. #2
    Join Date
    Aug 2004
    Location
    Gent, Belgium
    Posts
    74
    Quote Originally Posted by edsager
    Dear Users,

    I am very new to MediaPlay, having been with MS Access for quite awhile and been very disappointed with my attempts to distribute Access databases. Anyway, I am trying to convert a project I had in Access to MediaPlay. But I am having what seems to me a ridiculous problem:

    Page.StartTimer(1000)

    nWeekday = System.GetDate(DATE_FMT_DAYOFWEEK);

    nMonth = System.GetDate(4);

    If (nMonth == 1) Then (strMonth = "January") AND (Label.SetText("Label1", strMonth)) End;


    If (System.GetTime(1)>.5) Then Label.SetVisible (lblGoodMorning, false) End


    I keep getting an error when compiling, telling me to put '=' near different places, and after I do, what I want to happen does not happen.

    What I am trying to do with the two If statements is this:

    (1) create nested If statements in order to put as text in a label the current month and day of the week (as part of the entire current date on the user's computer: day of week, name of Month, day, year[4 digits]); and,
    (2) to allow only one of three labels to be visible depending on the time of day. That is, if it is before noon and after midnight, then display the label which says: "Good morning," if after noon but before 5 PM, allow the label which states: "Good afternoon," to be visible, and then after 5 PM and before midnight, to have "Good Evening," appear.

    I do have a working clock on my opening page already.

    Any suggestions would be greatly appreciated.

    Very truly,
    edsager
    What about
    If (nMonth == 1) AND (strMonth = "January") Then (Label.SetText("Label1", strMonth)) End;


    Just an thought..

    Georges

  3. #3
    Join Date
    Aug 2003
    Posts
    2,468
    Re the second part - you could do this with -

    result = System.GetTime(TIME_FMT_AMPM);
    if (String.Right(result, 2)=="PM") then
    greeting="Good Afternoon"
    else
    greeting="Good Morning"
    end
    if (String.Left(result, 2)> "5") and (String.Right(result, 2)=="PM")then
    greeting="Good Evening"
    end
    Label.SetText("Label1", greeting);

    As for part 1 - I've looked at this myself in the past but put it on the back burner for when I know more about AMS. It would be easy in Access but I think in AMS you might need to use a table to do some looking up. Greater minds will no doubt come up with an answer

  4. #4
    Join Date
    Jun 2001
    Location
    U.S.A - California
    Posts
    2,134
    Tigg helped me out with this one...hope it helps!


    result = System.GetTime(TIME_FMT_HOUR);

    result=String.ToNumber(result);

    if (result <= 7) then

    Paragraph.SetText("time of day Paragraph", "Good Early Morning");

    elseif (result <=9) then

    Paragraph.SetText("time of day Paragraph", "Good Morning");

    elseif (result <= 12) then

    Paragraph.SetText("time of day Paragraph", "Good Late Morning");

    elseif (result <= 15) then

    Paragraph.SetText("time of day Paragraph", "Good Early Afternoon");

    elseif (result <= 16) then

    Paragraph.SetText("time of day Paragraph", "Good Afternoon");

    elseif (result <= 21) then

    Paragraph.SetText("time of day Paragraph", "Good Evening");

    elseif (result <=24) then

    Paragraph.SetText("time of day Paragraph", "Good Late Evening");

    end

  5. #5
    Join Date
    Aug 2003
    Posts
    2,468
    This fulfils both requirements I think.
    An excercise for me to start to get my head round tables at last -

    -- Greeting.
    result = System.GetTime(TIME_FMT_AMPM);
    if (String.Right(result, 2)=="PM") then
    greeting="Good Afternoon"
    else
    greeting="Good Morning"
    end
    if (String.Left(result, 2)> "5") and (String.Right(result, 2)=="PM")then
    greeting="Good Evening"
    end
    Label.SetText("Label1", greeting);



    -- Date as text.
    tbl_months={"January","February","March","April"," May","June","July","August","September","October", "November","December"}
    tbl_days={"Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"}
    tbl_day_numbers={"First","Second","Third","Fourth" ,"Fifth","Sixth","Seventh","Eigth","Ninth","Tenth" ,"Eleventh","Twelfth","Thirteenth","Fourteenth","F ifteenth","Sixteenth","Seventeenth","Eighteenth"," Nineteenth","Twentieth","Twenty first","Twenty third","Twenty fourth","Twenty fifth","Twenty sixth","Twenty seventh","Twenty eighth","Twenty ninth","Thirtieth","Thirty first"}
    get_month = System.GetDate(DATE_FMT_MONTH);
    get_day_of_week = System.GetDate(DATE_FMT_DAYOFWEEK);
    get_day = System.GetDate(DATE_FMT_DAY);
    get_year = System.GetDate(DATE_FMT_YEAR);
    m = String.ToNumber(get_month);
    d = String.ToNumber(get_day_of_week);
    dd = String.ToNumber(get_day);
    month = tbl_months[m]
    day = tbl_days [d]
    days = tbl_day_numbers[dd]
    display_date = "Today is "..day.." the "..days.." of "..month.." "..get_year
    Label.SetText("Label2", display_date);

  6. #6
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Cool! Yes, this is a great one for getting familiar with tables.

    Corey Milner
    Creative Director, Indigo Rose Software

  7. #7
    Join Date
    Jun 2004
    Posts
    3

    Grin

    I agree with Corey: very cool.

    Thank you all. This will definitely provide for an opportunity to become familiar with AMS5.0 tables.

    Thanks,
    edsager

Posting Permissions

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