Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it possible to get this result?
Message
From
01/05/2002 08:07:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00651242
Message ID:
00651256
Views:
21
This message has been marked as a message which has helped to the initial question of the thread.
>>>>>What I'm trying to achieve is a single, quick test that will compare 2 sets of states and give the following results:
>>>>>
>>>>>State1 State2 Result
>>>>> T       T      T
>>>>> T       F      F
>>>>> F       T      T
>>>>> F       F      T
>>>>>
>>>>>The first state indicated if something if being used and the second if access is granted. I really want to do this check when creating nodes for a treeview so speed is quite important.
>>>>>
>>>>>Can anyone point me to a solution?
>>>>>Thanks in anticipation.
>>>>
>>>>select State1, State2, State2 or State1 = State2 as Result from myTable
>>>>
>>>>Cetin
>>>
>>>Cetin,
>>>
>>>Is it possible to do something similar to compare the 2 States if they are strings:
>>>
>>>State1 = "TTFF"
>>>State2 = "TFTF"
>>>
>>
>>
>>
Result=""
>>for ix=1 to len(State1)
>> Result = Result + iif(substr(State2,ix)='T' or substr(State2,ix)=substr(State1,ix),'T','F')
>>endfor
>>
>>However you're saying speed is important. For a similar thing where strings are much much longer I use a FLL.
>>Depending on your needs you might want to FLL, lowlevel check, parsing to array, cursor tricks etc
>>Cetin
>Cetin,
>
>Thanks for all your help I'll give it a go this way and see what the speed is like then maybe try the array or cursor tricks as suggested.
>
>Thanks again

Maybe this one would be faster :
Result=State2
for ix=1 to len(Result)
	if substr(m.Result,ix)='F' and substr(m.State1,ix)='F'
		Result = stuff(m.Result,m.ix,1,'T')
	endif
endfor
? Result
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform