Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to reduce the codes ?
Message
From
28/08/2004 14:06:23
 
 
To
28/08/2004 13:45:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00937323
Message ID:
00937325
Views:
7
Hi Paul,
SELECT TOP 5 ddate FROM mytable GROUP BY 1 ORDER BY 1 DESC INTO ARRAY DUMMY
lc1stDate = CTOD(DTOC(DUMMY(1)))
lc2ndDate = CTOD(DTOC(DUMMY(2)))
lc3rdDate = CTOD(DTOC(DUMMY(3)))
lc4thDate = CTOD(DTOC(DUMMY(4)))
lc5thDate = CTOD(DTOC(DUMMY(5)))
IF lc5thDate = nexttable.ddtae or lc4thDate = nexttable.ddtae or lc3rdDate = nexttable.ddtae lc2ndDate = nexttable.ddtae
   DO myprog
ELSE
   EXIT
ENDIF
Or if you don't need any more processing, you can do something like
SELECT TOP 5 ddate FROM mytable GROUP BY 1 ORDER BY 1 DESC INTO ARRAY DUMMY
IF ASCAN(DUMMY,nexttable.ddtae)>0
   DO myprog
ELSE
   EXIT
ENDIF
NB! Not tested, you may have to adjust the ASCAN line.

>Hello,
>
>How to make the following codes more shorter ?
>***************************************************
>SELECT TOP 5 ddate ;
> FROM mytable ;
> GROUP BY 1 ;
> ORDER BY 1 DESC ;
> INTO CURSOR crsddates
>
>LOCAL lc1stDate,lc2ndDate,lc3rdDate,lc4thDate,lc5thDate
>GO 1
>lc1stDate = CTOD(DTOC(crsddates.ddate))
>GO 2
>lc2ndDate = CTOD(DTOC(crsddates.ddate))
>GO 3
>lc3rdDate = CTOD(DTOC(crsddates.ddate))
>GO 4
>lc4thDate = CTOD(DTOC(crsddates.ddate))
>GO 5
>lc5thDate = CTOD(DTOC(crsddates.ddate))
>
>DO CASE
> CASE lc5thDate = nexttable.ddtae
> DO myprog
>
> CASE lc4thDate = nexttable.ddtae
> DO myprog
>
> CASE lc3rdDate = nexttable.ddtae
> DO myprog
>
> CASE lc2ndDate = nexttable.ddtae
>
> DO myprog
> OTHERWISE
> EXIT
>ENDCASE
>**********************************************
>TIA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform