2.Visual FoxPro内存变量显示和清除命令

一、内存变量的显示相关命令:  

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

运行截图:



原文地址:https://www.cnblogs.com/xingyunblog/p/3844331.html