T.R | Title | User | Personal Name | Date | Lines |
---|
3515.1 | code.cxx | SWETSC::EKLUND | On a clear day you can see forever | Wed Mar 26 1997 07:55 | 79 |
| //
// DESIGN ISSUES:
//
// A (part of a) character string is formatted according to the
// formatting rule = AN (Account Number).
//
// - A space is inserted between multiples of 4 characters,
// e.g. account number '12345678901234' will be formatted to
// '1234 5678 9012 34'
//
// INPUT PARAMETERS:
//
// argString A character string, where a part of it shall
// be formatted
// currStartPos Start position in 'argString' where the
// formatting shall start
// length Number of characters that shall be formatted
//
// OUTPUT PARAMETERS:
//
// argString Is now containing the result of the formatting
// length Number of characters after the formatting.
// E.g. if the formatting did result in inserting
// three spaces in the character string,
// the output length is 3 greater than the input length.
//
// CREATION DATE: 1997-01-27
//
// RETURN VALUE:
//
// TRUE Successful execution
//--
//
// INCLUDE FILES
//
#include <stdio.h> // TRUE/FALSE
#include "Utility_FormatString.h"
int Utility_FormatAccountNumber (char* argString,
const int currStartPos,
int& length)
{
int toInsert; // Number of spaces that shall be inserted
int index;
int anInt; // An integer
//
// Calculate the number of spaces that shall be inserted
//
toInsert = (length - 1) / 4;
for (index = length; toInsert > 0; index--)
{
// Start at the end of the current string and move characters
// forwards, until it is time to insert a space.
// Then continue moving characters again and so on.
argString [currStartPos + index + toInsert]
= argString [currStartPos + index];
//
// If index = 4, 8, 12, 16 etc, then it is time to insert a space
//
anInt = index % 4;
if (anInt == 0)
{
argString [currStartPos + index + toInsert - 1] = ' ';
toInsert--;
length++;
}
}
return TRUE;
}
//------------------------------------------------------------------------------
|
3515.2 | utility_formatstring.h | SWETSC::EKLUND | On a clear day you can see forever | Wed Mar 26 1997 07:56 | 63 |
| // Utility_FormatString.h
// Inneh�ller deklarationer f�r Utility_FormatString.cxx och
// dess underfunktioner
#ifndef Utility_FormatStringINCLUDED
#define Utility_FormatStringINCLUDED
const int maxParams = 50; // max number of unnamed parameters to
// the function Utility_FormatString
const int maxLength = 1000; // max length of the output message
// If you change the value of maxLength, you should also change the hardcoded
// values concerning the length of the raw text in Utility_GetRawText.Pcx.
// These values are defined in embedded SQL statements and therefore
// maxLength cannot be used.
struct paramTable
{ char type [3]; // 2 chars + NUL
char formatRule [3]; // 2 chars + NUL
int startPos;
int noOfChars;
};
//
// P R O T O T Y P E S
//
int Utility_FormatString (const char* language,
const char* msgName,
const int msgLength,
char* message,
...);
int Utility_GetRawText (const char* language,
const char* msgName,
char* rawText);
int Utility_SearchForParameters (const char* rawText,
paramTable* theParamTable,
int& highestIndex);
int Utility_AccessArguments (va_list& ap,
paramTable* theParamTable,
int highestIndex,
char* argString);
int Utility_ReplaceParameters (const char* rawText,
const char* argString,
const int msgLength,
const paramTable* theParamTable,
char* message);
int Utility_FormatAccountNumber (char* argString,
const int currStartPos,
int& length);
int Utility_FormatMoney (char* argString,
const int currStartPos,
int& length,
const double fpValue);
#endif
|
3515.3 | | SPECXN::DERAMO | Dan D'Eramo | Wed Mar 26 1997 10:58 | 18 |
| Which line does the error message point to?
#include <stdio.h> // TRUE/FALSE
Are TRUE/FALSE really defined in <stdio.h>? According to the
ANSI/ISO C standard they aren't. You might need to add
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
to your .cxx or .h file.
Dan
|
3515.4 | I think the problem is va_list | DECC::J_WARD | | Wed Mar 26 1997 11:03 | 6 |
|
I think the problem is that although va_list is declared
as a char* typedef in stdarg.h, somewhere else (in one of the
include files brought in by stdio.h) it is declared as
an actual variable. If you put an include of stdarg.h
before the include of stdio.h, then it seems to work ok.
|
3515.5 | Thanx, buglet or what ? | SWETSC::EKLUND | On a clear day you can see forever | Wed Mar 26 1997 11:23 | 7 |
| Hi and thanx to both.
Yeah, it worked including stdarg before stdio.
Beeing a C++ ignorant, is this really correct or a buglet ?
-Johan
|
3515.6 | buglet? | DECC::J_WARD | | Wed Mar 26 1997 11:27 | 8 |
|
Well, it's not a bug in the C++ compiler, but
it does seem like it might be a problem with the
VMS C headers... I didn't investigate fully where the
other (conflicting) declaration of va_list is or what the C
library standard has to say about va_list.
Perhaps someone better informed may know.
|
3515.7 | I do not see anything incorrect | TLE::D_SMITH | Duane Smith -- DEC C RTL | Wed Mar 26 1997 14:58 | 9 |
| The header file <utility_formatstring.h> uses va_list, but does nothing
to ensure that this type is actually defined. While this may not have
been a problem on another system, I believe that it was "by chance"
that va_list was defined by <stdio.h>. In a strict ANSI compilation
mode, va_list can only be defined by either including varargs.h or
stdarg.h.
To me the correct edit is to include <stdarg.h> in the header file
which uses va_list.
|
3515.8 | Thank you all | SWETSC::EKLUND | On a clear day you can see forever | Thu Mar 27 1997 03:01 | 5 |
| Hi,
Thanx a lot the explanation.
-Johan
|