; --------------------------------------------------------------------------------
; @Title: Example for dialog with an included output area for text
; @Description: Shows a dialog with area
; @Keywords: practice, dialog, area
; @Author: SME
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: dialog_area.cmm 8581 2015-08-17 14:15:21Z wwbenayed $


  LOCAL &linecount
  &linecount=0.

;Create an area which is invisible ...

  AREA.Create testarea 40. 100.
  PRINT "---------1---------2---------3---------4"
  PRINT "40 chars wide and 100 lines in height"

;and attach it to a dialog with a simple close button
;The dialog is 40 chars wide and includes 10 lines of text

  WINPOS , , 40. 10.
  DIALOG.AREA testarea
  (
           HEADER "DIALOG.AREA example"

           POS 0.25 0. 20. 1.
LINENUM:   dyntext "Lines printed: 0."

           POS 0.25 1. 11. 1.
           BUTTON "Print some text"
           (
              LOCAL &tmp
              &tmp=FORMAT.DECIMAL(3,&linecount)
              AREA.Select testarea
              PRINT "&tmp: Some more text in the area"
              &linecount=&linecount+1.
              DIALOG.SET LINENUM "Lines printed: &linecount"
              ; enable clean button
              DIALOG.Enable BTN_CLEAN
           )

           POS 12. 1. 10. 1.
BTN_CLEAN: BUTTON "Clean area"
           (
              AREA.CLEAR testarea
              &linecount=0.
              DIALOG.set LINENUM "Lines printed: &linecount"
              ; disable clean button
              DIALOG.Disable BTN_CLEAN
           )

           ; close button
           POS 28.5 1. 8. 1.
           BUTTON "Close" "goto closeDialog"

           ; handle [X] and Escape
           CLOSE "goto closeDialog"
  )

;initialy disable clean button
  DIALOG.DISABLE BTN_CLEAN
  STOP

;common jumplabel for closing the dialog and ending script
closeDialog:
  DIALOG.END

ENDDO
