Thanks for the sample code and all the help.  "ByVal" is the key.  

I know tried using "ByVal" before my first e-mail; but the function returned a null 
value.  After running your code, I see that I have a problem with the function also. 
(I had originally written this code in visual basic and "converted" it to Mapbasic.)  
The functions (between the two) are just a little different.  It seems I screwed up 
the conversion.

Again thanks to all!     

-----Original Message-----
From: Bill Thoen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 10:10 AM
To: Cummings, Mike
Subject: Re: MI-L mapbasic Update table with custom function


BTW, you must pass the argument by value, not reference. In your
example below, you've declared Function xx (str as ...). It must
be Function xx (ByVal str ...

"Cummings, Mike" wrote:
> 
> OK, what's the trick?  Corner=strpcorner(stable2.location) doesn't work.  I don't 
> want to write code to loop through the table, if I don't have to.  Looping through 
> the table is going to be slow.
> 
> The update statement (for some reason) doesn't recognize table field names in custom 
> functions.  I have written a MBX with a simple function and I can pass values to 
> fill the field.
> 
> When I tried to use an alias(ie - Function xx(str as alias)as string), its fatal for 
> Mapinfo 6.5 (win2000 reports an illegal operation & closes Mapinfo).
> 
> Someone must have discovered this before.  I have a hard time believing there isn't 
> a way to update a field with a custom function without looping through the table or 
> some other work around. (I can do it in access.) When I sketched out my flow 
> diagram, it never occurred to me that this couldn't be done.  Its back to the 
> drawing board.  The Manual says that you can use custom functions in Select 
> statements.  Has anyone had any luck?
> 
> -----Original Message-----
> From: B. Thoen [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 26, 2004 5:07 PM
> To: Jacques Paris
> Cc: Cummings, Mike; Mapinfo-L
> Subject: RE: MI-L mapbasic Update table with custom function
> 
> No, that's not the case. In MapBasic, you can use custom functions in
> 'update' statements. In fact, this is a little known trick for rapidly
> updating tables rather than using the slower 'Do While...Loop' technique.
> 
> You might need to add the table name to the variable (e.g.
> Corner=strpcorner(stable2.location)), but that's just a stab in the dark.
> Check your spelling too -- 'location' may actually be 'loaction' in the
> table, or something like that.
> 
> - Bill Thoen
> 
> On Mon, 26 Apr 2004, Jacques Paris wrote:
> 
> > My interpretation is that the expression used to update a column must be
> > written with the MapBasic "vocabulary". I deduce that from the fact that
> > "update" as many other functions can be run from the MapBasic window that
> > does not support any "external" calls, i.e. calls to custom functions that
> > are not part of the MB set and must be supplied by the user, and the MB
> > window does not allow that.
> >
> > Jacques Paris
> > e-mail  [EMAIL PROTECTED]
> > MapBasic-MapInfo support  http://www.paris-pc-gis.com
> >
> >
> > -----Original Message-----
> > From: Cummings, Mike [mailto:[EMAIL PROTECTED]
> > Sent: 26-Apr-04 18:14
> > To: Mapinfo-L
> > Subject: MI-L mapbasic Update table with custom function
> >
> > I tried to compile this code:
> >
> > Update "stable2" Set MTRS = Left$(bm,1)+Twn+Rge+right$("0"+sec,2),
> > Corner=strpcorner(location)
> >
> > (Where MTRS, BM, TWN, RGE, SEC, corner & Location are fields in stable2
> > and strpcorner is a custom function)
> >
> > and I get this error message: Subroute Argument location not defined.
> >
> > Why doesn't this work?  Shouldn't Mapbasic recognize that location is a
> > field name?
> 
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 11533
> 
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 11544

-- 
- Bill Thoen
------------------------------------------------------------ 
GISnet, 1401 Walnut St., Suite C, Boulder, CO  80302
tel: 303-786-9961, fax: 303-443-4856
http://www.gisnet.com/
------------------------------------------------------------

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 11551

Reply via email to