Download Free Tools for Tally ERP
FREE utilities for Tally Accounting Software

Wednesday, February 7, 2007

Example 6: Adding BUTTONs in TDL Form

This programs illustrates the use of BUTTON definition and OPTION attribute

[#Menu: GatewayOfTally]
Add: Item: MyOption : Display: rptReport



;;This report uses a Local variable lChooseHeight which is initially set to "No"
[Report: rptReport]
Add: Form: frmForm
Add: Variable: lChooseHeight
Set: lChooseHeight : No



;;When the logical condition is true, the modified definition becomes the part of the original definition
[Form: frmForm]
Add: Part: prtPart
Add: Button : btnButton1
Option : Small HelloWorld Form: Not #lChooseHeight
Option : Full HelloWorld Form: #lChooseHeight



;;Optional Definitions start with exclamation sign !
[!Form: Small HelloWorld Form]
Background: Yellow
Set: fldField1: This is Yellow
Width: 50% screen
Height: 50% screen



;;Optional Definitions start with exclamation sign !
[!Form: Full HelloWorld Form]
Background: Green
Set: fldField1: This is Green
Width: 100% screen
Height: 100% screen



;;Local Variable definition
[Variable: lChooseHeight]
Type: Logical



[Part: prtPart]
Add: Line : lnLine1



[Line: Lnline1]
Add: Field: fldField1



[Field: fldField1]
Set as: "Press F4 key to change the Form-size and color"



;;Defining a Button with F4 as the shortcut key.
;;When user presses F4 key, the value of variable lChooseHeight changes
;;This will replace the original Form definition with the modified definition
;;===========================================================================
[Button: btnButton1]
Key: F4
Action: Set: lChooseHeight: Not #lChooseHeight


Notes:
1) The form "frmForm" uses a button which is displayed in the Button panel on the right-side of the screen.
2) The Option Attribute provides a means to substitue the original definition with modified definition. In the above code, two optional definitions have been used. The syntax of Option keyword is :-
Syntax: Option : <Modified Definition>: <Logical condition>


Click here to download the Example 6 compiled file and the source-code.
Tally; Tally Developer and Tally Definition Language are trademarks or registered trademarks of "Tally Solutions", Bangalore.