<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    With is pretty dangerous because of scoping issues - and it breaks
    all the refactorings.  I'd like to see a "with f :
    MyDataModule.MyDataSet do" or similar construct.  I believe there is
    something like this in Prism.<br>
    <br>
    <br>
    <pre class="moz-signature" cols="72">Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
<a class="moz-txt-link-freetext" href="http://www.salespartner.co.nz">http://www.salespartner.co.nz</a>
PO Box 13085
Johnsonville
Wellington </pre>
    <br>
    On 21/01/2011 3:32 p.m., Ross Levis wrote:
    <blockquote cite="mid:00c901cbb913$724e91a0$56ebb4e0$@com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 12 (filtered
        medium)">
      <!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
      <style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:PMingLiU;
        panose-1:2 2 3 0 0 0 0 0 0 0;}
@font-face
        {font-family:PMingLiU;
        panose-1:2 2 3 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"\@PMingLiU";
        panose-1:2 2 3 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
p.avgcert, li.avgcert, div.avgcert
        {mso-style-name:avgcert;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
      <div class="Section1">
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);">Yes. 
            But I have done things like this.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);">procedure
            DoSomething;<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);">begin<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);"> 
            with MainForm do<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);"> 
            begin<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);">   
            …<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);"> 
            end;<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);">end;<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);">Definitely
            lazy.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:
            &quot;Calibri&quot;,&quot;sans-serif&quot;; color: rgb(31,
            73, 125);"><o:p> </o:p></span></p>
        <div>
          <div style="border-right: medium none; border-width: 1pt
            medium medium; border-style: solid none none; border-color:
            rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
            padding: 3pt 0cm 0cm;">
            <p class="MsoNormal"><b><span style="font-size: 10pt;
                  font-family:
                  &quot;Tahoma&quot;,&quot;sans-serif&quot;; color:
                  windowtext;" lang="EN-US">From:</span></b><span
                style="font-size: 10pt; font-family:
                &quot;Tahoma&quot;,&quot;sans-serif&quot;; color:
                windowtext;" lang="EN-US"> <a class="moz-txt-link-abbreviated" href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a>
                [<a class="moz-txt-link-freetext" href="mailto:delphi-bounces@delphi.org.nz">mailto:delphi-bounces@delphi.org.nz</a>] <b>On Behalf Of </b>John
                Bird<br>
                <b>Sent:</b> Friday, 21 January 2011 3:17 PM<br>
                <b>To:</b> NZ Borland Developers Group - Delphi List<br>
                <b>Subject:</b> Re: [DUG] Variables stored<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <div>
            <div>
              <p class="MsoNormal"><span style="font-size: 10pt;
                  font-family:
                  &quot;Arial&quot;,&quot;sans-serif&quot;;">Lazy?
                  or simpler and convenient?<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-size: 10pt;
                  font-family:
                  &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-size: 10pt;
                  font-family:
                  &quot;Arial&quot;,&quot;sans-serif&quot;;">plain
                  functions that might be useful anywhere in any program
                  are best done like this
                  I would think.   Examples are in Delphi units
                  afterall, eg StrUtils<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-size: 10pt;
                  font-family:
                  &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-size: 10pt;
                  font-family:
                  &quot;Arial&quot;,&quot;sans-serif&quot;;">John<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-size: 10pt;
                  font-family:
                  &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span style="font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">I
                  use some global variables.  I also have what I assume
                  are other bad habits
                  like creating plain functions or procedures instead of
                  declaring them inside
                  the form class.  Just lazy.<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">Ross.<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <div>
                <div style="border-right: medium none; border-width: 1pt
                  medium medium; border-style: solid none none;
                  border-color: rgb(181, 196, 223) -moz-use-text-color
                  -moz-use-text-color; padding: 3pt 0cm 0cm;">
                  <p class="MsoNormal"><b><span style="font-size: 10pt;
                        font-family:
                        &quot;Tahoma&quot;,&quot;sans-serif&quot;;
                        color: windowtext;" lang="EN-US">From:</span></b><span
                      style="font-size: 10pt; font-family:
                      &quot;Tahoma&quot;,&quot;sans-serif&quot;; color:
                      windowtext;" lang="EN-US">
                      <a class="moz-txt-link-abbreviated" href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a>
                      [<a class="moz-txt-link-freetext" href="mailto:delphi-bounces@delphi.org.nz">mailto:delphi-bounces@delphi.org.nz</a>] <b>On
                        Behalf
                        Of </b>Jolyon Smith<br>
                      <b>Sent:</b> Friday, 21 January 2011 9:44 AM<br>
                      <b>To:</b> 'NZ Borland Developers Group - Delphi
                      List'<br>
                      <b>Subject:</b> Re: [DUG] Variables stored<o:p></o:p></span></p>
                </div>
              </div>
              <p class="MsoNormal"> <o:p></o:p></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">Assignable typed constants are
                  pointless.<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">If you are going to declare a
                  constant and then use a compiler
                  switch to make it behave like a variable, then be
                  honest and just use a
                  variable!!<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">Typed constants cannot even be used
                  where “normal” constants can
                  be:<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">    const<o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">       ONE: Integer = 1;<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">   procedure Foo(aIndex: Integer =
                  ONE);  
                  // ERROR: Constant expression expected<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">or:<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">  case iValue of<o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">    ONE: ;  // ERROR: Constant
                  expression
                  expected<o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">  end;<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">Remove the type declaration from
                  the ONE const, and both compile
                  just fine (note that this is independent of the
                  Assigned Typed Constants
                  compiler setting).<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">A typed constant is to all intents
                  and purposes a variable, and
                  might as well be declared as such (note that you can
                  initialise a unit variable
                  as part of it’s declaration):<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">  var<o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">    ONE: Integer = 1;<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">One final comment – Delphi really
                  has no concept of a “global”
                  variable.  The highest visibility is “unit variable”. 
                  You still have
                  to explicitly “use” a unit to bring it into scope, and
                  if two units declare
                  variables of the same name normal scoping rules apply
                  but you can explicitly
                  qualify a reference using the unit name if you need to
                  override the default
                  scope.<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">Most of the time global/unit
                  variable is close enough that the
                  distinction doesn’t matter, but when it comes to dogma
                  the old rules that
                  “global variables are the spawn of Satan himself”
                  needs to be tempered in
                  Delphi with the fact that they are a bit better
                  “behaved” than the sort of
                  global variable that those ritualistic rules were
                  originally devised for.<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);">However, it is still true that the
                  occasions when a unit
                  variable is called for are relatively few, but they
                  should not be simply
                  outlawed for being something they are not.<o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"><span style="font-size: 11pt;
                  font-family: Wingdings; color: rgb(31, 73, 125);">J</span><span
                  style="font-size: 11pt; font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <p class="MsoNormal"> <span style="font-size: 11pt;
                  font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;; color:
                  rgb(31, 73, 125);"><o:p></o:p></span></p>
              <div>
                <div style="border-right: medium none; border-width: 1pt
                  medium medium; border-style: solid none none;
                  border-color: rgb(181, 196, 223) -moz-use-text-color
                  -moz-use-text-color; padding: 3pt 0cm 0cm;">
                  <p class="MsoNormal"><b><span style="font-size: 10pt;
                        font-family:
                        &quot;Tahoma&quot;,&quot;sans-serif&quot;;
                        color: windowtext;" lang="EN-US">From:</span></b><span
                      style="font-size: 10pt; font-family:
                      &quot;Tahoma&quot;,&quot;sans-serif&quot;; color:
                      windowtext;" lang="EN-US">
                      <a class="moz-txt-link-abbreviated" href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a>
                      [<a class="moz-txt-link-freetext" href="mailto:delphi-bounces@delphi.org.nz">mailto:delphi-bounces@delphi.org.nz</a>] <b>On
                        Behalf
                        Of </b>Robert martin<br>
                      <b>Sent:</b> Friday, 21 January 2011 09:18<br>
                      <b>To:</b> NZ Borland Developers Group - Delphi
                      List<br>
                      <b>Subject:</b> Re: [DUG] Variables stored<o:p></o:p></span></p>
                </div>
              </div>
              <p class="MsoNormal"> <o:p></o:p></p>
              <p class="MsoNormal">Hi John<br>
                <br>
                While all you suggest may be true (I don't know about
                the compiler setting
                stuff) I would strongly recommend anybody starting out
                with programming /
                delphi avoids using global variables.  Its a nasty habit
                to get into
                :)  <br>
                <br>
                Also the compiler setting you talk about sounds
                dangerous as someone who didn't
                know about it could become highly confused looking at
                the code or trying to
                compile it on a fresh install of Delphi !<br>
                <br>
                Also note I changed the typo spelling of the subject
                because it was annoying me
                :)<br>
                <br>
                Cheers<br>
                Rob<br>
                <br>
                On 21/01/2011 9:04 a.m., John Bird wrote: <o:p></o:p></p>
              <div>
                <div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">There
                        is another way as well, you can declare simple
                        global variables – depending
                        where you declare it determines it’s scope - how
                        visible it it is.<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">In
                        this example string2 can be seen by any unit
                        that uses this one, just as Form11
                        (the particular instance of TForm11, and is also
                        a global variable) is visible.<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">String3
