109 lines
2.6 KiB
Plaintext
109 lines
2.6 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: Example for dialog with Edit fields
|
|
; @Description: Shows a dialog with edit fields
|
|
; @Keywords: dialog, edit, hotedit, practice
|
|
; @Author: REI
|
|
; @Copyright: (C) 1989-2021 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Id: dialog_hotedit.cmm 18691 2021-12-15 18:51:36Z rweiss $
|
|
|
|
|
|
DIALOG
|
|
(
|
|
HEADER "HOTEDIT Demo"
|
|
; define dialog width by inserting empty text: POS 0. 0. <width> 1.
|
|
POS 0. 0. 27. 1.
|
|
TEXT ""
|
|
|
|
POS 1. 0. 25. 1.
|
|
;EDIT: TextA_UpdateHook is called when EDIT control TextA looses input focus
|
|
TEXT "EDIT:"
|
|
TextA: EDIT "type here" "GOSUB OnUpdate_TextA"
|
|
TEXT "result:"
|
|
TextAOut: EDIT "type here" ""
|
|
TEXT ""
|
|
|
|
;HOTEDIT: TextB_UpdateHook is called when EDIT control TextB's contents change
|
|
TEXT "HOTEDIT:"
|
|
TextB: HOTEDIT "type here" "GOSUB OnUpdate_TextB"
|
|
TEXT "result:"
|
|
TextBOut: EDIT "type here" ""
|
|
TEXT ""
|
|
|
|
TEXT "Type address here:"
|
|
TextC: HOTEDIT "" "GOSUB OnUpdate_TextC"
|
|
TEXT "result:"
|
|
TextCOut: EDIT "no input" ""
|
|
|
|
|
|
;buttons OK (Default) and Cancel
|
|
POS 8. 15. 10. 1.
|
|
DEFBUTTON "OK" "GOSUB OnClose"
|
|
|
|
;dialog open event
|
|
INIT
|
|
(
|
|
;disable output fields
|
|
DIALOG.Disable TextAOut
|
|
DIALOG.Disable TextBOut
|
|
DIALOG.Disable TextCOut
|
|
)
|
|
;dialog close event
|
|
CLOSE "GOSUB OnClose"
|
|
;dialog subroutines
|
|
SUBROUTINE OnUpdate_TextA
|
|
(
|
|
DIALOG.Set TextAOut DIALOG.STRing(TextA)
|
|
)
|
|
SUBROUTINE OnUpdate_TextB
|
|
(
|
|
DIALOG.Set TextBOut DIALOG.STRing(TextB)
|
|
)
|
|
SUBROUTINE OnUpdate_TextC
|
|
(
|
|
&text=DIALOG.STRing(TextC)
|
|
IF "&text"==""
|
|
(
|
|
DIALOG.Set TextCOut "no input"
|
|
RETURN
|
|
)
|
|
IF (STRing.LENgth("&text")==1)&&(STRing.MID("&text",0,1)!="0")
|
|
(
|
|
DIALOG.Set TextCOut "start with ""0x"""
|
|
RETURN
|
|
)
|
|
IF (STRing.LENgth("&text")>=2)&&(STRing.MID("&text",1,1)!="x")
|
|
(
|
|
DIALOG.Set TextCOut "start with ""0x"""
|
|
RETURN
|
|
)
|
|
IF STRing.LENgth("&text")==2
|
|
(
|
|
DIALOG.Set TextCOut "so far so good..."
|
|
RETURN
|
|
)
|
|
&index=2
|
|
WHILE &index<STRing.LENgth("&text")
|
|
(
|
|
&digit=STRing.MID("&text",&index,1)
|
|
IF !STRing.FIND("&digit","0123456789ABCDEFabcdef")
|
|
(
|
|
DIALOG.Set TextCOut "this is not a valid address"
|
|
RETURN
|
|
)
|
|
&index=&index+1
|
|
IF (&index>10.)
|
|
(
|
|
DIALOG.Set TextCOut "address too long"
|
|
RETURN
|
|
)
|
|
)
|
|
DIALOG.Set TextCOut "&text"
|
|
)
|
|
SUBROUTINE OnClose
|
|
(
|
|
DIALOG.END
|
|
)
|
|
)
|
|
ENDDO
|