Hi
Forgive me but I am doing a proof of concept to determine if my company should buy this product.
I was trying to have a variable (zModalResult) populated with ModalResult depending on which button was pushed on a dialog.
This variable is then used to drive the logic that happens after that.
I have a problem that zModalResult is not being populated by my logic below.
Can you please advise what I am doing wrong. Many many thanks
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
Let>IGNORESPACES=1
//Number of millisecs between keystrokes
Let>SK_DELAY=20
Dialog>Dialog1
object Dialog1: TForm
Left = 244
Top = 135
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 194
ClientWidth = 732
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -17
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 144
TextHeight = 20
object Label1: TLabel
Left = 152
Top = 32
Width = 345
Height = 36
Caption = 'Select The Business Unit'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -30
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object MSButton1: tMSButton
Left = 67
Top = 99
Width = 238
Height = 25
Caption = 'Firstflex'
TabOrder = 8
DoBrowse = False
BrowseStyle = fbOpen
ModalResult = 10
end
object MSButton2: tMSButton
Left = 379
Top = 99
Width = 238
Height = 25
Caption = 'Sitemate'
TabOrder = 9
DoBrowse = False
BrowseStyle = fbOpen
ModalResult = 20
end
end
EndDialog>Dialog1
Show>Dialog1,1
SetDialogObjectVisible>Dialog1,,0
Let>zModalResult = ModalResult
EndDialog>Dialog1
Dialog>Dialog2
object Dialog2: TForm
Left = 244
Top = 135
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 194
ClientWidth = 732
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -17
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 144
TextHeight = 20
object Label1: TLabel
Left = 152
Top = 32
Width = 345
Height = 36
Caption = 'Firstflex Selected'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -30
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
end
EndDialog>Dialog2
If>zModalResult = 10
Gosub ShowDialog2
Else
Endif
SRT>ShowDialog2
Show>Dialog2,1
END>ShowDialog2
How to build logic in buttons on a dialog
Moderators: Dorian (MJT support), JRL
Re: How to build logic in buttons on a dialog
Use Dialog handlers.
Code: Select all
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
Let>IGNORESPACES=1
//Number of millisecs between keystrokes
Let>SK_DELAY=20
Dialog>Dialog2
object Dialog2: TForm
Left = 613
Top = 189
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 126
ClientWidth = 476
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 99
Top = 21
Width = 149
Height = 25
Margins.Left = 2
Margins.Top = 2
Margins.Right = 2
Margins.Bottom = 2
Caption = ''
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -20
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
end
EndDialog>Dialog2
Dialog>Dialog1
object Dialog1: TForm
Left = 613
Top = 189
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 126
ClientWidth = 476
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 99
Top = 21
Width = 219
Height = 25
Margins.Left = 2
Margins.Top = 2
Margins.Right = 2
Margins.Bottom = 2
Caption = 'Select The Business Unit'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -20
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
object MSButton1: tMSButton
Left = 44
Top = 64
Width = 154
Height = 17
Margins.Left = 2
Margins.Top = 2
Margins.Right = 2
Margins.Bottom = 2
Caption = 'Firstflex'
ModalResult = 10
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 246
Top = 64
Width = 155
Height = 17
Margins.Left = 2
Margins.Top = 2
Margins.Right = 2
Margins.Bottom = 2
Caption = 'Sitemate'
ModalResult = 20
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
AddDialogHandler>Dialog1,msButton1,OnClick,ShowDialog2(Firstflex)
AddDialogHandler>Dialog1,msButton2,OnClick,ShowDialog2(Sitemate)
Show>Dialog1,1
SRT>ShowDialog2
SetDialogProperty>Dialog2,Label1,Caption,%ShowDialog2_var_1% Selected
Show>Dialog2,1
END>ShowDialog2