can
                        be seen by all procedures in this unit, but not
                        by anywhere
                        else.    If you have lots of simple variables to
                        store and they
                        don’t need to be inherited etc this is the
                        simplest way to do it.<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">You
                        can take this further:<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">If
                        I have lots of constants to declare, or
                        variables to store I create a unit
                        which is code only (no classes) eg called
                        storeunit and declare all the
                        constants and variables I want there, any form
                        or unit that wants access to all
                        these variables just has to add storeunit to its
                        uses clause.   This
                        centralises all such declarations in one place
                        away from a form and is very
                        tidy.   I will often put simple global functions
                        and procedures in
                        here too, as they also become globally
                        available, eg various standard ways for
                        formatting dates and strings.   Also this unit
                        can be uses in
                        different projects as well.   For this just go
                        to
                        File/New/Unit   and the IDE gives you a new
                        blank unit already to add
                        stuff to – a simpler unit with no form or class
                        stuff.<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">Here
                        string4 string5 integer1 integer2 integer3 can
                        all be seen from anywhere that
                        uses Storeunit<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">It
                        depends on whether you like using global
                        variables or not.   Also its
                        a good idea to use a clear naming convention for
                        such variables.<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">There
                        are other tricks you can do too -  you can alter
                        compiler settings to
                        allow assignable constants for a procedure, then
                        any values assigned here will
                        be preserved between calls to the procedure.  
                        But that seems to be
                        confusing to me, as it really becomes a variable
                        and not a constant.  
                        I saw that used in and example where the program
                        wanted a counter of the number
                        of times the procedure was called, and the
                        counter constant in the procedure
                        was assigned a new value each time the procedure
                        was called, its quite a tidy
                        way to do that sort of thing.  In this case the
                        scope (visibility) of the
                        variable is totally limited to the one
                        procedure.<o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><tt><span style="font-size:
                          10pt;">type</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;"> 
                          TForm11 = class(TForm)</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">   
                          Button1: TButton;</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">   
                          procedure
                          Button1Click(Sender: TObject);</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;"> 
                          private</span></tt><span style="font-family:
                        &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">    {
                          Private
                          declarations }</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">  public</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">    {
                          Public declarations
                          }</span></tt><span style="font-family:
                        &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">   
                          MyString : string;</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">  end;</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                        <br>
                      </span><tt><span style="font-size: 10pt;">var</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;"> 
                          Form11: TForm11;</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><tt><span style="font-size:
                          10pt;">  string2: string;</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                        <br>
                      </span><tt><span style="font-size: 10pt;">implementation</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><tt><span style="font-size:
                          10pt;">uses storeunit;</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-family:
                        &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">{$R
                          *.dfm}</span></tt><span style="font-size:
                        10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><tt><span style="font-size:
                          10pt;">var</span></tt><span style="font-size:
                        10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><tt><span style="font-size:
                          10pt;">string3: string;</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-family:
                        &quot;Courier New&quot;;"><br>
                        <br>
                      </span><tt><span style="font-size: 10pt;">procedure
