Announcement

Collapse
No announcement yet.

ARRAYS : Retrieving and reassigning data II

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

    ARRAYS : Retrieving and reassigning data II



    From: Alex Ricks <[email protected]>

    Huhmmn, How to explain this?

    I need some help with these "psuedo" arrays. I can create a numbered array based on
    dbase three record numbers, but I have trouble retrieving the data from these arrays,
    assigning them to the dbase record fields and updating the record :

    I am currently working on a project where data stored in a dbase III table is opened and
    queried with mvfind. The results are display in a form and table, one record per row
    by way of a mvwhile loop. Three of the fields for each record can be changed by the
    user and updated when the form is submitted.

    The default data for the form text boxes is the value retrieved from the matching field
    of the dbase III table. After the user changes the data in the text boxes and submits the form, the
    data is passed to the program in numbered arrays cooresponding to it's dbase record
    number (alias_db.d.recno). This works fine until I try to retrieve the data ie.:

    Here is the table :

    recno type name size qty delete id
    -------- -------- -------- -------- ------- -------- --------
    1 border floral yard 3 n O1BE8CD406
    2 print pastel memo 2 n O1BE8CD406
    3 border stripes yard 4 y O1BE8CD406

    Only columns 4,5,6 (size, qty, delete) can be edited by the user with form fields .
    After changing the data and submitting the form, the command line array looks like this :

    documenturl.mv?size_3=yard&size_2=memo&size_1=yard &qty_3=4&qty_2=2&qty_1=3&
    delete_3=y&delete_2=n&delete_1=n&session_id=O1BE8C D406B78B4&screen=update

    The variable "screen" directs the program to a function called "update". The
    "session_id" number is used for tracking purposes and to retrieve the dbase III records
    with mvfind. I want to open the database, mvfind the records matching that id #, and
    update the record with the "array" variables that correspond to the database record
    number. Then I loop the process with an mvwhile until all of the records have been
    updated. Here is my code. I replace the '>' with '*' so this message board doesn't cut
    out my code :

    * MVFUNCTION NAME="update" *
    * MVOPEN NAME="orderform_db" DATABASE="orderform.dbf" *
    * MVMAKEINDEX NAME="orderform_db" INDEXFILE="orderform_session_id.mvx" *
    EXPR="{orderform_db.d.session_id}" FLAGS="descending" *
    * MVFIND NAME="orderform_db" VALUE="{&[g.session_id]}" *
    * MVWHILE EXPR="{NOT orderform_db.d.eof AND orderform_db.d.session_id EQ g.session_id}" *
    * MVASSIGN NAME="orderform_db.d.size" VALUE="size_&[orderform_db.d.recno]" *
    * MVASSIGN NAME="orderform_db.d.qty" VALUE="qty_&[orderform_db.d.recno]" *
    * MVASSIGN NAME="orderform_db.d.deleted" VALUE="delete_&[orderform_db.d.recno]" *
    * MVUPDATE *
    * MVSKIP *
    * /MVWHILE *
    * MVCLOSE NAME="orderform_db" *
    * /MVFUNCTION *

    My problem occurs with the three mvassigns you see. I am trying to assign the value
    from the arrays to the database fields by calling the array with it's name appended by the
    record number of the current open record (size_1, qty_1, delete_1 . . .etc). No matter
    how I change the syntax after (value=" "), it either doesn't work or gives me a syntax error.

    I know that the dbase III thing with Miva is new and advise is scarce, but if anyone can
    help me join these variables names to call the arrays, I'll give them the source code for
    the entire application. It will permit you to open and edit multiple database records from
    multiple tables at once instead of one record at a time like you see on most miva
    applications currently passed around on the web.

    Thanks,

    Alex Ricks
    mailto:[email protected]



    #2
    ARRAYS : Retrieving and reassigning data



    Hey Jefferey:

    My copy of the message looks like this:

    [snip]
    Then I loop the process with an mvwhile until all of the records have
    been
    updated. Here is my code. I replace the '>' with '*' so this
    message board doesn't cut
    out my code :

    * MVFUNCTION NAME="update" *
    * MVOPEN NAME="orderform_db" DATABASE="orderform.dbf" *
    * MVMAKEINDEX NAME="orderform_db" INDEXFILE="orderform_session_id.mvx"
    *
    EXPR="{orderform_db.d.session_id}" FLAGS="descending" *
    * MVFIND NAME="orderform_db" VALUE="{&[g.session_id]}" *
    * MVWHILE EXPR="{NOT orderform_db.d.eof AND orderform_db.d.session_id
    EQ g.session_id}" *
    * MVASSIGN NAME="orderform_db.d.size"
    VALUE="size_&[orderform_db.d.recno]" *
    * MVASSIGN NAME="orderform_db.d.qty"
    VALUE="qty_&[orderform_db.d.recno]" *
    * MVASSIGN NAME="orderform_db.d.deleted"
    VALUE="delete_&[orderform_db.d.recno]" *
    * MVUPDATE *
    * MVSKIP *
    * /MVWHILE *
    * MVCLOSE NAME="orderform_db" *
    * /MVFUNCTION *

    [snip]

    This is odd.

    Jack

    Jeff Huber wrote:
    >
    > At 11:26 AM 4/23/99 -0800, Miva Engine List Archive wrote:
    > <snip>
    > >Then I loop the process with an mvwhile until all of
    > >the records have been updated. Here is my code :
    > >
    > >
    > >
    > >My problem occurs with the three mvassigns you see.
    > <snip>
    >
    > I see no code in there, did you forget to paste it, or did
    > one of our email clients strip it out.
    >
    > Ciao!
    >
    > -Jefferey Robert Huber
    >


    Comment


      #3
      Re: ARRAYS : Retrieving and reassigning data II



      I'm having the same problem with pseudo arrays.
      See <A HREF ="http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979">http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979</A>

      I can aassign the values to the array but I can get access the value unless I hard code the indexes.

      I can create a string version of the variable and assign a value.
      <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }">
      <MvASSIGN NAME="{ l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">

      Where l.cat is in the format g.cattree_1_1

      I can output the value directly <MvEVAL EXPR="{g.cattree_1_1}">
      but when trying to use variable indexes I can't get the values back out.

      <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
      <MvEVAL EXPR="{miva_variable_value(l.cat)}">
      <MvEVAL EXPR="{&[l.cat]}">

      Did you ever figure this out?
      Ray


      Alex Ricks [email protected] Wrote:
      >
      >From: Alex Ricks <[email protected]>
      >
      >Huhmmn, How to explain this?
      >
      >I need some help with these "psuedo" arrays. I can create a numbered array based on
      >dbase three record numbers, but I have trouble retrieving the data from these arrays,
      >assigning them to the dbase record fields and updating the record :
      >
      >........
      >
      >My problem occurs with the three mvassigns you see. --
      From: Ray Yates <[email protected]>

      Comment


        #4
        Re: ARRAYS : Retrieving and reassigning data II



        <MvEVAL EXPR="{&[l.cat]}"> .. normally the compiler (and empresa) don't
        support macros anymore..

        For: <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
        you should use

        <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
        $ ':id') }">
        <MvEVAL EXPR="{l.cat}">

        Best regards,
        Claudiu

        -----Original Message-----
        From: [email protected] [mailto:[email protected]]On
        Behalf Of [email protected]
        Sent: vendredi 28 janvier 2005 09:02
        To: [email protected]
        Cc: [email protected]
        Subject: [meu] Re: ARRAYS : Retrieving and reassigning data II


        I'm having the same problem with pseudo arrays.
        See <A HREF ="http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979">http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979</A>

        I can aassign the values to the array but I can get access the value unless
        I hard code the indexes.

        I can create a string version of the variable and assign a value.
        <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }">
        <MvASSIGN NAME="{ l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">

        Where l.cat is in the format g.cattree_1_1

        I can output the value directly <MvEVAL EXPR="{g.cattree_1_1}">
        but when trying to use variable indexes I can't get the values back out.

        <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }"> <!--
        string "g.catree_1_1:id" -->
        <MvEVAL EXPR="{miva_variable_value(l.cat)}">
        <MvEVAL EXPR="{&[l.cat]}">

        Did you ever figure this out?
        Ray


        Alex Ricks [email protected] Wrote:
        >
        >From: Alex Ricks <[email protected]>
        >
        >Huhmmn, How to explain this?
        >
        >I need some help with these "psuedo" arrays. I can create a numbered array
        based on
        >dbase three record numbers, but I have trouble retrieving the data from
        these arrays,
        >assigning them to the dbase record fields and updating the record :
        >
        >........
        >
        >My problem occurs with the three mvassigns you see. --
        From: Ray Yates <[email protected]>

        Comment


          #5
          Re: ARRAYS : Retrieving and reassigning data II



          Thanks Claudiu,
          While completely logical it doesn't work either.

          <MvASSIGN NAME="l.newcat_string" VALUE="{ 'g.cattree_' $ l.newcat_var $
          ':id' }">
          <MvASSIGN NAME="l.newcat_id" VALUE="{ miva_variable_value('g.cattree_' $
          l.newcat_var $ ':id') }">
          <MvEVAL EXPR="{l.newcat_string $ ' = ' $ l.newcat_id}">


          Results in this output
          g.cattree_1_1:id =
          g.cattree_1_2:id =
          g.cattree_1_3:id =
          g.cattree_1_4:id =

          Any other sugestions?
          Is miva_variable_value() unable to handle structures?
          Ray

          Subject: RE: [meu] Re: ARRAYS : Retrieving and reassigning data II

          <MvEVAL EXPR="{&[l.cat]}"> .. normally the compiler (and empresa) don't
          support macros anymore..

          For: <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
          you should use

          <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
          $ ':id') }"> <MvEVAL EXPR="{l.cat}">

          Best regards,
          Claudiu


          Subject: [meu] Re: ARRAYS : Retrieving and reassigning data II


          I'm having the same problem with pseudo arrays.
          See <A HREF ="http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979">http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979</A>

          I can aassign the values to the array but I can get access the value unless
          I hard code the indexes.

          I can create a string version of the variable and assign a value.
          <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }"> <MvASSIGN NAME="{
          l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">

          Where l.cat is in the format g.cattree_1_1

          I can output the value directly <MvEVAL EXPR="{g.cattree_1_1}"> but when
          trying to use variable indexes I can't get the values back out.

          <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }"> <!--
          string "g.catree_1_1:id" -->
          <MvEVAL EXPR="{miva_variable_value(l.cat)}"> <!-- this outputs
          nothing -->
          <MvEVAL EXPR="{&[l.cat]}"> <!-- this causes a compiler syntax
          error -->

          Did you ever figure this out?
          Ray


          Alex Ricks [email protected] Wrote:
          >
          >From: Alex Ricks <[email protected]>
          >
          >Huhmmn, How to explain this?
          >
          >I need some help with these "psuedo" arrays. I can create a numbered
          >array
          based on
          >dbase three record numbers, but I have trouble retrieving the data from
          these arrays,
          >assigning them to the dbase record fields and updating the record :
          >
          >........
          >
          >My problem occurs with the three mvassigns you see. --
          From: Ray Yates <[email protected]>

          Comment


            #6
            RE: ARRAYS : Retrieving and reassigning data II



            I made a small test that work:

            <mvassign name="l.cat_var" value="test">
            <mvassign name="g.cattree_test:id" value="Super shoupa wabba doub!">

            <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
            $ ':id') }">
            <MvEVAL EXPR="{l.cat}">

            Now if you want to use arrays.. this could be better:

            <mvassign name="g.cattree" index="1" value="test1">
            <mvassign name="g.cattree" index="2" value="test2">
            <mvassign name="g.cattree" index="3" value="test3">

            <MvASSIGN NAME="l.newcat_id" VALUE="{ miva_variable_value('g.cattree[' $
            l.your_array_number $ ']:id') }">
            ANd that shoul output your values..

            Now tell me exactly what you want to do .. I can help more if I have the
            whole idea ..

            Best regards,
            Claudiu

            -----Original Message-----
            From: Ray Yates [mailto:[email protected]]
            Sent: vendredi 28 janvier 2005 09:40
            To: miva-users
            Subject: Re: ARRAYS : Retrieving and reassigning data II


            Thanks Claudiu,
            While completely logical it doesn't work either.

            <MvASSIGN NAME="l.newcat_string" VALUE="{ 'g.cattree_' $ l.newcat_var $
            ':id' }">
            <MvASSIGN NAME="l.newcat_id" VALUE="{ miva_variable_value('g.cattree_' $
            l.newcat_var $ ':id') }">
            <MvEVAL EXPR="{l.newcat_string $ ' = ' $ l.newcat_id}">


            Results in this output
            g.cattree_1_1:id =
            g.cattree_1_2:id =
            g.cattree_1_3:id =
            g.cattree_1_4:id =

            Any other sugestions?
            Is miva_variable_value() unable to handle structures?
            Ray

            Subject: RE: [meu] Re: ARRAYS : Retrieving and reassigning data II

            <MvEVAL EXPR="{&[l.cat]}"> .. normally the compiler (and empresa) don't
            support macros anymore..

            For: <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
            you should use

            <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
            $ ':id') }"> <MvEVAL EXPR="{l.cat}">

            Best regards,
            Claudiu


            Subject: [meu] Re: ARRAYS : Retrieving and reassigning data II


            I'm having the same problem with pseudo arrays.
            See <A HREF ="http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979">http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979</A>

            I can aassign the values to the array but I can get access the value unless
            I hard code the indexes.

            I can create a string version of the variable and assign a value.
            <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }"> <MvASSIGN NAME="{
            l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">

            Where l.cat is in the format g.cattree_1_1

            I can output the value directly <MvEVAL EXPR="{g.cattree_1_1}"> but when
            trying to use variable indexes I can't get the values back out.

            <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }"> <!--
            string "g.catree_1_1:id" -->
            <MvEVAL EXPR="{miva_variable_value(l.cat)}"> <!-- this outputs
            nothing -->
            <MvEVAL EXPR="{&[l.cat]}"> <!-- this causes a compiler syntax
            error -->

            Did you ever figure this out?
            Ray


            Alex Ricks [email protected] Wrote:
            >
            >From: Alex Ricks <[email protected]>
            >
            >Huhmmn, How to explain this?
            >
            >I need some help with these "psuedo" arrays. I can create a numbered
            >array
            based on
            >dbase three record numbers, but I have trouble retrieving the data from
            these arrays,
            >assigning them to the dbase record fields and updating the record :
            >
            >........
            >
            >My problem occurs with the three mvassigns you see. --
            From: Ray Yates <[email protected]>

            Comment


              #7
              RE: ARRAYS : Retrieving and reassigning data II



              I duplicated your results but only once...

              <mvassign name="l.cat_var" value="test">
              <mvassign name="g.cattree_test:id" value="Super shoupa wabba doub!">
              <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree' $ l.cat_var
              $ ':id') }">
              <MvEVAL EXPR="{l.cat}">

              I compiled, uploaded and it worked.

              Then I changed <mvassign name="l.cat_var" value="1_1">
              I compiled, uploaded and it return a blank screen.

              I changed it to
              <MIVA STANDARDOUTPUTLEVEL = "text,html,compresswhitespace">
              <html><head></head><body>

              <mvassign name="l.cat_var" value="test">
              <mvassign name="g.cattree_test:id" value="Super shoupa wabba doub!">
              <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree' $ l.cat_var
              $ ':id') }">
              <MvEVAL EXPR="{l.cat}">

              </body></html>

              I compiled, uploaded and it still return a blank.
              I just rebooted the server and I'm going to try again



              -----Original Message-----
              From: [email protected] [mailto:[email protected]] On Behalf
              Of Claudiu Bischoff
              Sent: Friday, January 28, 2005 3:53 AM
              To: Ray Yates; miva-users
              Subject: [meu] RE: ARRAYS : Retrieving and reassigning data II

              I made a small test that work:

              <mvassign name="l.cat_var" value="test"> <mvassign
              name="g.cattree_test:id" value="Super shoupa wabba doub!">

              <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
              $ ':id') }"> <MvEVAL EXPR="{l.cat}">

              Now if you want to use arrays.. this could be better:

              <mvassign name="g.cattree" index="1" value="test1"> <mvassign
              name="g.cattree" index="2" value="test2"> <mvassign name="g.cattree"
              index="3" value="test3">

              <MvASSIGN NAME="l.newcat_id" VALUE="{ miva_variable_value('g.cattree[' $
              l.your_array_number $ ']:id') }">
              ANd that shoul output your values..

              Now tell me exactly what you want to do .. I can help more if I have the
              whole idea ..

              Best regards,
              Claudiu

              -----Original Message-----
              From: Ray Yates [mailto:[email protected]]
              Sent: vendredi 28 janvier 2005 09:40
              To: miva-users
              Subject: Re: ARRAYS : Retrieving and reassigning data II


              Thanks Claudiu,
              While completely logical it doesn't work either.

              <MvASSIGN NAME="l.newcat_string" VALUE="{ 'g.cattree_' $ l.newcat_var $
              ':id' }"> <MvASSIGN NAME="l.newcat_id" VALUE="{
              miva_variable_value('g.cattree_' $ l.newcat_var $ ':id') }"> <MvEVAL
              EXPR="{l.newcat_string $ ' = ' $ l.newcat_id}">


              Results in this output
              g.cattree_1_1:id =
              g.cattree_1_2:id =
              g.cattree_1_3:id =
              g.cattree_1_4:id =

              Any other sugestions?
              Is miva_variable_value() unable to handle structures?
              Ray

              Subject: RE: [meu] Re: ARRAYS : Retrieving and reassigning data II

              <MvEVAL EXPR="{&[l.cat]}"> .. normally the compiler (and empresa) don't
              support macros anymore..

              For: <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
              you should use

              <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
              $ ':id') }"> <MvEVAL EXPR="{l.cat}">

              Best regards,
              Claudiu


              Subject: [meu] Re: ARRAYS : Retrieving and reassigning data II


              I'm having the same problem with pseudo arrays.
              See <A HREF ="http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979">http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979</A>

              I can aassign the values to the array but I can get access the value unless
              I hard code the indexes.

              I can create a string version of the variable and assign a value.
              <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }"> <MvASSIGN NAME="{
              l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">

              Where l.cat is in the format g.cattree_1_1

              I can output the value directly <MvEVAL EXPR="{g.cattree_1_1}"> but when
              trying to use variable indexes I can't get the values back out.

              <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }"> <!--
              string "g.catree_1_1:id" -->
              <MvEVAL EXPR="{miva_variable_value(l.cat)}"> <!-- this outputs
              nothing -->
              <MvEVAL EXPR="{&[l.cat]}"> <!-- this causes a compiler syntax
              error -->

              Did you ever figure this out?
              Ray


              Alex Ricks [email protected] Wrote:
              >
              >From: Alex Ricks <[email protected]>
              >
              >Huhmmn, How to explain this?
              >
              >I need some help with these "psuedo" arrays. I can create a numbered
              >array
              based on
              >dbase three record numbers, but I have trouble retrieving the data from
              these arrays,
              >assigning them to the dbase record fields and updating the record :
              >
              >........
              >
              >My problem occurs with the three mvassigns you see. --
              From: Ray Yates <[email protected]>

              Comment


                #8
                Re: ARRAYS : Retrieving and reassigning data II



                On Fri, 28 Jan 2005 03:40:13 -0500, Ray Yates
                <[email protected]> gave utterance to the following:

                > Thanks Claudiu,
                > While completely logical it doesn't work either.
                >
                > <MvASSIGN NAME="l.newcat_string" VALUE="{ 'g.cattree_' $ l.newcat_var $
                > ':id' }">
                > <MvASSIGN NAME="l.newcat_id" VALUE="{ miva_variable_value('g.cattree_' $
                > l.newcat_var $ ':id') }">
                > <MvEVAL EXPR="{l.newcat_string $ ' = ' $ l.newcat_id}">

                >
                > Results in this output
                > g.cattree_1_1:id =
                > g.cattree_1_2:id =
                > g.cattree_1_3:id =
                > g.cattree_1_4:id =
                > Any other sugestions?
                > Is miva_variable_value() unable to handle structures?

                I have used the function (uncompiled) with structures, but I usually use
                the MEMBER syntax when assigning:

                <MvASSIGN NAME="{'g.cattree_' $ l.newcat_var}" MEMBER="id" VALUE="foo">


                --
                Richard Grevers
                Between two evils always pick the one you haven't tried



                Comment


                  #9
                  Re: ARRAYS : Retrieving and reassigning data II



                  I also use Member= when assign values TO the structure. I'm trying to get
                  the value FROM the structure without hard coding the indexes.

                  The odd thing is I got Claudiu's example to work ONE time. Now it doesn't
                  work any more.
                  I'm using compiler 1.14 and Miva Engine v4.1000

                  Is this a know bug?

                  -----Original Message-----
                  From: Richard Grevers [mailto:[email protected]]
                  Sent: Friday, January 28, 2005 4:33 AM
                  To: Ray Yates; miva-users
                  Subject: Re: [meu] Re: ARRAYS : Retrieving and reassigning data II

                  On Fri, 28 Jan 2005 03:40:13 -0500, Ray Yates
                  <[email protected]> gave utterance to the following:

                  I have used the function (uncompiled) with structures, but I usually use the
                  MEMBER syntax when assigning:

                  <MvASSIGN NAME="{'g.cattree_' $ l.newcat_var}" MEMBER="id" VALUE="foo">


                  --
                  Richard Grevers
                  Between two evils always pick the one you haven't tried


                  Comment


                    #10
                    Re: ARRAYS : Retrieving and reassigning data II



                    Are you shure you are using well the vars names?

                    <MIVA STANDARDOUTPUTLEVEL = "text,html,compresswhitespace">
                    <html><head></head><body>

                    <mvassign name="l.cat_var" value="1_1">
                    <mvassign name="g.cattree_1_1:id" value="Super shoupa wabba doub!">
                    <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $
                    l.cat_var$ ':id') }">
                    <MvEVAL EXPR="{l.cat}">

                    </body></html>

                    this work..

                    Best regards,
                    Claudiu

                    -----Original Message-----
                    From: [email protected] [mailto:[email protected]]On
                    Behalf Of Ray Yates
                    Sent: vendredi 28 janvier 2005 10:36
                    To: miva-users
                    Subject: RE: [meu] Re: ARRAYS : Retrieving and reassigning data II


                    I also use Member= when assign values TO the structure. I'm trying to get
                    the value FROM the structure without hard coding the indexes.

                    The odd thing is I got Claudiu's example to work ONE time. Now it doesn't
                    work any more.
                    I'm using compiler 1.14 and Miva Engine v4.1000

                    Is this a know bug?

                    -----Original Message-----
                    From: Richard Grevers [mailto:[email protected]]
                    Sent: Friday, January 28, 2005 4:33 AM
                    To: Ray Yates; miva-users
                    Subject: Re: [meu] Re: ARRAYS : Retrieving and reassigning data II

                    On Fri, 28 Jan 2005 03:40:13 -0500, Ray Yates
                    <[email protected]> gave utterance to the following:

                    I have used the function (uncompiled) with structures, but I usually use the
                    MEMBER syntax when assigning:

                    <MvASSIGN NAME="{'g.cattree_' $ l.newcat_var}" MEMBER="id" VALUE="foo">


                    --
                    Richard Grevers
                    Between two evils always pick the one you haven't tried


                    Comment


                      #11
                      RE: ARRAYS : Retrieving and reassigning data II



                      Looks like you left off the underscore

                      <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
                      > $ ':id') }">

                      On 1/28/05 4:17 AM, "Ray Yates " <[email protected]>
                      wrote:

                      > I duplicated your results but only once...
                      >
                      > <mvassign name="l.cat_var" value="test">
                      > <mvassign name="g.cattree_test:id" value="Super shoupa wabba doub!">
                      > <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree' $ l.cat_var
                      > $ ':id') }">
                      > <MvEVAL EXPR="{l.cat}">
                      >
                      > I compiled, uploaded and it worked.
                      >
                      > Then I changed <mvassign name="l.cat_var" value="1_1">
                      > I compiled, uploaded and it return a blank screen.
                      >
                      > I changed it to
                      > <MIVA STANDARDOUTPUTLEVEL = "text,html,compresswhitespace">
                      > <html><head></head><body>
                      >
                      > <mvassign name="l.cat_var" value="test">
                      > <mvassign name="g.cattree_test:id" value="Super shoupa wabba doub!">
                      > <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree' $ l.cat_var
                      > $ ':id') }">
                      > <MvEVAL EXPR="{l.cat}">
                      >
                      > </body></html>
                      >
                      > I compiled, uploaded and it still return a blank.
                      > I just rebooted the server and I'm going to try again
                      >
                      >
                      >
                      > -----Original Message-----
                      > From: [email protected] [mailto:[email protected]] On Behalf
                      > Of Claudiu Bischoff
                      > Sent: Friday, January 28, 2005 3:53 AM
                      > To: Ray Yates; miva-users
                      > Subject: [meu] RE: ARRAYS : Retrieving and reassigning data II
                      >
                      > I made a small test that work:
                      >
                      > <mvassign name="l.cat_var" value="test"> <mvassign
                      > name="g.cattree_test:id" value="Super shoupa wabba doub!">
                      >
                      > <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
                      > $ ':id') }"> <MvEVAL EXPR="{l.cat}">
                      >
                      > Now if you want to use arrays.. this could be better:
                      >
                      > <mvassign name="g.cattree" index="1" value="test1"> <mvassign
                      > name="g.cattree" index="2" value="test2"> <mvassign name="g.cattree"
                      > index="3" value="test3">
                      >
                      > <MvASSIGN NAME="l.newcat_id" VALUE="{ miva_variable_value('g.cattree[' $
                      > l.your_array_number $ ']:id') }">
                      > ANd that shoul output your values..
                      >
                      > Now tell me exactly what you want to do .. I can help more if I have the
                      > whole idea ..
                      >
                      > Best regards,
                      > Claudiu
                      >
                      > -----Original Message-----
                      > From: Ray Yates [mailto:[email protected]]
                      > Sent: vendredi 28 janvier 2005 09:40
                      > To: miva-users
                      > Subject: Re: ARRAYS : Retrieving and reassigning data II
                      >
                      >
                      > Thanks Claudiu,
                      > While completely logical it doesn't work either.
                      >
                      > <MvASSIGN NAME="l.newcat_string" VALUE="{ 'g.cattree_' $ l.newcat_var $
                      > ':id' }"> <MvASSIGN NAME="l.newcat_id" VALUE="{
                      > miva_variable_value('g.cattree_' $ l.newcat_var $ ':id') }"> <MvEVAL
                      > EXPR="{l.newcat_string $ ' = ' $ l.newcat_id}">

                      >
                      > Results in this output
                      > g.cattree_1_1:id =
                      > g.cattree_1_2:id =
                      > g.cattree_1_3:id =
                      > g.cattree_1_4:id =
                      >
                      > Any other sugestions?
                      > Is miva_variable_value() unable to handle structures?
                      > Ray
                      >
                      > Subject: RE: [meu] Re: ARRAYS : Retrieving and reassigning data II
                      >
                      > <MvEVAL EXPR="{&[l.cat]}"> .. normally the compiler (and empresa) don't
                      > support macros anymore..
                      >
                      > For: <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
                      > you should use
                      >
                      > <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattree_' $ l.cat_var
                      > $ ':id') }"> <MvEVAL EXPR="{l.cat}">
                      >
                      > Best regards,
                      > Claudiu
                      >
                      >
                      > Subject: [meu] Re: ARRAYS : Retrieving and reassigning data II
                      >
                      >
                      > I'm having the same problem with pseudo arrays.
                      > See <A HREF ="http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979">http://www.miva.com/~archive/meu/index.mv?control=displaymsid=id90979</A>
                      >
                      > I can aassign the values to the array but I can get access the value unless
                      > I hard code the indexes.
                      >
                      > I can create a string version of the variable and assign a value.
                      > <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }"> <MvASSIGN NAME="{
                      > l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">
                      >
                      > Where l.cat is in the format g.cattree_1_1
                      >
                      > I can output the value directly <MvEVAL EXPR="{g.cattree_1_1}"> but when
                      > trying to use variable indexes I can't get the values back out.
                      >
                      > <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }"> <!--
                      > string "g.catree_1_1:id" -->
                      > <MvEVAL EXPR="{miva_variable_value(l.cat)}"> <!-- this outputs
                      > nothing -->
                      > <MvEVAL EXPR="{&[l.cat]}"> <!-- this causes a compiler syntax
                      > error -->
                      >
                      > Did you ever figure this out?
                      > Ray
                      >
                      >
                      > Alex Ricks [email protected] Wrote:
                      >>
                      >> From: Alex Ricks <[email protected]>
                      >>
                      >> Huhmmn, How to explain this?
                      >>
                      >> I need some help with these "psuedo" arrays. I can create a numbered
                      >> array
                      > based on
                      >> dbase three record numbers, but I have trouble retrieving the data from
                      > these arrays,
                      >> assigning them to the dbase record fields and updating the record :
                      >>
                      >> ........
                      >>
                      >> My problem occurs with the three mvassigns you see. --
                      > From: Ray Yates <[email protected]>
                      >

                      Comment


                        #12
                        Re: ARRAYS : Retrieving and reassigning data II



                        Now, maybe you typed something in wrong, but...

                        In your first example you talked about
                        g.test_1_1_n:id

                        but everything after that you refer to as
                        g.test_1_1:id

                        What happened to the '_n'? Was that a typo from the intro,
                        or has we been trying to pull out the wrong variable?

                        /ScottMc


                        --- Ray Yates <[email protected]> wrote:

                        > I also use Member= when assign values TO the structure.
                        > I'm trying to get
                        > the value FROM the structure without hard coding the
                        > indexes.
                        >
                        > The odd thing is I got Claudiu's example to work ONE
                        > time. Now it doesn't
                        > work any more.
                        > I'm using compiler 1.14 and Miva Engine v4.1000
                        >
                        > Is this a know bug?
                        >
                        > -----Original Message-----
                        > From: Richard Grevers [mailto:[email protected]]
                        > Sent: Friday, January 28, 2005 4:33 AM
                        > To: Ray Yates; miva-users
                        > Subject: Re: [meu] Re: ARRAYS : Retrieving and
                        > reassigning data II
                        >
                        > On Fri, 28 Jan 2005 03:40:13 -0500, Ray Yates
                        > <[email protected]> gave utterance to the
                        > following:
                        >
                        > I have used the function (uncompiled) with structures,
                        > but I usually use the
                        > MEMBER syntax when assigning:
                        >
                        > <MvASSIGN NAME="{'g.cattree_' $ l.newcat_var}"
                        > MEMBER="id" VALUE="foo">
                        >
                        >
                        > --
                        > Richard Grevers
                        > Between two evils always pick the one you haven't tried
                        >
                        >

                        Comment


                          #13
                          Re: Re: ARRAYS : Retrieving and reassigning data II



                          I got it solved. Thanks to everyone that posted.

                          There seems to be a problem (at least on my site) with the handling of structures by miva_variable_value(). I finally realized (duh) that since I'm using a Pseudo Array anyway I could just use a Pseudo Structure as well.

                          <mvassign name="l.cat_var" value="1_1">
                          <mvassign name="g.cattreeid_1_1" value="204">
                          <MvASSIGN NAME="l.cat" VALUE="{ miva_variable_value('g.cattreeid_' $ l.cat_var) }">
                          <MvEVAL EXPR="{l.cat}">

                          My "array" will contain similarly named g.cattreename_ and g.cattreecode_ elements.

                          Let me explain l.cat_var" value="1_1

                          Since I can't know how deep the tree is g.cattreeid_1, g.cattreeid_2, g.cattreeid_3 and so on contain the top level category id's. g.cattreeid_1_1, _1_2, _1_3 and so on is the branch below the first top level category. g.cattreeid_4_4_3_1 would be a branch 4 levels deep starting at the 4th top category, 4th parent category, 3rd child category, 1st grandchild etc. As I build the array, I keep track of the depth of each level in a stack array and call a recursive routine to populate all the branches.

                          A Multi dimensional array would have been way more convient to code (as I did on the first crack at this) but Mivascript arrays can't be re-sized and retain their values. So you would have to "pick" an arbitrary depth up front and/or pass a fixed depth to the function.



                          Scot Ranney [email protected] Wrote:
                          >
                          >Did you get it working?
                          >
                          >The code below basically does what you are looking for from what I could
                          >glean from your emails.
                          >
                          ><MvCOMMENT>Set l.cat_var to: 1_1</MvCOMMENT>
                          ><MvASSIGN NAME = "l.cat_var" VALUE = "{ '1_1' }">
                          >
                          ><MvCOMMENT>asssign 12345 to "g.cattree_1_1:id"</MvCOMMENT>
                          ><MvASSIGN NAME = "{ 'g.cattree_' $ l.cat_var $ ':id' }" VALUE = "{
                          >'12345' }">
                          >
                          ><MvCOMMENT>Create your category variable string</MvCOMMENT>
                          ><MvASSIGN NAME="l.cat_string" VALUE="{ 'g.cattree_' $ l.cat_var $ ':id' }">
                          >
                          ><MvEVAL EXPR = "{'l.cat_string: ' $ l.cat_string $ '
                          '}">
                          >
                          ><MvCOMMENT>Assign l.cat_id the value of l.cat_string (12345)</MvCOMMENT>
                          ><MvASSIGN NAME="l.cat_id" VALUE="{ miva_variable_value(l.cat_string)}">
                          >
                          ><MvCOMMENT>Evaluate the data</MvCOMMENT>
                          ><MvEVAL EXPR = "{'Data: ' $ l.cat_id}">
                          >
                          >Scot
                          ><A HREF ="http://www.scotsscripts.com">http://www.scotsscripts.com</A>
                          >
                          >Ray Yates wrote:
                          >> MivaScript's array handling seems to be pretty strangely implemented or else
                          >> I'm just dumb. I can't figure out how to do this with the
                          >> miva_variable_value() function or macro's. Neither seem to work with
                          >> structured arrays.
                          >>
                          >> I have a situation where I can't know how many dimensions my array will
                          >> require beforehand. I'm loading the entire category tree into a structure
                          >> and since there is no way to re-dimension an array and retain it's values
                          >> I've been coding using the old techniques formerly supported using macro's.
                          >>
                          >> I'm using this structure g.cattree_1_1_n:name, g.cattree_1_1_n:id,
                          >> g.cattree_1_1_n:code.
                          >> Top level category: g.cattree_1:id,
                          >> Parent level category: g.cattree_1_1:id
                          >> Child level category: g.cattree_1_1_1:id and so on for as many levels as
                          >> needed.
                          >>
                          >> Where l.cat_var is a string in the form "1_1", I have successfully stored
                          >> data in this pseudo array using this technique.
                          >> <MvASSIGN NAME="l.cat" VALUE="{ 'g.cattree_' $ cat_var }">
                          >> <MvASSIGN NAME="{ l.cat }" MEMBER="id" VALUE="{ Categories.d.id }">
                          >>
                          >> BUT, I can't get the data back out.
                          >> Again, where l.cat_var is t string "1_1" the assignment below produces the
                          >> string "g.catree_1_1:id"
                          >> <MvASSIGN NAME="l.cat_string" VALUE="{ 'g.cattree_' $ l.cat_var $
                          >> ':id' }">
                          >>
                          >> This assignment fails to do anything...
                          >> <MvASSIGN NAME="l.cat_id" VALUE="{ miva_variable_value(l.cat_string)
                          >> }">
                          >>
                          >> However, this assignment works!
                          >> <MvASSIGN NAME="l.cat_id" VALUE="{ g.catree_1_1:id }">
                          >>
                          >> Question:
                          >> Once I have created this string "g.catree_1_1:id" as the name if a variable
                          >> that holds Categories.d.id, how do I use that string to get the id stored in
                          >> a simple variable?
                          >>
                          >> Comment:
                          >> I've already tried <MvEVAL EXPR="{[l.cat_string]}"> exactly like the
                          >> documentation shows.
                          >> The compiler produces this error. Found unexpected "" in expression
                          >>
                          >> Ray Yates
                          >>
                          >>
                          >>
                          >> I eventually figured out
                          >>
                          >>
                          >> Ray Yates
                          >> <A HREF ="http://www.flyinghands.com">http://www.flyinghands.com</A>
                          >>
                          >>
                          >

                          Scott McC [email protected] Wrote:
                          >
                          >Now, maybe you typed something in wrong, but...
                          >
                          >In your first example you talked about
                          >g.test_1_1_n:id
                          >
                          >but everything after that you refer to as
                          >g.test_1_1:id
                          >
                          >What happened to the '_n'? Was that a typo from the intro,
                          >or has we been trying to pull out the wrong variable?
                          >
                          >/ScottMc
                          >
                          >
                          >--- Ray Yates <[email protected]> wrote:
                          >
                          >> I also use Member= when assign values TO the structure.
                          >> I'm trying to get
                          >> the value FROM the structure without hard coding the
                          >> indexes.
                          >>
                          >> The odd thing is I got Claudiu's example to work ONE
                          >> time. Now it doesn't
                          >> work any more.
                          >> I'm using compiler 1.14 and Miva Engine v4.1000
                          >>
                          >> Is this a know bug?
                          >>
                          >> -----Original Message-----
                          >> From: Richard Grevers [mailto:[email protected]]
                          >> Sent: Friday, January 28, 2005 4:33 AM
                          >> To: Ray Yates miva-users
                          >> Subject: Re: [meu] Re: ARRAYS : Retrieving and
                          >> reassigning data II
                          >>
                          >> On Fri, 28 Jan 2005 03:40:13 -0500, Ray Yates
                          >> <[email protected]> gave utterance to the
                          >> following:
                          >>
                          >> I have used the function (uncompiled) with structures,
                          >> but I usually use the
                          >> MEMBER syntax when assigning:
                          >>
                          >> <MvASSIGN NAME="{'g.cattree_' $ l.newcat_var}"
                          >> MEMBER="id" VALUE="foo">
                          >>
                          >>
                          >> --
                          >> Richard Grevers
                          >> Between two evils always pick the one you haven't tried
                          >>
                          >>
                          >
                          --
                          From: Ray Yates <[email protected]>

                          Comment

                          Working...
                          X