Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select
Message
De
10/08/2008 09:37:37
 
 
À
10/08/2008 04:43:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Select
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01336783
Message ID:
01337887
Vues:
7
I'm sorry, but I have absolutely no idea about what you try to do here. As written many, many times before, your code is NOT interesting at all. Tell us what you have and what you want, NOTHING MORE.


But did you really try my code which will give you EXACTLY the result you wanted in your earlier message? You wrote that I did not use AND, but AND is not necessary the way I wrote the code. My code first creates a cursor where lcName1 matches any of your four name fields. Then uses this cursor to filter where ALSO lcName2 exists, then the same with lcName3 and lcName4. The end result is a cursor where all not blank lcNameX exist in any of the four nameX fields.

>hi,
>
>thank you for reply and help,
>
>i need to make code as below at event interactivchange for text1,text2,text3 and text4,
>
>
>
>
>    SET EXCLUSIVE off
>    SET EXACT on
>
>
>             lcName1 = alltrim(thisform.text1.value)
>             lcName2 = alltrim(thisform.text2.value)
>             lcName3 = alltrim(thisform.text3.value)
>             lcName4 = alltrim(thisform.text4.value)
>
>IF lcName1=="" AND lcName2 ==""   AND lcName3 =="" AND lcName4<>""
>      if LEN(ALLTRIM(thisform.text4.value)) >= 3
>     Select F4,F1,name4,name3,name2,name1 from x2 where  name4=lcName4;
>                                  into cursor lcResultTable
>
>
>              ************************************************
>      if LEN(ALLTRIM(thisform.text3.value)) >= 3 and LEN(ALLTRIM(thisform.text4.value)) >= 3
>
>       IF  lcName1 ==""   AND lcName2 =="" AND lcName3<>""  AND lcName4<>""
>
>        Select F4,F1,name4,name3,name2,name1 from x2 where   name3=lcName3 AND name4=lcName4;
>                                  into cursor lcResultTable
>
>                             ********************************************
>if LEN(ALLTRIM(thisform.text3.value)) >= 3 and LEN(ALLTRIM(thisform.text4.value)) >= 3 and LEN(ALLTRIM(thisform.text2.value)) >= 3
>
>       IF  lcName1 ==""   AND lcName2 <>"" AND lcName3<>""  AND lcName4<>""
>
>        Select F4,F1,name4,name3,name2,name1 from x2 where  name2=lcName2 and name3=lcName3 AND name4=lcName4;
>                                  into cursor lcResultTable
>                                  ***********************************************
>  if LEN(ALLTRIM(thisform.text3.value)) >= 3 and LEN(ALLTRIM(thisform.text4.value)) >= 3 and LEN(ALLTRIM(thisform.text2.value)) >= 3 AND LEN(ALLTRIM(thisform.text1.value)) >= 3
>
>       IF  lcName1 <>""   AND lcName2 <>"" AND lcName3<>""  AND lcName4<>""
>
>        Select F4,F1,name4,name3,name2,name1 from x2 where   name1=lcName1 AND name2=lcName2 and name3=lcName3 AND name4=lcName4;
>                                  into cursor lcResultTable  NOFILTER
>
>
>
>              ENDIF
>              ENDIF
>              ENDIF
>              ENDIF
>              ENDIF
>              ENDIF
>              ENDIF
>              ENDIF
>
>
>
>GO top
>  thisform.Grid1.RecordSource="lcResultTable"
>          thisform.grid1.Visible=.t.
>
>
>
>
>thanks for help
>
>>>I had a typo in my program, I wrote Endif instead of Endfor. Also I suggest that you change == to =. This modified version works as you describe. If one or more of lxNameX match any of the nameX fields, you have a match.
>>>lcFromTable='x2'
>>>lcResultTable='crsMyCursor'
>>>For x=1 to 4
>>>   lcName=Evaluate('lcName'+Transform(x))
>>>   If !Empty(lcName)
>>>      Select * from (lcFromTable) where name1=lcName or name2=lcName or name3=lcName or name4=lcName into cursor (lcResultTable) READWRITE
>>>      lcFromTable=lcResultTable
>>>   EndIf
>>>EndFor
>>>NB! I tested it this time. :-)
>>
>>Nice! You can, of course, write it as one long select too, e.g.
>>
>>  Select * from (lcFromTable) where (m.lcName1=="" OR (name1=lcName1 or name2=lcName1 or name3=lcName1 or name4=lcName1) )
>>AND ((m.lcName2=="" OR (name1=lcName2 or name2=lcName2 or name3=lcName2 or name4=lcName2) )
>>AND ...
>>
>>
>>into cursor (lcResultTable)
>>
>>BTW, you can exit out of the loop once you get no result, you need to add a check for this.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform