Hello Mike,

I see that several people have made suggestions about this one. Here are my
thoughts:

1) You can indeed use a custom function in an UPDATE statement, but not
sub(s). This method can only be used in a MB program and not on the MB
window command line. 

2) Remember that you pass back a return value in MapBasic by assigning the
function name itself to something as if it were a variable. It's very easy
to forget this and have functions returning incorrect values.

3) The function can accept parameters from field names or MapBasic variable
that are in scope.

4) I don't think it matters if the variables are passed "byval" or not. I am
sure values passed not byval (=by reference), and modified by the function,
are not stored back to the table. This is different from passing a variable
by reference.

5) Your data types should be preferably identical but at least compatible
(data type promotions like smallint->integer->float) are OK.

6) Remember that your column names should not conflict with variable names.
If so, variable names will take precedence. E.g. If you have a variable
called "location" with a type incompatible with strpcorner(), that could be
your problem.

7) You can break statements along multiple lines so the
"Corner=strpcorner(location)" which appears to be on a separate line in your
message will be fine. The comma at the end of the preceding line makes it
valid. Unlike some other languages you do not need to use "&" statement
continuation marks over multiple lines.

Regards,
Warren Vick
Europa Technologies Ltd.
http://www.europa-tech.com

-----Original Message-----
From: Cummings, Mike [mailto:[EMAIL PROTECTED] 
Sent: 26 April 2004 23: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: 11530




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

Reply via email to