我不知道我的标题应该是什么,请随意编辑我的帖子,如果你能想出更好的东西,可以修改它。
在使用Foxpro方面没有多少可用的资源,我想要做的是了解正在发生的事情。
lldisdead=.t.
Select .f. as chkbox, * from a_counties ;
order by cn_area, cn_desc ;
into dbf (StrTmpFile1)
scan while !EOF()
IF ChkBox
selected_some_cnty = .t
endif
endscan以下是我的理解:
IF CHKBOX是什么意思?
它是否表示如果列CHKBOX不是null,则执行以下操作,否则,不执行任何操作。
编辑:添加附加代码
发布于 2019-01-02 14:29:29
If chkBox在VFP中,指:
if (chkBox)也是在所有其他众所周知的语言,如C,C++,C#,Java,Go,Dart,Ruby,.你可以给它命名--有些语言括号是强制性的,有些则不是。它的简单意思是“如果 chkBox是真”。有时你会把它写成:
If chkBox = .T.像这样:
If chkBox == true与其他语言一样,但它比需要的要详细,经验丰富的开发人员不会那样编写它(毕竟,像“如果真是真”这样的写作是尴尬的,简单地说“如果是真的”就行了)。
这是用代码中的注释来解释的:
* Initialize a memory variable named lldisdead as .t. (true)
lldisdead=.t.
* Select some fields into a table named m.StrTmpFile1
* StrTmpFile1 is a variable holding a string name of the table
* selecting all fields of a_counties table
* plus a boolean field named "chkBox" which is initially
* filled with .F. (false) value
Select .f. as chkbox, * from a_counties ;
order by cn_area, cn_desc ;
into dbf (StrTmpFile1)
* select's result table is table open in the current
* work area and by default located on first record.
* scanning the whole table
* with an unnecessary "while !EOF()" addition
* Default scope of scan is until EOF
scan while !EOF()
* Checking if chkBox field has a value of true
IF ChkBox
* if it has, than set "selected_some_cnty" memory variable to true
selected_some_cnty = .t
endif
endscan话虽如此,本部分:
scan while !EOF()
IF ChkBox
selected_some_cnty = .t.
endif
endscan可以写成:
scan
IF ChkBox
selected_some_cnty = .t
endif
endscan此外:
LOCATE FOR ChkBox
selected_some_cnty = !EOF() 但是,由于我们知道所有的chkBox值都是.F.,所以这段代码是完全无用的,可以一起删除。
发布于 2019-01-02 03:17:09
从SQL查询中,数据将根据"StrTmpFile1“变量所指向的名称进入物理表。还要注意,这个select语句的第一列是".f. as ChkBox“。因此,这是使用始终为False的前导列(因此是.f)来准备查询中的每条记录。
Select .f. as chkbox, * from a_counties ;
order by cn_area, cn_desc ;
into dbf (StrTmpFile1)现在,我怀疑还有其他一些用户界面操作正在使用这个结果表,比如在表单中的网格中显示,以及允许列上的复选框让用户选择一个或多个条目来做进一步的事情。
在上述选择(同样,推测意图)之后,它将遍历循环,只查找表中的"ChkBox“列被设置为true的记录,并将标志设置为.t。某些东西是被选中的。
总的来说,这是一个非常新手的方法,但这是一个不同的问题。如果标记为
select (the table)
Locate for ChkBox
selected_some_cnty = found()希望这对你有帮助,如果你需要更多的澄清,请发表评论。
https://stackoverflow.com/questions/54000248
复制相似问题