Announcement

Collapse
No announcement yet.

Checking a particular dbf field based on a variable value

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

    Checking a particular dbf field based on a variable value



    Hello,

    I have a database which includes fields for months:

    ONGOING.d.JAN
    ONGOING.d.FEB
    ONGOING.d.MAR
    etc.

    This dbf is a given.... so the months-as-fields format is my starting point.

    If I use ...

    <MvIF EXPR="{ server_current_month EQ 3 AND ONGOING.d.MAR EQ 1 }">

    ... I can check if the server_current_month (which is either the actual
    current month as a number or a target month specified as a number elsewhere
    in the script) equals 3 and, if so, if the d.MAR field is EQ to 1. If both
    conditions are met, something is displayed.

    Great... but what I want to do is determine this dynamically:

    Check the server_current_month
    If it is 1, see if ONGOING.d.JAN is EQ 1
    but if it is 2, see if ONGOING.d.FEB is EQ 1
    but if it is 3, see if ONGOING.d.MAR is EQ 1
    etc.

    If the appropriate server_current_month condition is met, display the thing.

    Other than a whopping bunch of ELSEs, I am not sure how to do this..... and
    12 successive </MvIFs> just make me sure there is a better conceptual approach.

    All guidance welcome!

    Thanks
    rg







    Ralph Gauer
    [email protected]
    www.ralphgauer.com
    505-534-4184
    Silver City, New Mexico




    #2
    Checking a particular dbf field based on a variable value



    There are a number of possibilities. For example you define an array in this
    way:

    <MvASSIGN NAME="g.month"
    VALUE="{miva_array_deserialize('jan,feb,mar,apr,ma y,jun,jul,aug,sep,oct,nov,
    dec')}">

    ... and then you can check if the field of the respective current month is
    turne on in this way:

    <MvIF EXPR="{miva_variable_value('ONGOING.d.' $
    g.month[g.server_current_month])}">


    Ivo
    http://mivo.truxoft.com



    -----Original Message-----
    From: Ralph Gauer


    Hello,

    I have a database which includes fields for months:

    ONGOING.d.JAN
    ONGOING.d.FEB
    ONGOING.d.MAR
    etc.

    This dbf is a given.... so the months-as-fields format is my starting point.

    If I use ...

    <MvIF EXPR="{ server_current_month EQ 3 AND ONGOING.d.MAR EQ 1 }">

    ... I can check if the server_current_month (which is either the actual
    current month as a number or a target month specified as a number elsewhere
    in the script) equals 3 and, if so, if the d.MAR field is EQ to 1. If both
    conditions are met, something is displayed.

    Great... but what I want to do is determine this dynamically:

    Check the server_current_month
    If it is 1, see if ONGOING.d.JAN is EQ 1
    but if it is 2, see if ONGOING.d.FEB is EQ 1
    but if it is 3, see if ONGOING.d.MAR is EQ 1
    etc.

    If the appropriate server_current_month condition is met, display the thing.

    Other than a whopping bunch of ELSEs, I am not sure how to do this..... and
    12 successive </MvIFs> just make me sure there is a better conceptual
    approach.

    All guidance welcome!

    Thanks
    rg







    Ralph Gauer
    [email protected]
    www.ralphgauer.com
    505-534-4184
    Silver City, New Mexico



    Comment


      #3
      Checking a particular dbf field based on a variable value



      Yet, another and simpler possibility is using the system variable s.stm_mon
      - in that case you do not need any array. You just check it in this way:

      <MvIF EXPR="{miva_variable_value('ONGOING.d.' $ s.stm_mon)}">

      Of course, I assume that you are looking for the current month. Otherwise,
      you would still need the previous code, or other way to convert the numeric
      value into the string.

      Ivo
      http://mivo.truxoft.com


      -----Original Message-----
      From: [email protected] [mailto:[email protected]] On Behalf
      Of Ralph Gauer
      Sent: Tuesday, February 08, 2005 8:12 PM
      To: [email protected]
      Subject: [meu] Checking a particular dbf field based on a variable value

      Hello,

      I have a database which includes fields for months:

      ONGOING.d.JAN
      ONGOING.d.FEB
      ONGOING.d.MAR
      etc.

      This dbf is a given.... so the months-as-fields format is my starting point.

      If I use ...

      <MvIF EXPR="{ server_current_month EQ 3 AND ONGOING.d.MAR EQ 1 }">

      ... I can check if the server_current_month (which is either the actual
      current month as a number or a target month specified as a number elsewhere
      in the script) equals 3 and, if so, if the d.MAR field is EQ to 1. If both
      conditions are met, something is displayed.

      Great... but what I want to do is determine this dynamically:

      Check the server_current_month
      If it is 1, see if ONGOING.d.JAN is EQ 1
      but if it is 2, see if ONGOING.d.FEB is EQ 1
      but if it is 3, see if ONGOING.d.MAR is EQ 1
      etc.

      If the appropriate server_current_month condition is met, display the thing.

      Other than a whopping bunch of ELSEs, I am not sure how to do this..... and
      12 successive </MvIFs> just make me sure there is a better conceptual
      approach.

      All guidance welcome!

      Thanks
      rg







      Ralph Gauer
      [email protected]
      www.ralphgauer.com
      505-534-4184
      Silver City, New Mexico



      Comment

      Working...
      X