Dialog NO_SUCH_PROPERTY

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Dialog NO_SUCH_PROPERTY

Post by Jerry Thomas » Mon Mar 07, 2011 7:50 pm

I keep getting NO_SUCH_PROPERTY on strFileName but only the 2nd time through. The 1st time, everything works.

But when the last line of the SRT is commented out, it continues to work with no problems.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 546
  Top = 119
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Dialog1'
  ClientHeight = 173
  ClientWidth = 536
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object lblLocation: TLabel
    Left = 30
    Top = 15
    Width = 251
    Height = 16
    Caption = 'Select location for file to be created:'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object lblFileName: TLabel
    Left = 32
    Top = 75
    Width = 76
    Height = 16
    Caption = 'File Name:'
  end
  object ebFolder: TEdit
    Left = 30
    Top = 40
    Width = 278
    Height = 21
    TabOrder = 1
    TextHint = 'File location...'
  end
  object btnFolder: tMSButton
    Left = 328
    Top = 37
    Width = 64
    Height = 25
    DoubleBuffered = True
    Glyph.Data = {
      F6000000424DF600000000000000760000002800000010000000100000000100
      0400000000008000000000000000000000001000000010000000000000000000
      80000080000000808000800000008000800080800000C0C0C000808080000000
      FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
      77777777777777777777000000000007777700333333333077770B0333333333
      07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
      77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
      7007777777770777070777777777700077777777777777777777}
    ParentDoubleBuffered = False
    TabOrder = 0
    DoBrowse = False
    Filter = 'Any file (*.*)|*.*'
    BrowseStyle = fbFolder
  end
  object ebFileName: TEdit
    Left = 30
    Top = 100
    Width = 168
    Height = 21
    TabOrder = 2
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,btnFolder,OnClick,DirBrowse

Show>Dialog1,r

SRT>DirBrowse

**BREAKPOINT**
  SetDialogProperty>Dialog1,btnFolder,DoBrowse,True
//Watch variables after next line is executed.
  GetDialogProperty>Dialog1,btnFolder,Filename,strFileName
  SetDialogProperty>Dialog1,ebFolder,Text,strFileName

//Comment this line out and there is no problem
  GetDialogProperty>Dialog1,ebFileName,Text,FileName
END>DirBrowse
Thanks,
Jerry

[email protected]

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Mar 08, 2011 8:46 am

I can see the problem. Let's walk through some of the lines in your SRT:

GetDialogProperty>Dialog1,btnFolder,Filename,strFileName

Here you ask for the Filename property and store it in strFileName. No problem.

e.g.: strFileName=c:\bla

SetDialogProperty>Dialog1,ebFolder,Text,strFileName

Here you set the Text property to the value of strFileName. No problem.

//Comment this line out and there is no problem
GetDialogProperty>Dialog1,ebFileName,Text,FileName

Here you get the Text property and store it in a variable called FileName.

e.g.: FileName=c:\bla\file.fil

Now let's do a 2nd parse:

GetDialogProperty>Dialog1,btnFolder,Filename,strFileName

Get the property referenced by Filename. Filename now = "c:\bla\file.fil"
There's no property called ""c:\bla\file.fil"". Error!

Solutions:

1. Use a more sensible variable naming convention, e.g. as you have done with strFileName
and/or
2. Explicitly specify a literal string for the proprty:

GetDialogProperty>Dialog1,btnFolder,{"Filename"},strFileName

or

3. Use VAREXPLICIT if you are that way inclined and want more traditional separation between what is a literal and what is a variable.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Tue Mar 08, 2011 3:19 pm

Many thanks!

I appreciate the time you took to walk through this.
You are right, using a variable name twice typically will not lead to successful code!
Thanks,
Jerry

[email protected]

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