Author | Topic: NTOC() IDSC Error | |
---|---|---|
Charles Freeman | NTOC() IDSC Error on Wed, 25 Mar 2009 00:00:45 -0400 For the last few years my client's error logs have showed infrequent but consistent IDSC errors in the internal NTOC() function. By infrequent, I would mean it would IDSC two or three times a week on a function that gets called thousands of times per day. It's legacy stuff left over from Clipper days; I used NTOC() to compress a date into a three character space as follows: cResult := NTOC(dDate - STOD(19800101), 32) Using this I date stamp every record of every database in my application. I never changed the system when going to Xbase++ because of a zillion legacy databases at client sites that would need to change; besides, it worked. At any rate I've reported the IDSC to Alaska several times over the years. To their credit they test it and it works fine, which is the end of their interest in the subject. Of course it works fine, my results are the same... 99.999% of the time. But IDSC's just don't cut it with my clients, even if they only occur a few times per week, and this was one of the last to go. I finally had a "duh!" moment a few months ago and realized that NTOC() was a pretty trivial function to write myself. I did it, and sure enough mine has not logged any IDSC's at all since it was substituted for theirs. So once again, a workaround was the best approach to take. On the off chance anyone else has had this problem, this will save you a few moments of programming effort: -------------- /*!-------------------------------------------------------------------------- Function: N2C(n, nBase) Summary: Convert n to string in nBase (nBaseMax = 36) Description: Because NToC in xbTools++ gives IDSC's ---------------------------------------------------------------------------*/ FUNCTION N2C(n, nBase) LOCAL cOutStr := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' LOCAL cRet := cOutStr[(n%nBase)+1] IF n > nBase Recurse for greater digits cRet := N2C(INT(n/nBase), nBase) + cRet ENDIF RETURN cRet -------------- Best regards, Charlie Freeman | |
Frankie | Re: NTOC() IDSC Error on Thu, 20 Jan 2011 03:44:05 +0800 Hi, Thank you for providing the work around. I happen to use NToC() recently and it works on the 1st app but have showed IDSC on the 2nd app constantly. As a result, i searched the NG and found your solution except there's an error in the code. This line IF n > nBase Recurse for greater digits should be changed to IF n >= nBase Recurse for greater digits to get the correct result. Regards Frankie On Wed, 25 Mar 2009 00:00:45 -0400, Charles Freeman wrote: > For the last few years my client's error logs have showed infrequent but > consistent IDSC errors in the internal NTOC() function. By infrequent, I > would mean it would IDSC two or three times a week on a function that gets > called thousands of times per day. > > It's legacy stuff left over from Clipper days; I used NTOC() to compress a > date into a three character space as follows: > > cResult := NTOC(dDate - STOD(19800101), 32) > > Using this I date stamp every record of every database in my application. I > never changed the system when going to Xbase++ because of a zillion legacy > databases at client sites that would need to change; besides, it worked. > > At any rate I've reported the IDSC to Alaska several times over the years. > To their credit they test it and it works fine, which is the end of their > interest in the subject. Of course it works fine, my results are the > same... 99.999% of the time. But IDSC's just don't cut it with my clients, > even if they only occur a few times per week, and this was one of the last > to go. > > I finally had a "duh!" moment a few months ago and realized that NTOC() was > a pretty trivial function to write myself. I did it, and sure enough mine > has not logged any IDSC's at all since it was substituted for theirs. So > once again, a workaround was the best approach to take. > > On the off chance anyone else has had this problem, this will save you a > few moments of programming effort: > > -------------- > /*!-------------------------------------------------------------------------- > Function: N2C(n, nBase) > Summary: Convert n to string in nBase (nBaseMax = 36) > Description: Because NToC in xbTools++ gives IDSC's > ---------------------------------------------------------------------------*/ > FUNCTION N2C(n, nBase) > LOCAL cOutStr := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' > LOCAL cRet := cOutStr[(n%nBase)+1] > > IF n > nBase Recurse for greater digits > cRet := N2C(INT(n/nBase), nBase) + cRet > ENDIF > > RETURN cRet > > -------------- > > Best regards, > > Charlie Freeman | |
Frankie | Re: NTOC() IDSC Error on Thu, 20 Jan 2011 03:53:08 +0800 Hi, Thank you for providing the work around. I happen to use NToC() recently and it works on the 1st app but have showed IDSC on the 2nd app constantly. As a result, i searched the NG and found your solution except there's an error in the code. This line IF n > nBase Recurse for greater digits should be changed to IF n >= nBase Recurse for greater digits to get the correct result. Regards Frankie On Wed, 25 Mar 2009 00:00:45 -0400, Charles Freeman wrote: > For the last few years my client's error logs have showed infrequent but > consistent IDSC errors in the internal NTOC() function. By infrequent, I > would mean it would IDSC two or three times a week on a function that gets > called thousands of times per day. > > It's legacy stuff left over from Clipper days; I used NTOC() to compress a > date into a three character space as follows: > > cResult := NTOC(dDate - STOD(19800101), 32) > > Using this I date stamp every record of every database in my application. I > never changed the system when going to Xbase++ because of a zillion legacy > databases at client sites that would need to change; besides, it worked. > > At any rate I've reported the IDSC to Alaska several times over the years. > To their credit they test it and it works fine, which is the end of their > interest in the subject. Of course it works fine, my results are the > same... 99.999% of the time. But IDSC's just don't cut it with my clients, > even if they only occur a few times per week, and this was one of the last > to go. > > I finally had a "duh!" moment a few months ago and realized that NTOC() was > a pretty trivial function to write myself. I did it, and sure enough mine > has not logged any IDSC's at all since it was substituted for theirs. So > once again, a workaround was the best approach to take. > > On the off chance anyone else has had this problem, this will save you a > few moments of programming effort: > > -------------- > /*!-------------------------------------------------------------------------- > Function: N2C(n, nBase) > Summary: Convert n to string in nBase (nBaseMax = 36) > Description: Because NToC in xbTools++ gives IDSC's > ---------------------------------------------------------------------------*/ > FUNCTION N2C(n, nBase) > LOCAL cOutStr := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' > LOCAL cRet := cOutStr[(n%nBase)+1] > > IF n > nBase Recurse for greater digits > cRet := N2C(INT(n/nBase), nBase) + cRet > ENDIF > > RETURN cRet > > -------------- > > Best regards, > > Charlie Freeman | |
Thomas Braun | Re: NTOC() IDSC Error on Thu, 20 Jan 2011 17:30:16 +0100 Frankie wrote: > Thank you for providing the work around. I happen to use NToC() recently > and it works on the 1st app but have showed IDSC on the 2nd app constantly. Replying to a nearly 2 year old thread... nice Just copied the NTOC function to my common functions prg file. Thomas |