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



    In Miva Script you can create an array either by assigning each member
    separately, or by deserializing the compound form. That can be simplified
    into a comma delimited string. For briefness I practically always use the
    second method.

    As for the MvIF condition - first you compose the variable name from the
    constant prefix 'ONGOING.d.' and the variable month abbreviation pulled from
    the array through a numeric index. You then pull the value of the composed
    variable name with the miva_variable_value function.

    Ivo Truxa

    | http://miva.truxoft.com
    | Advanced Miva Merchant modules



    -----Original Message-----
    From: Ralph Gauer [mailto:[email protected]]


    Ivo,

    Wow... fabulous, and a one-liner, on top of that....

    If I can further demonstrate my stupidity, what you are doing is:

    * Creating an array of my month abbreviations....
    * Using the deserialize function to take the number of the
    current_server_month to then "count in" to the appropriate abbreviation in
    the array
    * And then concatenating that with the field name prefix "ongoing.d".....
    * This can be evaluated in an MvIF with the miva_variable_value
    function -- because that function returns the value of the "built up"
    concatenated variable

    Yes?

    I need to play with the arrays more..... wonderful stuff....

    Thanks
    rg








    At 08:36 PM 2/8/2005 +0100, you wrote:
    >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,m ay,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
    >
    >
    >
Working...
X