errsysw.prg

errsysw.prg

Postby hag » Tue Aug 24, 2010 3:01 pm

Using errsysw.prg and I would like to modify it in the following manner:

When there is a "data width error" it should notify the user to change the data and the program auto shortens the data then returns to the program rather then closing down the program. All help will be appreciated.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: errsysw.prg

Postby James Bott » Tue Aug 24, 2010 6:20 pm

Harvey,

I wouldn't suggest handling it that way. You end up with questionable data and you don't know which ones are questionable.

I would expand the database fields and/or restrict the data entry field. If the users are entering valid long data so expanding the database field would be a better solution. If the long data is not valid then restricting the data input field is a better solution.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: errsysw.prg

Postby hag » Tue Aug 24, 2010 8:50 pm

Thanks james. Your suggestion won't work. I need to inform user of the problem and prompt them to fix the data. If you have any idea on how best to dode this in errysysw I'd appreciate it.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: errsysw.prg

Postby James Bott » Tue Aug 24, 2010 10:21 pm

Harvey,

My concern is that there may be a better solution other than modifying errsysw.prg that either you don't know about or don't understand.

Why won't either of my suggestions work? Is the data coming from some unconrolled source such as a file import?

I think this error only comes from numerical data. How is the user going to "fix" it? Assuming the source data is real, are they then going to be forced to change the number and if so, aren't you going to end up with a number that is not real?

Do you know that there is a way to trap errors without modifying errsysw.prg?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: errsysw.prg

Postby hag » Tue Aug 24, 2010 11:09 pm

The problem generally happens when the user is playing around and reviewing the progrm and puts in not real data. Boom error width. I need to trap it let the user know they made a mistake or their real data is to large they need to fix it.
JAmes the data already goes to 999,999,999 can't make it larger. Also too many dbfs to expand.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: errsysw.prg

Postby James Bott » Tue Aug 24, 2010 11:24 pm

Harvey,

The best solution is to use picture clauses on the GETs so they cannot enter data that is too large. It is much better to not allow the "bad" data to be entered in the first place, rather the tell the user they did something "wrong" later. Users don't like to be scolded by machines.

Is there some reason that you cannot use picture clauses or limit the fieldsize of the data entry field?

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: errsysw.prg

Postby hag » Tue Aug 24, 2010 11:42 pm

I use pict clauses on all gets. They may enter a 10,000,000 in one part of the program then in another part of the program multiple by 100 an calc is too large for the data base. James best would be to trap the error when it occurs and let them know and fix it. My users love when I scold them. :D
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: errsysw.prg

Postby James Bott » Tue Aug 24, 2010 11:54 pm

Harvey,

OK, well you can easily check the result of the calculation to see if the result is too large then take whatever action you wish. Alternately you could limit the multipler depending on the input number. It is hard to make an educated suggestion without knowing exactly what is happening in your code (and the theory behind it).

Below is some sample code which uses a temporary error trapping routine during a portion of your code. You could adapt this to your needs. It may be more difficult to do this than the above since you are in a different part of your code (the save routine).

Regards,
James

Code: Select all  Expand view
Local oError, bOldError

// .... your code

lRetVal := .T.
bOldError := ErrorBlock( {|oErr| Break( oErr ) } )

Begin Sequence
   dbUseArea( lNewArea, cDriver, cDbfFile, cAlias, ! lExclu, lReadOnly )

Recover Using oError    // this error object is created automatically by the error handler
   NetError(.T.)
   lRetVal := .F.
   If oError:osCode == 2    // file not found
      // you handle it as you feel appropiate
   endif

End Sequence

ErrorBlock( bOldError )  // very important to restore original error handler!
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: errsysw.prg

Postby hag » Wed Aug 25, 2010 3:50 am

Thanks james I'll give it s try. I'll let you know if it works.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: errsysw.prg

Postby James Bott » Wed Aug 25, 2010 3:59 am

It would be simpler than using an errorblock, to just do something like this:

Code: Select all  Expand view
do while len( nTotal ) > len( (cAlias)->total )
   // do whatever to fix length
enddo

replace (cAlias)->total with nTotal


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: errsysw.prg

Postby James Bott » Wed Aug 25, 2010 4:12 am

Whoops, the above would only work with character fields. A generic one for numeric fields would be more complex. Perhaps you only need this since your maximum is 99,999,999.

Code: Select all  Expand view
do while nTotal >  99999999
   // do whatever to fix length
enddo

replace (cAlias)->total with nTotal


Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests