在做任务时我遇到了问题,我不知道如何从组合框中获得值作为变量,我已经阅读了很多文档,但没有找到解决方案,也许你可以建议我。
DEFINE VARIABLE StateBox AS CHARACTER FORMAT "X(256)":U
LABEL "Pick a Satete"
VIEW-AS COMBO-BOX INNER-LINES 5
DROP-DOWN-LIST
SIZE 16 BY 1 NO-UNDO.
DEFINE FRAME StateCombo
StateBox
WITH CENTERED ROW 4.
FOR EACH State NO-LOCK BREAK BY State.StateName:
StateBox:ADD-LAST(State.StateName) IN FRAME StateCombo.
END.
vStateText = (SCREEN-VALUE:StateBox). //ERROR
ENABLE StateBox WITH FRAME StateCombo.
APPLY "VALUE-CHANGED" TO StateBox IN FRAME StateCombo.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. //COMBO-BOX CREATED
我尝试了SCREEN-VALUE, STREAM,我想得到一个解决方案
vStateText = (SCREEN-VALUE:StateBox). //ERROR
这很接近。SCREEN-VALUE
是文档中的一个属性。引用属性的正确语法是先有句柄/事物,然后是属性。所以StateBox:SCREEN-VALUE
应该是正确的顺序。
你应该
WAIT-FOR GO OF CURRENT-WINDOW.
就像Peter说的,它必须是StateBox:SCREEN-VALUE,不需要APPLY VALUE-CHANGED,所以这个就可以了:
ENABLE StateBox WITH FRAME StateCombo.
WAIT-FOR GO OF CURRENT-WINDOW. //COMBO-BOX CREATED
DEFINE VARIABLE vStateText AS CHARACTER NO-UNDO .
vStateText = (StateBox:SCREEN-VALUE). //ERROR
MESSAGE vStateText
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
但是由于StateBox也是一个CHARACTER-Variable,所以您不需要额外的变量vStateText:
ENABLE StateBox WITH FRAME StateCombo.
WAIT-FOR GO OF CURRENT-WINDOW. //COMBO-BOX CREATED
ASSIGN StateBox .
MESSAGE StateBox
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
不带=操作符的ASSIGN语句将把屏幕值赋给相同的命名变量。