この例では、リストを定義して単純な値とピックリストの両方でエントリーを追加する方法を示すプロパティ・シートを作成します。
プロパティ・シートの例のコード
このコードをコピーしてフォームに貼り付け、フォームをコンパイルして実行してください。
FUNCTION options(*DIRECT)BEGIN_COM height(254) left(375) top(161) width(272)DEFINE_COM class(#PRIM_PROP) name(#PROP_1) busyupdatesofparent(True) columnbuttons(False) displayposition(1) dragstyle(Aggregated) height(153) left(16) parent(#COM_OWNER) rowheight(15) tabposition(1) top(16) visualstyleofparent(False) width(233)DEFINE_COM class(#PRIM_PHBN) name(#PHBN_1) caption('Show Properties') displayposition(2) left(16) parent(#COM_OWNER) tabposition(2) top(184) width(105)DEFINE_COM class(#PRIM_PRCL) name(#PRCL_1) displayposition(1) parent(#PROP_1) source(#PROPERTY) width(50)DEFINE_COM class(#PRIM_PRCL) name(#PRCL_2) displayposition(2) parent(#PROP_1) source(#VALUE) width(20) widthtype(Remainder)* Data class definitions for the property sheet* Define #givename data class based on the repository field #givenameDEFINE_COM class(#GIVENAME) name(#GIVENAME)* Define #surname data class based on the elemental data class #PRIM_ALPH (string)DEFINE_COM class(#SURNAME) name(#SURNAME)* Define #salary data class based on the repository field #salaryDEFINE_COM class(#SALARY) name(#SALARY)* Define #expenses data class based on the elemental data class #PRIM_NMBR (number)DEFINE_COM class(#PRIM_ALPH) name(#OPTIONSA)* Define #optionsn data class based on the elemental data class #PRIM_NMBR (number)DEFINE_COM class(#PRIM_NMBR) name(#OPTIONSN) length(9)* Pick list and pick list item definitions for the property sheet* pick list counter (index)DEFINE_COM class(#STD_COUNT) name(#CUR_PLIST)* pick list item counter (index)DEFINE_COM class(#STD_COUNT) name(#CUR_PITEM)* collection of pick lists (shown inside the property sheet)DEFINE_COM class(#PRIM_KCOL) name(#PL_COL) collects(#PRIM_PKLT) keyedby(#STD_COUNT)* collection of pick list itemsDEFINE_COM class(#PRIM_KCOL) name(#PI_COL) collects(#PRIM_PKIT) keyedby(#STD_COUNT)* Add new picklistSUBROUTINE name(ADD_PLIST)* give the new pick list an index numberCHANGE field(#CUR_PLIST) to('#Cur_PList + 1')ENDROUTINE* Add new picklist itemSUBROUTINE name(ADD_PITEM) parms((#PROPERTY *RECEIVED) (#VALUE *RECEIVED))* give the new pick list item an index numberCHANGE field(#CUR_PITEM) to('#Cur_PItem + 1')* Set the caption and the value of the item plus assign it into the picklistSET com(#PI_Col<#Cur_PItem>) caption(#property) default(True) value(#value) parent(#PL_COL<#Cur_PList>)ENDROUTINE* fill the property sheetEVTROUTINE handling(#prop_1.Initialize) options(*NOCLEARMESSAGES *NOCLEARERRORS)* set values for the entriesCHANGE field(#GIVENAME) to('''Veronica''')SET com(#surname) value('Brown')CHANGE field(#SALARY) to(60000)* Add an alphanumeric entry based on the data class of the field - First NameCHANGE field(#PROPERTY) to('''First Name''')CHANGE field(#VALUE) to(#GIVENAME)ADD_ENTRY to_list(#PROP_1)SET com(#prop_1.CurrentItem) dataclass(#givename)* Add an alphanumeric entry based on the data class of the field - SurnameCHANGE field(#PROPERTY) to('''Surname''')CHANGE field(#VALUE) to(#surname)ADD_ENTRY to_list(#PROP_1)SET com(#prop_1.CurrentItem) dataclass(#surname)* Add a numeric entry based on the data class of the field - SalaryCHANGE field(#PROPERTY) to('''Salary''')CHANGE field(#VALUE) to('#SALARY.TEXT')ADD_ENTRY to_list(#PROP_1)SET com(#prop_1.CurrentItem) dataclass(#salary)* Create picklist with three items and add it to an alphanumeric entry - Alpha OptionsEXECUTE subroutine(ADD_PLIST)EXECUTE subroutine(ADD_PITEM) with_parms('A' 'option A')EXECUTE subroutine(ADD_PITEM) with_parms('B' 'option B')EXECUTE subroutine(ADD_PITEM) with_parms('C' 'option C')CHANGE field(#PROPERTY) to('''Alpha Options''')SET com(#optionsa) picklist(#PL_COL<#Cur_PList>)CHANGE field(#VALUE) to('#OPTIONSA.TEXT')ADD_ENTRY to_list(#PROP_1)SET com(#prop_1.CurrentItem) dataclass(#optionsa)* Create picklist with three items and add it to a numeric entry - Numeric OptionsEXECUTE subroutine(ADD_PLIST)EXECUTE subroutine(ADD_PITEM) with_parms('1001' '1001')EXECUTE subroutine(ADD_PITEM) with_parms('220' '220')EXECUTE subroutine(ADD_PITEM) with_parms('34' '34')CHANGE field(#PROPERTY) to('''Numeric Options''')SET com(#optionsn) picklist(#PL_COL<#Cur_PList>)CHANGE field(#VALUE) to('#OPTIONSN.TEXT')ADD_ENTRY to_list(#PROP_1)SET com(#prop_1.CurrentItem) dataclass(#optionsn)ENDROUTINEEVTROUTINE handling(#PHBN_1.Click)USE builtin(MESSAGE_BOX_ADD) with_args('First name:' #GIVENAME)USE builtin(MESSAGE_BOX_ADD) with_args('Surname:' #SURNAME)USE builtin(MESSAGE_BOX_ADD) with_args('Salary:' #SALARY)USE builtin(MESSAGE_BOX_ADD) with_args('Alpha Options:' #OPTIONSA.TEXT)USE builtin(MESSAGE_BOX_ADD) with_args('Numeric Options:' #OPTIONSN.TEXT)USE builtin(MESSAGE_BOX_SHOW) with_args(' ' ' ' ' ' 'Returned Values')ENDROUTINEEND_COM
プロパティ・シートに関する注意事項
値の割り当て
#Value列の値を設定する場合に、エントリーのデータ・クラスが#PRIM_ALPH、#PRIM_NMBR、または数値フィールドに基づく場合は、コンポーネントのTextプロパティを使用する必要があります。
CHANGE field(#PROPERTY) to('''Salary''')CHANGE field(#VALUE) to('#SALARY.TEXT')ADD_ENTRY to_list(#PROP_1)SET com(#prop_1.CurrentItem) dataclass(#salary)
値を返す
プロパティ・シートから値を返す場合は、#PRIM_ALPHまたは#PRIM_NMBRに基づくデータ・クラスのValueプロパティまたはTextプロパティを使用する必要があります。
USE builtin(MESSAGE_BOX_ADD) with_args('First name: ' #GIVENAME)USE builtin(MESSAGE_BOX_ADD) with_args('Last name: ' #SURNAME)USE builtin(MESSAGE_BOX_ADD) with_args('Salary: ' #SALARY)USE builtin(MESSAGE_BOX_ADD) with_args('Alpha Options: ' #OPTIONSA.TEXT)USE builtin(MESSAGE_BOX_ADD) with_args('Numeric Options: ' #OPTIONSN.TEXT)
