Hello Doug,
Jaromir is right. And the reason he's right is that it's a scope question. Variables
in an MBX is in one scope, whereas variables in
command strings are in another. It's perfectly legal do do something along these lines:
Run Command "Dim a as Integer"
Run Command "a = 5"
The variable "a" here is _not_ defined in your MBX scope, so you can't issue a simple
"a = 5" statement, but it's defined in the
"command scope" (which is the same scope that the MapBasic window uses, btw), and thus
the assignment here is legal.
The problem with objects, and e.g. styles,. is that it's impossible to give the
"value" of such variables directly when running a
command string. It's easy to substitute strings and numeric values, but objects are
impossible. So it needs elaborate work-around to
make it work, typically involved a temporary, hidden table. Something like this :
Dim Thisobj as Object
Create Table "MyHiddenTable" (ID Integer) File TempFileName$("") Hide
Create Map For MyHiddenTable 'Coordsys ....
Insert Into MyHiddenTable (OBJ) Values (Thisobj)
Commit Table MyHiddenTable
Run Command "Dim Thisobj as Object"
Run Command "Fetch First From MyHiddenTable"
Run Command "ThisObj = MyHiddenTable.OBJ"
Run Command ".... do your stuff ......"
Run Command "Undim Thisobj" ' to clean up the command scope to prevent future errors
Close Table MyHiddenTable
Getting values back from the command scope into the mbx scope is another similar
troublesome task, only this time it concerns all
variables types.
Best regards/Med venlig hilsen
Lars V. Nielsen
GisPro, Denmark
http://www.gispro.dk/
http://www.gispro.biz/
----- Original Message -----
From: "Jaromir Svasta" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 29, 2003 7:13 AM
Subject: Re: MI-L run command error problem
> Variables cannot be included in command strings, you must substitute them
> with real values or functions. In case of region objects it is impossible
> because CreateRegion() function does not exist. With points, lines,
> circles or rectangles you can do it.
>
> Jaromir Svasta
>
>
> On Wed, 29 Oct 2003 09:28:04 +1000, Doug Pease
> <[EMAIL PROTECTED]> wrote:
>
> > Im stumped with what might have a very simple solution, but I am unable
> > to work it out. Hope someone can help me out here.
> >
> >
> >
> > In an application I run a very simple query :
> >
> > Select * from propertynotes where thisobj within propertynotes.obj into
> > findparcel
> >
> >
> >
> > Thisobj is defined as an Object
> >
> >
> >
> > When the query is run directly as a query it produces results. If I run
> > the query as a command string I get the following error: "Variable or
> > field thisobj not defined"
> >
> >
> >
> > Any assistance greatly appreciated.
> >
> >
> >
> > Doug Pease
> >
> > GIS Officer
> >
> > Livingstone Shire Council
> >
> > PO Box 600
> >
> > Yeppoon 4703
> >
> > Qld Australia
> >
> >
> >
> > Ph 07 49399957
> >
> > Fax 07 49393290
> >
> >
> >
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 8926
>
>
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 8929