TForm11.Button1Click(Sender:
                          TObject);</span></tt><span style="font-family:
                        &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">begin</span></tt><span
                        style="font-family: &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;"> 
                          MyString := 'Hello, world!';</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><tt><span style="font-size:
                          10pt;">  string2:=’Hello world2’;</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-bottom: 12pt;"><tt><span
                          style="font-size: 10pt;">  string5:=’Hello
                          world5’;</span></tt><span style="font-family:
                        &quot;Courier New&quot;;"><br>
                      </span><tt><span style="font-size: 10pt;">end;</span></tt><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">unit
                        Storeunit;</span><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">interface</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">var</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">string4:string;</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">string5:string;</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">integer1:integer;</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">integer2:integer;</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">integer3:integer;</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">implementation</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family: &quot;Courier New&quot;;">end.</span><span
                        style="font-size: 10pt; font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                  </div>
                  <div>
                    <p class="MsoNormal"><span style="font-size: 10pt;
                        font-family:
                        &quot;Arial&quot;,&quot;sans-serif&quot;;">John<o:p></o:p></span></p>
                  </div>
                  <div>
                    <div>
                      <div>
                        <div>
                          <p class="MsoNormal"><b><span
                                style="font-size: 10pt; font-family:
                                &quot;Tahoma&quot;,&quot;sans-serif&quot;;">From:</span></b><span
                              style="font-size: 10pt; font-family:
                              &quot;Tahoma&quot;,&quot;sans-serif&quot;;">
                              <a moz-do-not-send="true"
                                href="mailto:marshland@marshland.co.nz"
                                title="marshland@marshland.co.nz">Marshland
                                Engineering</a> <o:p></o:p></span></p>
                        </div>
                        <div>
                          <p class="MsoNormal"><b><span
                                style="font-size: 10pt; font-family:
                                &quot;Tahoma&quot;,&quot;sans-serif&quot;;">Sent:</span></b><span
                              style="font-size: 10pt; font-family:
                              &quot;Tahoma&quot;,&quot;sans-serif&quot;;">
                              Thursday, January
                              20, 2011 3:45 PM<o:p></o:p></span></p>
                        </div>
                        <div>
                          <p class="MsoNormal"><b><span
                                style="font-size: 10pt; font-family:
                                &quot;Tahoma&quot;,&quot;sans-serif&quot;;">To:</span></b><span
                              style="font-size: 10pt; font-family:
                              &quot;Tahoma&quot;,&quot;sans-serif&quot;;">
                              <a moz-do-not-send="true"
                                href="mailto:delphi@delphi.org.nz"
                                title="delphi@delphi.org.nz">delphi@delphi.org.nz</a>
                              <o:p></o:p></span></p>
                        </div>
                        <div>
                          <p class="MsoNormal"><b><span
                                style="font-size: 10pt; font-family:
                                &quot;Tahoma&quot;,&quot;sans-serif&quot;;">Subject:</span></b><span
                              style="font-size: 10pt; font-family:
                              &quot;Tahoma&quot;,&quot;sans-serif&quot;;">
                              [DUG] Variabels
                              stored<o:p></o:p></span></p>
                        </div>
                      </div>
                    </div>
                    <div>
                      <p class="MsoNormal"><span style="font-size: 10pt;
                          font-family:
                          &quot;Arial&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                    </div>
                  </div>
                  <div>
                    <div>
                      <p class="MsoNormal"><span style="font-size: 10pt;
                          font-family:
                          &quot;Arial&quot;,&quot;sans-serif&quot;;">Is
                          there a way to store variables so I can use
                          them from one procedure to
                          another?  </span><span style="font-family:
                          &quot;Calibri&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span style="font-family:
                          &quot;Calibri&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span style="font-size: 10pt;
                          font-family:
                          &quot;Arial&quot;,&quot;sans-serif&quot;;">I
                          have been currently storing them in hidden
                          edit.text boxes on the form but
                          there must be a better way. </span><span
                          style="font-family:
                          &quot;Calibri&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span style="font-family:
                          &quot;Calibri&quot;,&quot;sans-serif&quot;;"> <o:p></o:p></span></p>
                    </div>
                    <div>
                      <p class="MsoNormal"><span style="font-size: 10pt;
                          font-family:
                          &quot;Arial&quot;,&quot;sans-serif&quot;;">Cheers
                          Wallace</span><span style="font-family:
                          &quot;Calibri&quot;,&quot;sans-serif&quot;;"><o:p></o:p></span></p>
                    </div>
                    <div class="MsoNormal" style="text-align: center;"
                      align="center"><span style="font-family:
                        &quot;Calibri&quot;,&quot;sans-serif&quot;;">
                        <hr width="100%" align="center" size="2">
                      </span></div>
                    <p class="MsoNormal"><span style="font-family:
                        &quot;Calibri&quot;,&quot;sans-serif&quot;;">_______________________________________________<br>
                        NZ Borland Developers Group - Delphi mailing
                        list<br>
                        Post: <a moz-do-not-send="true"
                          href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
                        Admin: <a moz-do-not-send="true"
                          href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
                        Unsubscribe: send an email to <a
                          moz-do-not-send="true"
                          href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a>
                        with Subject: unsubscribe<o:p></o:p></span></p>
                  </div>
                </div>
              </div>
              <pre> <o:p></o:p></pre>
              <pre> <o:p></o:p></pre>
              <pre>_______________________________________________<o:p></o:p></pre>
              <pre>NZ Borland Developers Group - Delphi mailing list<o:p></o:p></pre>
              <pre>Post: <a moz-do-not-send="true" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><o:p></o:p></pre>
              <pre>Admin: <a moz-do-not-send="true" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a><o:p></o:p></pre>
              <pre>Unsubscribe: send an email to <a moz-do-not-send="true" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe<o:p></o:p></pre>
              <p class="MsoNormal" style="margin-bottom: 12pt;"><o:p> </o:p></p>
              <p class="avgcert">No virus found in this message.<br>
                Checked by AVG - <a moz-do-not-send="true"
                  href="http://www.avg.com">www.avg.com</a><br>
                Version: 10.0.1191 / Virus Database: 1435/3392 - Release
                Date: 01/20/11<o:p></o:p></p>
              <div class="MsoNormal" style="text-align: center;"
                align="center"><span style="font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;;">
                  <hr width="100%" align="center" size="3">
                </span></div>
              <p class="MsoNormal"><span style="font-family:
                  &quot;Calibri&quot;,&quot;sans-serif&quot;;">_______________________________________________<br>
                  NZ Borland Developers Group - Delphi mailing list<br>
                  Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a><br>
                  Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
                  Unsubscribe: send an email to
                  <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject:
                  unsubscribe<o:p></o:p></span></p>
            </div>
          </div>
        </div>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@delphi.org.nz">delphi@delphi.org.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@delphi.org.nz">delphi-request@delphi.org.nz</a> with Subject: unsubscribe</pre>
    </blockquote>
  </body>
</html>