Dialog Edit box returning NO_SUCH_PROPERTY

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
unclejoe
Newbie
Posts: 14
Joined: Wed Nov 06, 2002 10:43 am
Location: Poughkeepsie, NY

Dialog Edit box returning NO_SUCH_PROPERTY

Post by unclejoe » Fri Sep 17, 2010 4:21 pm

I have a test dialog with an EditBox and two buttons. The EditBox Text is initialized. If I click the Ok button and Get the Text Property, the result is ok. If I modify the contents of the Edit Box, I get the NO_SUCH_PROPERTY result for the Text Property. I am at a loss as to why.

The code follows:

Code: Select all


Dialog>Dialog1
object Dialog1: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 431
  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 Edit1: TEdit
    Left = 9
    Top = 13
    Width = 248
    Height = 21
    TabOrder = 0
    Text = 'Enter your Text'
  end
  object MSButton1: tMSButton
    Left = 41
    Top = 111
    Width = 75
    Height = 25
    Caption = 'Ok'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 180
    Top = 116
    Width = 75
    Height = 25
    Caption = 'Quit'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,EditBox
AddDialogHandler>Dialog1,MSButton2,OnClick,Exit

Show>Dialog1,r

SRT>EditBox
GetDialogProperty>Dialog1,Edit1,Text,dlgValue
Let>MSG_STAYONTOP=0
Let>MSG_CENTERED=1
Let>text=%dlgValue%
Message>text
END>EditBox

SRT>Exit
  exit
END>Exit

[/code]
Joe Mueller
[email protected]

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Sep 17, 2010 5:41 pm

Hi Joe,

You need to set your text gathering variable to something other than the word "text". "Text" is the name of the property you are trying to retrieve and apparently there is a little interference going on.

Or another plan is laid out in the Alternate_EditBox subroutine below. you have already set the edit box text to a the variable "dlgValue". Why set it to another variable? This accomplishes the same thing. Don't use the Dialog's edit box property as a variable name.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 431
  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 Edit1: TEdit
    Left = 9
    Top = 13
    Width = 248
    Height = 21
    TabOrder = 0
    Text = 'Enter your Text'
  end
  object MSButton1: tMSButton
    Left = 41
    Top = 111
    Width = 75
    Height = 25
    Caption = 'Ok'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 180
    Top = 116
    Width = 75
    Height = 25
    Caption = 'Quit'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,EditBox
AddDialogHandler>Dialog1,MSButton2,OnClick,Exit

Show>Dialog1,r

SRT>EditBox
GetDialogProperty>Dialog1,Edit1,Text,dlgValue
Let>MSG_STAYONTOP=0
Let>MSG_CENTERED=1
Let>vText=%dlgValue%
Message>vText
END>EditBox

SRT>Alternate_EditBox
GetDialogProperty>Dialog1,Edit1,Text,dlgValue
Let>MSG_STAYONTOP=0
Let>MSG_CENTERED=1
Message>dlgValue
END>Alternate_EditBox

SRT>Exit
  exit
END>Exit


unclejoe
Newbie
Posts: 14
Joined: Wed Nov 06, 2002 10:43 am
Location: Poughkeepsie, NY

Post by unclejoe » Fri Sep 17, 2010 11:36 pm

Thanks JRL.
In the back of my mind I thought the variable name could be a problem.

The code I posted was a paraphrase of a portion of a much larger application which was written many releases ago. I had to make a few changes and used the Dialog Designer and Presto the Dialog took on a whole new look.
The reason for using the variable "text" was that it was used in a subroutine.
Admittedly, poor coding practice. Should have used a parameter.

Thanks again!
Joe Mueller
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts