Reading in numbers - am I missing the boat?

Reading in numbers - am I missing the boat?

Post by Daniel Crows » Fri, 03 Mar 1995 06:35:18



Hello,

        I'm writing a report where I read in unformatted data from a
file.  I'm trying to read in some numeric fields, but it gives me
incompatable types errors.

----
define variable d-line as character.
define variable x-num as integer.

import unformatted d-line.

assign x-num = integer(substring(d-line, 1, 3)).

----

if I do

define variable x-tmp as char.

assign x-tmp = substring(d-line, 1, 3).
       x-num = integer(x-tmp).

it works.

Why do you have to break it up?

Thanks,

Dan

---------------------------------------------------------------------------



      Chesterfield MO 63005           |    ^-- mail me here 1st
---------------------------------------------------------------------------

 
 
 

Reading in numbers - am I missing the boat?

Post by KeyWest » Fri, 03 Mar 1995 09:56:28


First, I would check the character variable you created to see if theres
really a numbers in the field.   If so, then check to see what the actual
data looks like by displaying positions 1 through 3 of your import
variable and editing the file with some editor that will read raw data.  
My experience tells me that you have more than numbers in your field.  I
have not used the unformatted option on the import for raw data.  When I
read an ascii file,  I know where each record ends and begins.  So I use
the quoter utility to quote my entire records,  then break them up by
position according to the layout used the send the data.    

I have had problems before where garbage was embeded (actual ascii
characters) in the record,  They where there but you could not see the
characteds because they where control characters.   We were doing a
conversion from an HP3000 MPE to a DEC 5900 Ultrix.  The HP uses a CR as a
record seperator,  but UNIX uses CR/LF as a record seperator.  The
developer knew this,  and to compensate for it he embeded a CR/LF at the
end of each record.  However,  the MPE OS embeded a CR at the end of each
record in addition to his CR/LF.

 When I looked at the record in VI,  I could display the record seperator
with the (L) option and discovered there was a CRCR/LF at the end of each
record.  When I tried to read a record,  I could never find where one
record ended and one began.  Progress treated the file as if I were trying
to read one record.

I hope this helps

Mike Riley
KeyWest Software, Inc.
11107 Gainsborough Court #9
Fairfax, Va. 22030

(703) 591-8315
(703) 591-1830

 
 
 

Reading in numbers - am I missing the boat?

Post by Daniel Crows » Sat, 04 Mar 1995 00:15:36




>First, I would check the character variable you created to see if theres
>really a numbers in the field.   If so, then check to see what the actual
>data looks like by displaying positions 1 through 3 of your import
>variable and editing the file with some editor that will read raw data.  
>My experience tells me that you have more than numbers in your field.  I
>have not used the unformatted option on the import for raw data.  When I
>read an ascii file,  I know where each record ends and begins.  So I use
>the quoter utility to quote my entire records,  then break them up by
>position according to the layout used the send the data.    

- rest pruned -

That does't appear to be the problem here.  This is really a text file,
its just not delimitted with spaces.  

I just don't see the reason why I can't do the process in a single step.

Dan

---------------------------------------------------------------------------



      Chesterfield MO 63005           |    ^-- mail me here 1st
---------------------------------------------------------------------------

 
 
 

Reading in numbers - am I missing the boat?

Post by Peter Headla » Sun, 05 Mar 1995 20:48:57


Quote:> ----
> define variable d-line as character.
> define variable x-num as integer.

> import unformatted d-line.

> assign x-num = integer(substring(d-line, 1, 3)).
> ----

I just typed the above in with no database connected, and it compiled and ran
perfectly (SCO UNIX V7.3A02).  I would go back and try again with different
variable names - watch out for name clashes of the variables with fields in
your database!
 
 
 

Reading in numbers - am I missing the boat?

Post by MYTynda » Mon, 06 Mar 1995 14:52:37


RE:

Quote:> ----
> define variable d-line as character.
> define variable x-num as integer.

> import unformatted d-line.

> assign x-num = integer(substring(d-line, 1, 3)).
> ----

make your assign statement read:
    assign x-num = integer(substring(STRING(d-line),1,3)).

i believe that will do it on any platform.

Mark Tyndall
Business Systems Design, Inc.
Atlanta, GA  USA

 
 
 

Reading in numbers - am I missing the boat?

Post by Tim » Tue, 07 Mar 1995 07:04:44



>RE:
>> ----
>> define variable d-line as character.
>> define variable x-num as integer.

>> import unformatted d-line.

>> assign x-num = integer(substring(d-line, 1, 3)).
>> ----
>make your assign statement read:
>    assign x-num = integer(substring(STRING(d-line),1,3)).
>i believe that will do it on any platform.

I have never tried this, but have encountered the original problem on DOS and
Unix. I simply did the first workaround and went on to get the job finished.
It seems like a bug in the Progress compiler. (IMO)


"Nothing is simple..."

 
 
 

1. HOWTO: Find the first missing number in a series of numbers

Hi,

I've been thinking of this for a long while and this has been a challenge for as
long :). The challenge is the following: I have a table, which has an "ID"
column that is not an IDENTITY column. That is I can input values in that
column. The ID column has a UNIQUE index and its values are supposed to be
sequential numbers.

Now what happens if you delete a record? A "hole" appears and the sequence is
broken. If you want to fill the "holes" and reuse an ID that has been deleted
with a non-nested SELECT statement, here's a formula:

SELECT TOP 1 COUNT(Numbers.ID) AS ID
FROM Numbers INNER JOIN
    Numbers T ON Numbers.ID <= T.ID
GROUP BY T.ID
HAVING (T.ID > COUNT(Numbers.ID))

I'm using an uncommon JOIN with a "<=" operator to be able to count the number
of occurrences of an ID. There is no "hole" as long as the ID is equal to the
number of IDs that are smaller or equal.

The formula works perfectly well when there are holes. However it fails returns
nothing when there are none and. You must then get the max. value plus one.
Unless someone finds better :-). Well, I'm tired.

Vince C.

2. MS-SQL Server on New IBM OS/2 2.1???

3. INITIALIZE DEVICE- -What am I missing???

4. Wanted: 2 things

5. What am I missing....?

6. Current Survey - 01 Nov 2002

7. Integrated Security: What am I missing here?

8. HELP: Am I missing the point or something ?

9. Help with SQL Query - what am I missing?

10. What am I missing

11. Am I missing something????

12. Transaction Snapshots - What am I Missing?...