Errsysw

Errsysw

Postby PeterHarmes » Fri Aug 24, 2007 7:20 am

Hi,

When i wrote my app using 16bit version of fivewin, i modified errsysw.prg so that it wrote to a diferent filename instead of overwriting error.log Also i was getting a problem with the errsysw if i had a lot of databases open and i assumed that the variable cErrorlog was getting too big, so i changed the method of writing the file error.log so that it wrote the details in sections (build the details of the error, application write to file, build the details of the dbfs write the file etc)

Since converting to 32bit i occaisionally get a recursive error, which i think means that the errsysw is actually erroring, so i removed my errsysw.

I'm now going to start to look at this problem and was going to get the latest version of errsysw and make the same changes as i initially made to the latest version and wanted to know if there is a problem if the cErrorLog string got too big?

Also, has anyone else made a similar change to errorsysw where it writes to a diferent file each time and are willing to show me how they did it, so i can compare code and see if i can improve what i'm doing?

Thanks in advance

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Postby Antonio Linares » Fri Aug 24, 2007 7:32 am

Peter,

> if there is a problem if the cErrorLog string got too big?

As we are in 32 bits, cErrorLog can be as big as 4 Gb. You will not have any problems managing strings below that limit.

> it writes to a diferent file each time

You can use FWH function cTempFile( cPath, cExtension ) --> cUniqueFileName
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby PeterHarmes » Fri Aug 24, 2007 8:48 am

Thanks for the quick reply Antonio.

I forgot to ask another question:

In my modified Errsysw i wanted to write which user got this error message, which in my app is stored as a public variable. If i want to use the errsysw in another app, i have to remember to declare this variable or have a diferent version of errsysw. I would rather have one version, so is there a way to check if a public variable exists before trying to write this to the file?

Thanks in advance

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Postby demont frank » Fri Aug 24, 2007 9:15 am

Peter

Me too has changed errsysw.prg
1) filename : Date + time
2) User was stored in a GLOBAL EXTERNAL aBediende

Code: Select all  Expand view
#ifdef FRANKDEMONT
local cErFile
cErFile := "ERRORS\Er" + DTOS(DATE()) + "." + CharOnly("0123456789",Time()) + ".log"
....
# ifdef FRANKDEMONT
   cErrorLog += "   Bediende : " + aBediende[1] + CRLF
# endif


Frank
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby Antonio Linares » Fri Aug 24, 2007 9:25 am

Peter,

varname = "UserName"

MsgInfo( Type( "varname" ) ) // you get "C" if varname is assigned and "U" if it isn't
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby PeterHarmes » Fri Aug 24, 2007 10:08 am

If i do a type() on a variable that doesnt exist i get an error - variable does not exist ...

my errsysw has been modified to include:

cErrorLog += "Operator: " + cOperator

so i need to check if the variable cOperator has been declared Publically/Locally before doing this line - is this possible?
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Postby Antonio Linares » Fri Aug 24, 2007 10:20 am

Peter,

Please notice that the name of the variable has to be inside quotes "varname"

You can only check for publics or privates as they are the only ones that have an entry in the symbols table. Locals and static don't have a symbol name and are not located at the symbols table.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby PeterHarmes » Fri Aug 24, 2007 10:26 am

My mistake.. Works a treat now! Thanks Antonio
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Postby James Bott » Fri Aug 24, 2007 4:41 pm

Peter,

A better way to store user info is to put in into a function as a static var. Here is an example:

// Set/Get function example
static function getOption(nNewOption)
local nReply
static nOldOption:=1
nReply:= nOldOption
if nNewOption != nil
nOldOption:= nNewOption
endif
return nReply

You could just change the fucntion name to user().

Better yet is to create a user class and then store the oUser object in the user function. You can create a user class with DATA such as user name, password, rights, etc. Also, you could add methods for load(), save(), and edit(), so you can create a user object and save and restore it.

Then you can do this:

oUser:= TUser():new()

oUser:edit()
oUser:save()

user( oUser )

msgInfo( user():name )

msgInfo( user():rights )

etc...

You could also modify the set/get user() function to automatically return a new blank oUser if a user object was not passed and there isn't one already stored as a static.

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: Google [Bot] and 51 guests