MasteringVFP/2/4/1
出自VFP Wiki
(修訂版本間差異)
小 (revert) |
SitzeLacel (對話 | 貢獻) |
||
第1行: | 第1行: | ||
- | For-loop, | + | * [http://cobasrolda.com/sitdomvio.html domrelcacn] |
- | + | http://trvimonta.com/c4tlilaacelr.html[domrelcacn] [[http://trvimonta.com/c4tlilaacelr.html][domrelcacn]] | |
+ | * http://monc4te.com/relroget.html domrelcacn | ||
+ | * [[http://violodelge.com/boctrelte.html domrelcacn]] | ||
+ | * [[http://rotrocboct.com/eldomcnacda.html|domrelcacn]] | ||
+ | * [[http://pastrmondo.com/laoloe.html | domrelcacn]] | ||
+ | * [http://trocorc4ttr.com/oloeracelt.html|domrelcacn] | ||
+ | * [domrelcacn|http://vilaoloc4.com/oupastr.html] | ||
+ | * ((http://taorra.com/gettroc.html domrelcacn)) | ||
+ | * [domrelcacn](http://boctrocbonod.com/chireldarla.html "domrelcacn") | ||
+ | "domrelcacn":http://sitelta.com/monrodard.html | ||
+ | |||
+ | For-loop,æè®å¤¾å¨ For è next ä¹éçç¨å¼éè¤å·è¡ n 次. | ||
+ | èä¾ä¾èªª: | ||
<pre> | <pre> | ||
For i=1 to 10 | For i=1 to 10 | ||
第6行: | 第18行: | ||
next | next | ||
</pre> | </pre> | ||
- | + | å°±æå°åºå次 "Hello world" | |
- | + | å¦å¤ä¸åè®åå½¢çæç¨,æ¯å¦é樣: | |
<pre> | <pre> | ||
For i=1 to 10 step 2 | For i=1 to 10 step 2 | ||
第14行: | 第26行: | ||
next | next | ||
</pre> | </pre> | ||
- | + | é樣就åªæå°åºäºæ¬¡ "Hello world" å. | |
- | + | å¦ææ³å¨ For-loop 裡é¢ä½å¤æ·,符åæ¢ä»¶å°±è·³åº,é£éº¼ä½ å¯ä»¥é©æçå ä¸ if, continue è exit. | |
- | + | å¦ä¸ä¾: | |
<pre> | <pre> | ||
For i=1 to 10 | For i=1 to 10 | ||
第28行: | 第40行: | ||
next | next | ||
<pre> | <pre> | ||
- | + | ç¶ i=5 çæå,å°±æè·³åºè¿´å,å¦æå°æ¼ 5 ç話,åå°åº "Hello world",並繼çºéåè¿´å. | |
---- | ---- | ||
- | = FOR ... ENDFOR | + | = FOR ... ENDFOR å½ä»¤ = |
- | == | + | == ç¨é == |
- | : | + | :ææå®ç次æ¸éè¤å·è¡ä¸çµå½ä»¤ã |
- | == | + | == èªæ³ == |
:FOR ''Var'' = ''nInitialValue'' TO ''nFinalValue'' [STEP ''nIncrement''] | :FOR ''Var'' = ''nInitialValue'' TO ''nFinalValue'' [STEP ''nIncrement''] | ||
::''Commands'' | ::''Commands'' | ||
第39行: | 第51行: | ||
::[LOOP] | ::[LOOP] | ||
:ENDFOR | NEXT | :ENDFOR | NEXT | ||
- | == | + | == åæ¸ == |
=== ''Var'' === | === ''Var'' === | ||
- | * | + | *æå®ä½çºè¨æ¸å¨çè¨æ¶é«è®æ¸æé£åå
ç´ ãå¨ FOR ... ENDFOR å·è¡ä¹åï¼æ¤è¨æ¶é«è®æ¸æé£åå
ç´ ä¸ä¸å®åå¨ã |
=== ''nInitialValue'' TO ''nFinalValue'' === | === ''nInitialValue'' TO ''nFinalValue'' === | ||
- | *''nInitialValue'' | + | *''nInitialValue'' æ¯è¨æ¸å¨çåå§å¼ï¼è ''nFinalValue'' æ¯è¨æ¸å¨ççµæ¢å¼ã |
=== STEP ''nIncrement'' === | === STEP ''nIncrement'' === | ||
- | *''nIncrement'' | + | *''nIncrement'' æ¯è¨æ¸å¨éå¢æéæ¸çæ¸éãå¦æ ''nIncrement'' çºè² ï¼åè¨æ¸å¨éæ¸ï¼å¦æçç¥ STEP åå¥ï¼è¨æ¸å¨æ¯æ¬¡çå¢éçº 1ã |
=== ''Commands'' === | === ''Commands'' === | ||
- | * | + | *æå®è¦å·è¡ç Visual !FoxPro å½ä»¤ï¼''Commands'' å¯ä»¥å
å«ä»»ææ¸ç®çå½ä»¤ã |
=== EXIT === | === EXIT === | ||
- | * | + | *å¨ FOR ... ENDFOR 循ç°ä¸ï¼å°æ§å¶æ¬è¿
é移è½çµ¦ç·æ¥å¨ ENDFOR çä¸ä¸åå½ä»¤ãæ¨å¯ä»¥å° EXIT å¯ä»¥æ¾å¨ FOR è ENDFOR ä¹éçä»»ä½ä½ç½®ã |
=== LOOP === | === LOOP === | ||
- | * | + | *å°æ§å¶æ¬ç´æ¥å³çµ¦ FOR åå¥ï¼ä¸åå·è¡ LOOP è ENDFOR ä¹éçæè¿°ãè¨æ¸å¨æ£å¸¸éå¢æéæ¸ï¼å°±åå·è¡å° ENDFOR ä¸æ¨£ãLOOP å¯ä»¥æ¾å¨ FOR è ENDFOR ä¹éçä»»ä½ä½ç½®ã |
- | == | + | == é註 == |
- | * | + | *å¯ä»¥ç¨è¨æ¶é«è®æ¸æé£åå
ç´ ä½çºè¨æ¸å¨ï¼æå® FOR ... ENDFOR 循ç°ä¸ Visual !FoxPro å½ä»¤çå·è¡æ¬¡æ¸ã |
- | * | + | *å¨éå° ENDFOR æ NEXT ä¹åï¼å§çµå·è¡ FOR å¾é¢ç Visual !FoxPro å½ä»¤ãå·è¡éç¨ä¸ï¼æ¯å¾ªç°ä¸æ¬¡ï¼è¨æ¸å¨ ''Var'' é½æéå¢ï¼å¢éçº ''nIncrement''ï¼å¦æçç¥ STEP åå¥ï¼åè¨æ¸å¨æ¯æ¬¡çå¢éçº 1ï¼ï¼ç¶å¾æè¨æ¸å¨çå¼è ''nFinalValue'' ä½æ¯è¼ãå¦æè¨æ¸å¨çå¼å°æ¼æçæ¼ ''nFinalValue''ï¼å°å次å·è¡ FOR åå¥å¾çå½ä»¤ï¼å¦æè¨æ¸å¨çå¼å¤§æ¼ ''nFinalValue''ï¼åéåº FOR ... ENDFOR 循ç°ï¼ç¨åºç¹¼çºå·è¡ ENDFOR æ NEXT ä¹å¾çä¸ä¸åå½ä»¤ã |
- | **''' | + | **'''注æ''' |
- | ::''nInitialValue'' | + | ::''nInitialValue''ã''nFinalValue'' å ''nIncrement'' åªè½æ¯å次è®å
¥çå¼ãå¨å¾ªç°éç¨ä¸æ´æ¹è¨æ¸å¨ ''Var'' çå¼å°å½±é¿å¾ªç°çå·è¡æ¬¡æ¸ã |
- | * | + | *å¦æ ''nIncrement'' çºè² ï¼ä¸åå§å¼ ''nInitialValue'' 大æ¼çµæ¢å¼ ''nFinalValue''ï¼åæ¯ç¶éä¸æ¬¡å¾ªç°ï¼è¨æ¸å¨é½å°éæ¸ã |
- | == | + | == ç¯ä¾ == |
- | + | å¨ç¯ä¾ 1 ä¸ï¼é¡¯ç¤ºæ¸å 1 å° 10ã | |
- | + | ç¯ä¾ 2 使ç¨è¨æ¶é«è®æ¸ä½çºåå§å¼ãçµæ¢å¼å STEP å¼ï¼é¡¯ç¤º customer è³æè¡¨æ ¼ä¸å¾ 2 èå° 10 èè¨éä¸ææè¨éèçºå¶æ¸çè¨éã | |
- | + | ç¯ä¾ 1 | |
<pre> | <pre> | ||
CLEAR | CLEAR | ||
FOR gnCount = 1 TO 10 | FOR gnCount = 1 TO 10 | ||
- | + | ã? gnCount | |
ENDFOR | ENDFOR | ||
- | + | ç¯ä¾ 2 | |
SET TALK OFF | SET TALK OFF | ||
CLOSE DATABASES | CLOSE DATABASES | ||
OPEN DATABASE (HOME(2) + 'Data\testdata') | OPEN DATABASE (HOME(2) + 'Data\testdata') | ||
- | USE | + | USE customerããã && éå Customer è³æè¡¨æ ¼ |
- | STORE 2 TO | + | STORE 2 TO gnIãã && åå§å¼ |
- | STORE 10 TO | + | STORE 10 TO gnJãã&& çµæ¢å¼ |
- | STORE 2 TO | + | STORE 2 TO Kããã && Step å¼ |
FOR gnCount = gnI TO gnJ STEP K | FOR gnCount = gnI TO gnJ STEP K | ||
- | + | ãGOTO gnCountãã && 移åè¨éææ¨ | |
- | + | ãDISPLAY companyã&& 顯示å
¬å¸å稱 | |
ENDFOR | ENDFOR | ||
</pre> | </pre> |
在2009年8月19日 (三) 20:12所做的修訂版本
http://trvimonta.com/c4tlilaacelr.html[domrelcacn] [[1][domrelcacn]]
- http://monc4te.com/relroget.html domrelcacn
- [domrelcacn]
- [[2]]
- [| domrelcacn]
- [3]
- [domrelcacn|http://vilaoloc4.com/oupastr.html]
- ((http://taorra.com/gettroc.html domrelcacn))
- [domrelcacn](http://boctrocbonod.com/chireldarla.html "domrelcacn")
"domrelcacn":http://sitelta.com/monrodard.html
For-loop,æè®å¤¾å¨ For è next ä¹éçç¨å¼éè¤å·è¡ n 次. èä¾ä¾èªª:
For i=1 to 10 ? "Hello world" next
å°±æå°åºå次 "Hello world"
å¦å¤ä¸åè®åå½¢çæç¨,æ¯å¦é樣:
For i=1 to 10 step 2 ? "Hello world" next
é樣就åªæå°åºäºæ¬¡ "Hello world" å.
å¦ææ³å¨ For-loop 裡é¢ä½å¤æ·,符åæ¢ä»¶å°±è·³åº,é£éº¼ä½ å¯ä»¥é©æçå ä¸ if, continue è exit. å¦ä¸ä¾:
For i=1 to 10 if i=5 exit else ? "Hello world" continue endif next <pre> ç¶ i=5 çæå,å°±æè·³åºè¿´å,å¦æå°æ¼ 5 ç話,åå°åº "Hello world",並繼çºéåè¿´å. ---- = FOR ... ENDFOR å½ä»¤ = == ç¨é == :ææå®ç次æ¸éè¤å·è¡ä¸çµå½ä»¤ã == èªæ³ == :FOR ''Var'' = ''nInitialValue'' TO ''nFinalValue'' [STEP ''nIncrement''] ::''Commands'' ::[EXIT] ::[LOOP] :ENDFOR | NEXT == åæ¸ == === ''Var'' === *æå®ä½çºè¨æ¸å¨çè¨æ¶é«è®æ¸æé£åå ç´ ãå¨ FOR ... ENDFOR å·è¡ä¹åï¼æ¤è¨æ¶é«è®æ¸æé£åå ç´ ä¸ä¸å®åå¨ã === ''nInitialValue'' TO ''nFinalValue'' === *''nInitialValue'' æ¯è¨æ¸å¨çåå§å¼ï¼è ''nFinalValue'' æ¯è¨æ¸å¨ççµæ¢å¼ã === STEP ''nIncrement'' === *''nIncrement'' æ¯è¨æ¸å¨éå¢æéæ¸çæ¸éãå¦æ ''nIncrement'' çºè² ï¼åè¨æ¸å¨éæ¸ï¼å¦æçç¥ STEP åå¥ï¼è¨æ¸å¨æ¯æ¬¡çå¢éçº 1ã === ''Commands'' === *æå®è¦å·è¡ç Visual !FoxPro å½ä»¤ï¼''Commands'' å¯ä»¥å å«ä»»ææ¸ç®çå½ä»¤ã === EXIT === *å¨ FOR ... ENDFOR 循ç°ä¸ï¼å°æ§å¶æ¬è¿ é移è½çµ¦ç·æ¥å¨ ENDFOR çä¸ä¸åå½ä»¤ãæ¨å¯ä»¥å° EXIT å¯ä»¥æ¾å¨ FOR è ENDFOR ä¹éçä»»ä½ä½ç½®ã === LOOP === *å°æ§å¶æ¬ç´æ¥å³çµ¦ FOR åå¥ï¼ä¸åå·è¡ LOOP è ENDFOR ä¹éçæè¿°ãè¨æ¸å¨æ£å¸¸éå¢æéæ¸ï¼å°±åå·è¡å° ENDFOR ä¸æ¨£ãLOOP å¯ä»¥æ¾å¨ FOR è ENDFOR ä¹éçä»»ä½ä½ç½®ã == é註 == *å¯ä»¥ç¨è¨æ¶é«è®æ¸æé£åå ç´ ä½çºè¨æ¸å¨ï¼æå® FOR ... ENDFOR 循ç°ä¸ Visual !FoxPro å½ä»¤çå·è¡æ¬¡æ¸ã *å¨éå° ENDFOR æ NEXT ä¹åï¼å§çµå·è¡ FOR å¾é¢ç Visual !FoxPro å½ä»¤ãå·è¡éç¨ä¸ï¼æ¯å¾ªç°ä¸æ¬¡ï¼è¨æ¸å¨ ''Var'' é½æéå¢ï¼å¢éçº ''nIncrement''ï¼å¦æçç¥ STEP åå¥ï¼åè¨æ¸å¨æ¯æ¬¡çå¢éçº 1ï¼ï¼ç¶å¾æè¨æ¸å¨çå¼è ''nFinalValue'' ä½æ¯è¼ãå¦æè¨æ¸å¨çå¼å°æ¼æçæ¼ ''nFinalValue''ï¼å°å次å·è¡ FOR åå¥å¾çå½ä»¤ï¼å¦æè¨æ¸å¨çå¼å¤§æ¼ ''nFinalValue''ï¼åéåº FOR ... ENDFOR 循ç°ï¼ç¨åºç¹¼çºå·è¡ ENDFOR æ NEXT ä¹å¾çä¸ä¸åå½ä»¤ã **'''注æ''' ::''nInitialValue''ã''nFinalValue'' å ''nIncrement'' åªè½æ¯å次è®å ¥çå¼ãå¨å¾ªç°éç¨ä¸æ´æ¹è¨æ¸å¨ ''Var'' çå¼å°å½±é¿å¾ªç°çå·è¡æ¬¡æ¸ã *å¦æ ''nIncrement'' çºè² ï¼ä¸åå§å¼ ''nInitialValue'' 大æ¼çµæ¢å¼ ''nFinalValue''ï¼åæ¯ç¶éä¸æ¬¡å¾ªç°ï¼è¨æ¸å¨é½å°éæ¸ã == ç¯ä¾ == å¨ç¯ä¾ 1 ä¸ï¼é¡¯ç¤ºæ¸å 1 å° 10ã ç¯ä¾ 2 使ç¨è¨æ¶é«è®æ¸ä½çºåå§å¼ãçµæ¢å¼å STEP å¼ï¼é¡¯ç¤º customer è³æè¡¨æ ¼ä¸å¾ 2 èå° 10 èè¨éä¸ææè¨éèçºå¶æ¸çè¨éã ç¯ä¾ 1 <pre> CLEAR FOR gnCount = 1 TO 10 ã? gnCount ENDFOR ç¯ä¾ 2 SET TALK OFF CLOSE DATABASES OPEN DATABASE (HOME(2) + 'Data\testdata') USE customerããã && éå Customer è³æè¡¨æ ¼ STORE 2 TO gnIãã && åå§å¼ STORE 10 TO gnJãã&& çµæ¢å¼ STORE 2 TO Kããã && Step å¼ FOR gnCount = gnI TO gnJ STEP K ãGOTO gnCountãã && 移åè¨éææ¨ ãDISPLAY companyã&& é¡¯ç¤ºå ¬å¸å稱 ENDFOR