Can I use a variable within the Path?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Can I use a variable within the Path?

  • Creator
    Topic
  • #48079
    Rentian Huang
    Participant

      Greetings Cloverleafers!!!

      V5.2 on AIX

      Can I use a variable within the Path? As far as I know, %g1 is also a variable, but when I tried %ctr, @ctr, @%ctr or %@ctr, none of them works….  

      ITERATE

         COPY:    =Patient  —>  1(0).1(%g1).1(%@ctr).OBX.00573

    Viewing 9 reply threads
    • Author
      Replies
      • #57570
        Ryan Spires
        Participant

          What I typically do is use the @ctr, but before using it in a path, copy it to an unused list variable

          copy

          @ctr          $%l1

          Then you can use %l1 in your path with the value your were storing in @ctr.

          Ryan

          Rentian Huang wrote:

          Greetings Cloverleafers!!!

          V5.2 on AIX

          Can I use a variable within the Path? As far as I know, %g1 is also a variable, but when I tried %ctr, @ctr, @%ctr or %@ctr, none of them works….

        • #57571
          Rentian Huang
          Participant

            Ryan,

            I tried:

            COPY   =1  –> $%l1

            it works perfectly!

            But

            COPY   @ctr –> $%l1

            just hangs my testing tools forever

            I tried to use MATH and same thing happens…

            MATH: SUB    @ctr =1  –> $%l1

            Seems $%l1 doesn’t accept any variable???  Any suggestion?

            -Thanks!  

            8)

          • #57572
            Rentian Huang
            Participant

              I thou I needed to initiate the list variable, then I added a:

              COPY   =0 –> $%l1

              before

              COPY  @ctr –> $%l1

              COPY  @obx5 –> 1(0).1(%g1).1(%l1).OBX.00573

              but it still hangs my testing tool…. The below works fine:

              COPY  =2 –> $%l1

              COPY  @obx5 –> 1(0).1(%g1).1(%l1).OBX.00573

              I output the value of @ctr and it looks fine too…   🙁

            • #57573
              Jim Kosloskey
              Participant

                Did you initialize @ctr prior to referring to it?

                Jim Kosloskey

                email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

              • #57574
                Rentian Huang
                Participant

                  Ryan/Jim,

                  I did initialized the @ctr

                  COPY  =0 –> @ctr

                  I even output it to see its value and it looks ok:

                  COPY  @ctr -> 1(0).1(0).1(0).OBX.00569

                  the code below works too:

                  COPY  =3 –> @ctr

                  COPY  @ctr –> $%l1

                  COPY  @obx5 –> 1(0).1(%g1).1(%l1).OBX.00573

                  where did I do wrong?   😮

                • #57575
                  Rentian Huang
                  Participant

                    This is a very strange situation. If it were an error msg in the test tool I would have figured out a way, the problem is it just hangs the tool.

                    It’s have been a long day..   8)

                  • #57576
                    Charlie Bursell
                    Participant

                      The %g1 %s1, etc are not variables in the true sense.  That is why you can’t make substitutions as you want.

                      With that said, I do things llike you are trying to do all the time.  That is one of the main purposes of the CALL statement.  It allows for that kind of control.  Just use a CALL and do the xpmstore command within it.

                      The *ONlY* difference bewteen a COPY and a CALL is that with a COPY, there is *ALWAYS* something stored to xlateOutVals.  With a CALL, *NOTHING* is stored unless you explicitly store it.

                    • #57577
                      Rentian Huang
                      Participant

                        I added a CALL, but the value in @ctr just can NOT get passed to the variable $%l1 ???

                        CALL   @ctr -> {$%l1}

                        set counter [lindex $xlateInVals 0]

                        incr counter -1

                        xpmstore $xlateId [lindex $xlateOutList 0] c $counter

                      • #57578
                        Charlie Bursell
                        Participant

                          That’s not how you would use it.  Get the variable you want to use to increment the address and use it as part of the address in the xmpstore.  The variable could be @cnt that you passed in.

                          Assume you are passing a value in and a cnt in @ cnt in that order.  The ob address is the base address to store the data plus @cnt for update.

                          # Get the value and the cout

                          lassign $xlateInVals val cnt

                          # Get the two OB addresses

                          lassign $xlateOutList valAddr cntAddr

                          # Assume you know address is something like :

                          # 0(0).PID(0).00133 and you want it to be

                          # 0(0).PID(CTR).00133

                          regsub — {PID(0)} $valAddr “PID($cnt)” valAddr

                          # Increment the counter

                          incr cnt

                          # store the count

                          xpmstore $xlateId $cntAddr c $cnt

                          # Store the value

                          xmpstore $xalteId $valAddr c $val

                          This is off the top of my head.  I think its right but I may have fat-fingered something.

                        • #57579
                          Rentian Huang
                          Participant

                            Sorry for this late reply. I put this in a CALL action:


                            set val [datget [xpmfetch $xlateId @obx5] VALUE]

                            set cnt [datget [xpmfetch $xlateId @ctr] VALUE]

                            incr cnt -1

                            set valAddr {1(0).1(%g1).1(0).OBX.00573.[0]}

                            echo g1).1($cnt

                            regsub {g1).(0} $valAddr “g1).1($cnt” valAddr

                            xpmstore $xlateId $valAddr c $val


                            the value of $cnt just can NOT get into its right place. Even “echo g1).1($cnt ” yields the correct result. but after the regsub, $cnt becomes 0 again.

                            I m out of idea…

                            Sam  😮

                        Viewing 9 reply threads
                        • The forum ‘Cloverleaf’ is closed to new topics and replies.