Thanks to Lars and Martin for their replies. I now have a few suggestions to try out to make the code work. Lars the reason I had declared those local variables was because when I tried to run the mapbasic program it was coming up "field not defined". I'm assuming if I reference the table with the field name this won't be a problem. Thanks again,
Christine Christine Ronning GIS Analyst 740 Carmi Avenue Penticton, BC V2A 8P9 250-770-3408/250-870-4677 [EMAIL PROTECTED] -----Original Message----- From: Lars V. Nielsen (GisPro) [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 06, 2005 11:50 PM To: Ronning, Christine Cc: MapInfo-L@lists.directionsmag.com Subject: Re: MI-L Map Basic Application not inserting text where wanted Hi Christine, You've also defined the column names as local variables, and they override any table based column references. If you delete the problematic local variables (rowid, _15_19, ...), you should be fine. Further, when referencing table values, you should always use the "TableName.ColumnName" notation to prevent such ambiguities. Best regards/Med venlig hilsen Lars V. Nielsen GisPro, Denmark http://www.gispro.dk/ ----- Original Message ----- From: "Ronning, Christine" <[EMAIL PROTECTED]> To: "Bazeley, Gordon" <[EMAIL PROTECTED]>; <MapInfo-L@lists.directionsmag.com> Sent: Tuesday, September 06, 2005 8:33 PM Subject: MI-L Map Basic Application not inserting text where wanted Hi List, Just wondered if you could look over the following code and see if there's anything obviously wrong! I'm trying to identify the maximum value from a row based on values in Table "Population_Var" and place the column name of this value into another column. I've managed to find this maxmimum value, and with the help of this list write code that should update the column with text values, but can't seem to get it to insert any text values. ************************************************************************ ************************ Include "MapBasic.def" Declare sub main sub main Open Table "Population_Var" Interactive Alter Table Population_Var (Add Max_Count float Add Ratio_Dif float Add Max_Name char(14) Add Max_C_Group char(14)) Update Population_Var Set Max_Count = Maximum(Maximum(Maximum (Maximum(Maximum(Maximum(_15_19,_20_24),_25_29),_30_34) ,_35_39),_40_44),_45_49) Update Population_Var Set Ratio_Dif = (1-(_15_19/Max_Count))+ (1-(_20_24/Max_Count))+(1-(_25_29/Max_Count))+(1-(_30_34/Max_Count)) +(1-(_35_39/Max_Count))+(1-(_40_44/Max_Count))+(1-(_45_49/Max_Count)) Dim sum As Float, counter, rowid as Integer, Max_Count, _15_19,_20_24,_25_29,_30_34,_35_39,_40_44,_45_49 As Float, Max_C_Group, Max_Name As String Open Table "Population_Var" Interactive Fetch first from Population_Var Do while EOT(Population_Var) counter=rowid Max_Count=0 Max_C_Group="" If Population_Var._15_19>Max_Count then Max_Count=_15_19 Max_C_Group="_15_19" End if If Population_Var._20_24>Max_count then Max_Count=_20_24 Max_C_Group="_20_24" End if If Population_Var._25_29>Max_Count then Max_Count=_25_29 Max_C_Group="_25_29" End if If Population_Var._30_34>Max_count then Max_Count=_30_34 Max_C_Group="_30_34" End if If Population_Var._35_39>Max_Count then Max_Count=_35_39 Max_C_Group="_35_39" End if If Population_Var._40_44>Max_count then Max_Count=_40_44 Max_C_Group="_40_44" End if If Population_Var._45_49>Max_Count then Max_Count=_45_49 Max_C_Group="_45_49" End if Update Population_Var Set Max_Name=Max_C_Group Where rowid=counter counter = counter+1 Fetch Next from Population_Var Loop End Sub ************************************************************************ *********************** Any help would be greatly appreciated, thanks so much Christine --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Message number: 17775