Or try

If first_character_value between 48 and 57 then

John Hollingsworth
The Buxton Company
[EMAIL PROTECTED]

-----Original Message-----
From: Marty DeBenedictis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 29, 1999 3:09 PM
To: Andy
Cc: mapinfo mailing list
Subject: Re: MI my code is evil

Andy:
I think your problem is in this line:
          
If first_character_value = (c1 or c2 or c3 or c4 or c5 or c6 or c7 or c8
or c9 or c0) then

Instead, try:

If first_character_value = any(c1,c2,c3,c4 . . .

HTH,
Marty

Andy wrote:
>
> The code cleans address data and can be, once be fixed, a useful
tool....
> however!
>
> There's something wrong here with the following code. The code edits a
table
> which stores addresses. Unfortunately the
> people that entered the data have placed the building number and the
> building name in the same field. It is this code's job to
> seperate the number and the name, store the number in field2 and place
the
> remainder into field2.
>
> The code works fine at removing 'first components' but it is removing
all
> first components - whether they start with a number or a letter.
> I have ten constants which store the Asc(str) values of the characters
0 to
> 9 and as far as i can see (and this is no doubt the problem area)
these
> values are checked against the first character in the field. This
#should#
> determine whether the string starts with a number.. but, oh, it
doesn't.
>
> examples of how it should work
> field2 (original string)     field1      new field2
> 8 AVON HOUSE        8            AVON HOUSE
> BUTT CASTLE                         BUTT CASTLE
> 9A THE MEWS           9A         THE MEWS
>
> examples of what it is really doing
> field2(original string)      field1      new field2
> 8 AVON HOUSE        8            AVON HOUSE
> BUTT CASTLE           BUTT     CASTLE
> 9A THE MEWS           9A          THE MEWS
>
> ' Text adjustments to fields
> ' In this case we have a table called d:\temp\temp.tab
> ' this removes the first component of a string if
> ' it starts with a number.
> ' If there is only one component and it starts with
> ' a number this too will be removed.
> ' Removed components are placed into another field, field2.
> ' The rest of the string is returned to field1.
>
> ' field1 is for building names
> ' field2 is for building numbers
>
> ' Definitions
> Include "MAPBASIC.DEF"
> Include "MENU.DEF"
> Dim tablename As String
> Dim num_rows As Integer
> Dim complete_string As String
> Dim removed_component As String
> Dim residue_component As String
> Dim string_length As Integer
> Dim pos As Integer
> Dim record_number As Integer
> Dim first_character_value As Integer
> Open Table "D:\temp\temp"
> tablename = TableInfo(0, TAB_INFO_NAME)
> num_rows = TableInfo(0, TAB_INFO_NROWS)
>
> ' Asc Variable Definitions.
> Dim c1, c2, c3, c4, c5, c6, c7, c8, c9, c0 As Integer
> c1 = Asc("1")
> c2 = Asc("2")
> c3 = Asc("3")
> c4 = Asc("4")
> c5 = Asc("5")
> c6 = Asc("6")
> c7 = Asc("7")
> c8 = Asc("8")
> c9 = Asc("9")
> c0 = Asc("0")
>
> 'Run through the table.
>
> Fetch First from temp
> Do While Not EOT(temp)
>     complete_string = temp.field1
>     record_number = temp.rowID
>     string_length = Len(complete_string)
>     first_character_value = Asc(complete_string)
>     If first_character_value = (c1 or c2 or c3 or c4 or c5 or c6 or c7
or c8
> or c9 or c0) then
>
>         'First character is a number so remove first component
>         pos = InStr(1, complete_string, " ")
>         If pos = 0 then
>             ' complete_string is a complete number component and must
be
> completely removed
>             Update temp Set field2 = complete_string Where RowID =
> record_number
>         Else
>             'We have a multiple component string and the first part
must be
> removed...
>             removed_component = Left$(complete_string, (pos-1))
>             Update temp Set field2 = removed_component Where RowID =
> record_number
>             'And the rest of the string returned...
>             residue_component = Right$(complete_string,
(string_length-pos))
>             Update temp Set field1 = residue_component Where RowID =
> record_number
>         End If
>     End If
> Fetch Next from temp
> Loop
>
> ----------------------------------------------------------------------
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and
put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

--
------------------------------------
Marty DeBenedictis
Community Mapping Assistance Project - NYPIRG
http://www.cmap.nypirg.org
[EMAIL PROTECTED]
------------------------------------
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to