Tell me why


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Tell me why

  1. #1
    Toms Ng Guest

    Tell me why


    Case(1)
    select a
    set filter to a.field1 = "TOMS"
    Case(2)
    Local lcValue
    lcValue = this.txtValue.value-->("TOMS")
    select a
    set filter to a.field1 = lcValue
    Case(3)
    Local lcValue , lcString
    lcValue = this.txtValue.value-->("TOMS")
    lcString = "set filter to " + chr(39) + lcValue + Chr(39)
    select a
    &lcString
    Why case(3) and case(1) .




  2. #2
    Fred - Armoni Guest

    Re: Tell me why

    Toms Ng a écrit :
    >
    > Case(1)
    > select a
    > set filter to a.field1 = "TOMS"
    > Case(2)
    > Local lcValue
    > lcValue = this.txtValue.value-->("TOMS")
    > select a
    > set filter to a.field1 = lcValue
    > Case(3)
    > Local lcValue , lcString
    > lcValue = this.txtValue.value-->("TOMS")
    > lcString = "set filter to " + chr(39) + lcValue + Chr(39)

    lcString = "set filter to a.field1=" + chr(39) + lcValue + Chr(39)

    > select a
    > &lcString
    > Why case(3) and case(1) .


    I assume that you want to say why Case(2) doesn't work.
    the this.txtValue.value is scoped only in your object (this). The filter is
    evaluate every time you move the record pointer and then the this.txtValue.value
    is un-scoped.

    Fred
    --
    FE AVP&Cie
    Juillenay, Europe

  3. #3
    Fred Taylor Guest

    Re: Tell me why

    Because your local variable lcValue has gone out of scope in every other
    place besides the method you've actually got the code in.

    In case 1 you're using a direct value ("TOMS") and in case 3, you've
    essentially created a string that contains the direct value, and are no
    longer dependant on the existance of the variable lcValue.

    --
    Fred
    Microsoft Visual FoxPro MVP
    Please respond only to the newsgroups so that all may benefit.


    "Toms Ng" <Toms@Magic.com.hk> wrote in message
    news:3ab0ef31$1@news.devx.com...
    >
    > Case(1)
    > select a
    > set filter to a.field1 = "TOMS"
    > Case(2)
    > Local lcValue
    > lcValue = this.txtValue.value-->("TOMS")
    > select a
    > set filter to a.field1 = lcValue
    > Case(3)
    > Local lcValue , lcString
    > lcValue = this.txtValue.value-->("TOMS")
    > lcString = "set filter to " + chr(39) + lcValue + Chr(39)
    > select a
    > &lcString
    > Why case(3) and case(1) .
    >
    >
    >




  4. #4
    Nancy Folsom Guest

    Re: Tell me why

    In article <3ab0ef31$1@news.devx.com>, Toms@Magic.com.hk says...

    The Freds <g> told you the why. Perhaps we could also help you with
    how to debug that sort of question. You don't post the error message
    you got, and I don't know how you proceeded, but one technique would
    have been to break at the error, and if you put a watchpoint on
    lcValue, you would have seen (probably) that it was undefined.

    Another idea specific to this particular problem would be set a
    watchpoint on the value of FILTER(calias). You see a telling difference
    between #2 and #3, I think. You can try it in the command window.

    --
    Nancy
    So that all can benefit from the discussion,
    please post all followups to the newsgroup.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center