Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi I am having a problem running a

Status
Not open for further replies.

itc1

IS-IT--Management
Sep 18, 2003
65
US
Hi I am having a problem running a FoxPro program. An error comes up that reads :
numeric overflow data was lost

It stops on the code that reads:
Gather memar memo

Here's the portion of the code where the problem lies:

SCAN
SCATTER MEMVAR MEMO
COUNT=COUNT+1
m.storyorder = COUNT
titx=ALLTRIM(m.titlename)
copydate=ALLTRIM(STR(YEAR(m.issuedate)))
copyright = (CHR(9) + "This article was prepared by " + titx + " editors from staff and other reports. Copyright " + copydate + ", " + titx + " via NewsRx.com.")
m.abstract = ALLTRIM(m.abstract) + copyright
SET CENTURY ON
date1x=DTOC(m.issuedate)
newcnt = ALLTRIM(SUBSTR(date1x,1,2) + SUBSTR(date1x,4,2) + SUBSTR(date1x,7,4))
SET CENTURY OFF
cntstr=ALLTRIM(STR(m.storyorder))
orderxr3="333"
newcnt1 = (newcnt+orderxr3+cntstr)
m.id = newcnt1
GATHER MEMVAR MEMO
ENDSCAN

What can I do to fix this error? Thanks in advance
 
Don;t you have to "Appen Blank" before Gathering memvar? and you are gathering the memvar in the same Table?

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
This error usually occurs in 1 of 2 instances.

1. You are trying to stuff a large number in a small field.

I.e. Assume Amount is defined as numeric 4.

AMOUNT N(4)
REPLACE AMOUNT WITH 12345

2. You did a zero divide, resulting in *********** and you are trying to replace that into a numeric field.

Jim Osieczonek
Delta Business Group, LLC
 
Also COUNT is a reserved word and it isn't very wise to use it as a variable.
Use something like nCount that indicates that it is a numerical variable.

Rob.
 
thanks all for your help. TechnoSDS, the append blank worked. thanks again
 
hi again. I thought adding append blank before the GATHER MEMVAR MEMO worked, but it actually added a duplicate record to the file. Is there another place where I should add the Append Blank line. Here's the problem I was initially having:

I am having a problem running a FoxPro program. An error comes up that reads :
numeric overflow data was lost

It stops on the code that reads:
Gather memar memo

Here's the portion of the code where the problem lies:

SCAN
SCATTER MEMVAR MEMO
COUNT=COUNT+1
m.storyorder = COUNT
titx=ALLTRIM(m.titlename)
copydate=ALLTRIM(STR(YEAR(m.issuedate)))
copyright = (CHR(9) + "This article was prepared by " + titx + " editors from staff and other reports. Copyright " + copydate + ", " + titx + " via NewsRx.com.")
m.abstract = ALLTRIM(m.abstract) + copyright
SET CENTURY ON
date1x=DTOC(m.issuedate)
newcnt = ALLTRIM(SUBSTR(date1x,1,2) + SUBSTR(date1x,4,2) + SUBSTR(date1x,7,4))
SET CENTURY OFF
cntstr=ALLTRIM(STR(m.storyorder))
orderxr3="333"
newcnt1 = (newcnt+orderxr3+cntstr)
m.id = newcnt1
GATHER MEMVAR MEMO
ENDSCAN

It was suggested that I add Append Blank before GATHER MEMVAR MEMO, however, this added duplicate records to my output. Thanks for any help
 
Is newcnt and newcnt1 numeric or character fields.

IF they are numeric - Check out the following 2 lines of code in your program:

newcnt = ALLTRIM(SUBSTR(date1x,1,2) + SUBSTR(date1x,4,2) + SUBSTR(date1x,7,4))

newcnt1 = (newcnt+orderxr3+cntstr)

You make newcnt a character by using the SUBSTR and ALLTRIM and then you are trying to add it to orderxr3+cntstr. I think that is the problem.

Try adding the VAL function to make it all numbers:

newcnt = VAL(ALLTRIM(SUBSTR(date1x,1,2)) + VAL(SUBSTR(date1x,4,2)) + VAL(SUBSTR(date1x,7,4)))


If that's not it, can you let us know which fields are numeric and which are character? That would be helpful.





Jim Osieczonek
Delta Business Group, LLC
 
hi jimmo, I entered the code you suggested to the newcnt varible. I got an error on the newcnt1 line that read operator/operand type mismatch. By the way, the newcnt variable is a character field and the newcnt1 was a nuneric field. Should I also add something to the newcnt1 field, it appears the program went pass the newcnt field where I added the VAL function. thanks
 
By the way, the newcnt variable is a character field and the newcnt1 was a nuneric field. Should I also add something to the newcnt1 field, it appears the program went pass the newcnt field where I added the VAL function.

Based on that statement. Keep the code you have for newcnt the same:

newcnt = ALLTRIM(SUBSTR(date1x,1,2) + SUBSTR(date1x,4,2) + SUBSTR(date1x,7,4))


But, you must convert it to number when adding to other numbers and creating a new number.

newcnt1 = (VAL(newcnt)+orderxr3+cntstr)

Notice I added the VAL function around newcnt so it will be treated as a number. You will need to do the same for orderxr3 and cntstr unless they are already numeric data types.




Jim Osieczonek
Delta Business Group, LLC
 
thanks jimmo, I made the changes and ran the program. It seemed to work fine. However, I commented out the append blank code in the program, which was suggested when I initally had the problem. However, when I used the append blank code it duplicate news articles. Do I need to add that code in the program? If so, where do I place it. We have records now that will contain over 1000 articles. I got that Gather memar memo error when I tried to run the program with a file that had over 1000 articles in it. Will the code you provided me work with such a file or do I need append blank code. I wasn't able to test program with a record that has 1000 articles because I won't get another until next week. Thanks again for your help.
 
Not sure if this one has been resolved yet ... so here is my 2 cents worth ...

First: look at the record after getting the error message to see which field has the numeric overflow. There should be "*****" or something like it in the field.




Don


 
ITC

You only need the append blank if you plan on adding new records. If all you are doing is changing data, scatter works fine. In your instance you are scattering to memory variables, I actually prefer an object, but let's stick with memory variables so I don't confuse you too much. After you get this working, you can asked me to explain that.


Here is how scatter works.

USE Story
SCATTER MEMVAR MEMO

Let's says story has a title and cost. You want to change the title and cost.

title = "My New Title"
Cost = 10.10

* Save the data using a GATHER command.

GATHER story MEMO

You just changed the data on 2 fields.

Example 2.

Let's say you want to add a new record, but keep some information from the current record.

SCATTER MEMVAR MEMO
story = "New Story"
cost = 20.20

APPEND BLANK
* you are now on a new record but all the fields from the last record are in memory as variables. Of course, you changed 2 of them (story and cost).

* Since you are on a new record. Gather will replace the blank fields with the values in the memory variables.

GATHER MEMVAR MEMO

* you now have a new record using example 2.

Do these 2 examples help in your logic / thought process?

Jim Osieczonek
Delta Business Group, LLC
 
And to continue with my simplistic approach ...

A numeric overflow indicates that a numeric value has exeeded the size of the field it is being placed in.

Since the only variable I see in your code that ends up being numeric is .... TaDa ... m.storyorder. Therefore, if I had to guess, I would guess that it was the culprit.

Therefore, I might suggest increasing the size of the STORYORDER field in your file and the problem will go away.

You can verify all of this using the DEBUGGER.

Don


 
jimmo, thanks so much. you help me a great deal. thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top