MasteringVFP/4/7/2
出自VFP Wiki
http://www.textcachivirovir.com
seek
èªå¾ä¸ç¥ç¬¬å¹¾çç VFP æä¾ Seek() éåå½æ¸, å°±æ²åç¨ Seek çå½ä»¤, ä¸éååç VFP8 ç Help æç¼ç¾åä¾ Seek å½ä»¤ä¹å¤äºä¸å°åæ¸å¯ä»¥ä¸, éæ¯ä»¥åé½æ²æ³¨æå¢?
SEEK eExpression [ORDER nIndexNumber | IDXIndexFileName | [TAG] TagName [OF CDXFileName] [ASCENDING | DESCENDING]] [IN nWorkArea | cTableAlias]
Seek ä¸è«å½æ¸æå½ä»¤é½å¿ é äºåå»ºç« Index, ç¨éç解é大æ¦å°±æ¯:è³æ庫建ç«éç´¢å¼å¾, 使ç¨è©²æ令æ¾å°å°ç¬¦åæ¢ä»¶ç第ä¸çè¨é, å¦ææ¾ä¸å°å°ç§»åå°æå¾, å¯ç¨ Found() æ Eof() ä¾å¤æ·ã ä½¿ç¨ Seek(), å¦æ Set("Near")="OFF" ç話, ä¸ç¬¦åæ¢ä»¶, è¨éå°ç§»åå°æå¾, å¦æ Set("Near")="ON", ä¸ç¬¦åæ¢ä»¶, è¨éå°ç§»åå°æ符åæ¢ä»¶çè¨éç·¨èãSeek çå½ä»¤åç¡æ³åå°åè¿°åè½ã
æåå°±ä¾çç以ä¸çå¹¾åä¾å~
(1)
Set Near on CREATE CURSOR ABC(Field1 C(5)) INDEX ON field1 TO XYZ INSERT INTO ABC (Field1) Value("1") INSERT INTO ABC (Field1) Value("2") INSERT INTO ABC (Field1) Value("4") INSERT INTO ABC (Field1) Value("5") SEEK "3" ? Eof()
ä¸è¿° Eof() å°åå³ .T., 表示æ¾ä¸å° "3", è¨éä¹ç§»åå°æå¾ ä¸éå¦æ使ç¨ä»¥ä¸å½ä»¤
?Seek("3") ?Recno()
å°åå³ .F., è¨éå»æåçå¨ç¬¬ 3 ç, ä¹å°±æ¯ Field1="4" çä½ç½®, èä¸æ移åå°æå¾ æ¨å¯ä»¥è©¦è©¦ç Set Near Off åæç¼çä»éº¼æ æ³
(2)
Set Exact off CREATE CURSOR ABC(Field1 C(5)) INDEX ON field1 TO XYZ INSERT INTO ABC (Field1) Value("11") INSERT INTO ABC (Field1) Value("22") ?SEEK("2")
ä¸è¿°è¨å® Exact çº Off, æ¢ä»¶æ¥è©¢æå çºæ¥å°ç¬¬äºç 22 ç第ä¸å 2, æ以æ¯è¢«äºè¨±ç¬¦åæ¢ä»¶ ä½æ¯ç¶ Exact è¨å®çº On æ, é£è¦ç¬¦åæ¢ä»¶, åªè½ä¸ Seek("22") æç®ç¬¦åæ¢ä»¶ã