2.Visual FoxPro記憶體變數顯示和清除命令

weixin_34126215發表於2014-07-15

一、記憶體變數的顯示相關命令:  

1. LIST MEMORY[LIKE<萬用字元>][TO PRINTER |TO FILE<檔名>]

2. DISPLAY MEMORY[LIKE<萬用字元>][TO PRINTER | FILE<檔名>]


(1.) LIST MEMORY[LIKE<萬用字元>][TO PRINTER |TO FILE<檔名>]
 

    [LIKE<萬用字元>]                                                 

說明:只顯示與萬用字元相匹配的記憶體變數,萬用字元包括*和?

              *任意多個字元

             ?任意一個字元

     [ TO  PRINTER]                                                        

說明:顯示變數同時送往印表機

    [ TO FILE<檔名>]

說明:顯示變數同時送到一個指定的檔案,這個檔案時以.txt為副檔名的文字檔案。
              另外用LIST MEMORY顯示變數時,如果一屏顯示不完,它會分屏顯示。   

1:使用store命令給多個一、LIST MEMORY[LIKE<萬用字元>]

例一:變數賦值,使用   [LIKE<*>] 列出第一個字元是c開頭的所有變數。

store "http://www.baidu.com" to china,chinese,hello,red
list memory like c* 

執行結果:

************************************************************

例二:

使用store命令給多個變數賦值,使用   [LIKE<? / * >]  列出第一個字元是任意,第二個字元是e,後面任意字元的所有變數。

store "http://www.baidu.com" to china,chinese,hello,red
list memory like ?e*

執行結果:

****************************************************************

例三:

使用store命令給多個變數賦值,使用   [LIKE<? / * >] 列出前兩個字元任意,第三個字元是i,後面任意字元的所有變數。

store "http://www.baidu.com" to china,chinese,hello,red
list memory like ??i*

執行結果:


****************************************************************

2、LIST MEMORY[LIKE<萬用字元>][TO FILE<檔名>]

將查詢的變數資訊寫入到指定的txt檔案裡:

 

store "http://www.baidu.com" to china,chinese,hello,red

list memory like c* to file "d:\hello.txt"

 執行結果:

 


 

3、LIST MEMORY[LIKE<萬用字元>][TO PRINTER ]

顯示第一個字元是c,的所有變數的同時,傳送到印表機進行列印。

store "http://www.baidu.com" to china,chinese,hello,red

list memory like c* to PRINTER

執行結果:

印表機列印內容如下:

**************************************

 *********************************************


(2.)DISPLAY MEMORY[LIKE<萬用字元>][TO PRINTER | FILE<檔名>]

 

display memory命令和list memory用法非常相似,唯一不同之處在於:

      當顯示命令時,如果顯示命令過多,list memory 命令會自動向上滾動

而display memory 命令會一次顯示一屏,然後暫停,等待按下任意鍵繼續顯示下一屏。

舉例子:使用display命令顯示以a開頭的所有變數。

store "星雲" to air,b,c,apple
display memory like a*

 

執行結果如下:

 


 

store "星雲" to air,b,c,apple
display memory like a* to file "d:\china.txt"

 

 執行結果:


 

二、記憶體變數的清除相關命令: 

 

記憶體變數的清除

1.CLEAR MEMORY

清除所有的記憶體變數

2.RELEASE <記憶體變數名錶>

清除指定的記憶體變數

3.RELEASE ALL [EXTENDED]

清除所有記憶體變數,在人機會話的狀態下其作用與第一種格式相同,

但是如果出在程式中則加上短語EXTENDED ,否則不能清除共同變數。

4.RELEASE ALL

[LIKE<萬用字元>|EXCEPT<萬用字元>]

選用LIKE短語清除與萬用字元相匹配的變數,

選用EXCEPT短語清除與萬用字元不匹配的變數。

舉例:

清除以c開頭的變數

 

store "http://www.baidu.com" to hello,china,chinese,a,b,c,d
?"記憶體變數清除前"
?hello
?china
?chinese
?a
?b
?c
?d
release all like c* 
?"記憶體變數清除後"
?hello
?china
?chinese
?a
?b
?c
?d

 

 

 

執行截圖:


 

 


 

 清除hello變數:

store "http://www.baidu.com" to hello,china,chinese,a,b,c,d
?"記憶體變數清除前"
?hello
?china
?chinese
?a
?b
?c
?d
release all like c* 
?"記憶體變數清除後"
?hello
?china
?chinese
?a
?b
?c
?d
release hello
?hello

 

執行截圖:


 


 

清除除了a之外的所有變數:

store "http://www.baidu.com" to hello,china,chinese,a,b,c,d
?"記憶體變數清除前"
?hello
?china
?chinese
?a
?b
?c
?d
release all like c*
?"記憶體變數清除後"
?hello
?china
?chinese
?a
?b
?c
?d
release hello
?hello
release all except a*
?a
?b
?d

 

執行截圖:


 


 

清除所有變數:

store "http://www.baidu.com" to hello,china,chinese,a,b,c,d
?"記憶體變數清除前"
?hello
?china
?chinese
?a
?b
?c
?d
release all like c*
?"記憶體變數清除後"
?hello
?china
?chinese
?a
?b
?c
?d
release hello
?hello
release all except a*
?a
?b
?d
clear memory
?a

執行截圖:

 


 

 


 

相關文章