changed: variables and functions are case-sensitive now

added:   variables and functions can have underline characters
         in their names


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@62 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2008-01-23 23:51:53 +00:00
parent ee05abc94d
commit 4e75bda5fc
10 changed files with 87 additions and 14 deletions

View File

@ -49,6 +49,8 @@
<param name="Keyword" value="max">
<param name="Keyword" value="min">
<param name="Keyword" value="builtin functions">
<param name="Keyword" value="sum">
<param name="Keyword" value="avg">
</object>
</head>
@ -193,6 +195,13 @@ the function returns the max value which can be held in this precision.</dd>
<dd>This functions takes any number of arguments. It returns the min value of them. If there aren't arguments
the function returns the min value which can be held in this precision.</dd>
<dt>sum(x1; x2; ...)</dt>
<dd>This functions takes one or more arguments. It returns the sum of them.</dd>
<dt>avg(x1; x2; ...)</dt>
<dd>This functions takes one or more arguments. It returns the arithmetic mean. (The sum divided by
the number of arguments)</dd>
</dl>
</body>

View File

@ -22,6 +22,7 @@
</thead>
<tr><td>( )</td><td>parentheses for grouping an expression</td><td>(1+3)*4</td></tr>
<tr><td>- + # &amp;</td><td>unary minus and plus, and operators for changing the base (radix)</td><td>-10</td></tr>
<tr><td>without an operator</td><td>short form of multiplicating (only if the second argument is a variable or function)</td><td>3y</td></tr>
<tr><td>^</td><td>powering</td><td>3^2</td></tr>
<tr><td>* /</td><td>multiplication and division</td><td>10*20</td></tr>
<tr><td>+ -</td><td>addition and subtraction</td><td>10-30</td></tr>

View File

@ -17,9 +17,9 @@
<p>
You are allowed to define your own variables and functions. As a name of a variable or a function
can be a name consists of letters and digits but the first character must be a letter. Names are case-insensitive
that means 'name' is the same as 'NaMe'. For example these
are correct names: a, b, c3, myname, etc. During defining variables and functions you can call another
can be a name consists of letters, digits or an underline character but the first character must be a letter.
From version 0.8.3 names are case-sensitive that means 'name' is not the same as 'NaMe'. For example these
are correct names: a, b, c3, MyName, etc. During defining variables and functions you can call another
variables and functions but you cannot call a variable or a function twice. Recurrence calling are not allowed.
</p>

View File

@ -97,10 +97,10 @@ int i;
pchar = new char[temporary_buffer_size];
GetDlgItemText(hWnd, IDC_EDIT_FUNCTION_NAME, pchar, temporary_buffer_size);
name = Variables::ChangeToSmallLetters( Variables::StripWhiteCharacters(pchar) );
name = Variables::StripWhiteCharacters(pchar);
GetDlgItemText(hWnd, IDC_EDIT_FUNCTION_VALUE, pchar, temporary_buffer_size);
value = Variables::ChangeToSmallLetters( Variables::StripWhiteCharacters(pchar) );
value = Variables::StripWhiteCharacters(pchar);
parameters = (int)SendDlgItemMessage(hWnd,IDC_COMBO_FUNCTION_PARAM,CB_GETCURSEL,0,0);

View File

@ -44,6 +44,26 @@ IniParser::IniParser()
{
strip_white_characters_from_value = true;
convert_value_to_small_letters = true;
section_case_sensitive = false;
pattern_case_sensitive = false;
}
void IniParser::ConvertValueToSmallLetters(bool conv)
{
convert_value_to_small_letters = conv;
}
void IniParser::SectionCaseSensitive(bool sens)
{
section_case_sensitive = sens;
}
void IniParser::PatternCaseSensitive(bool sens)
{
pattern_case_sensitive = sens;
}
@ -148,7 +168,10 @@ IniParser::Error IniParser::ReadSection(std::string & section)
}
while( IsSectionCharacter( (c = ReadCharacter()) ) )
section += LowerCase(c);
if( section_case_sensitive )
section += c;
else
section += LowerCase(c);
if( c != ']' )
{
@ -220,7 +243,11 @@ IniParser::Error IniParser::ReadExpression(std::string & pattern, std::string &
while( IsPatternCharacter(c) )
{
pattern += LowerCase(c);
if( pattern_case_sensitive )
pattern += c;
else
pattern += LowerCase(c);
c = ReadCharacter();
}

View File

@ -133,6 +133,34 @@ public:
Error ReadFromFile(const char * path);
/*!
when true the names of sections will be case-sensitive
e.g.
when true: '[foo]' is not equal '[Foo]'
default: false
*/
void SectionCaseSensitive(bool sens);
/*!
when true the names of patterns will be case-sensitive
e.g.
when true: 'foo = 4' is not equal 'Foo = 4'
default: false
*/
void PatternCaseSensitive(bool sens);
/*!
if conv=true (default) that the whole characters in a value
will be changed into small letters
*/
void ConvertValueToSmallLetters(bool conv);
private:
typedef std::map<std::string, std::string *> Table;
@ -144,6 +172,8 @@ private:
int line;
bool strip_white_characters_from_value;
bool convert_value_to_small_letters;
bool section_case_sensitive;
bool pattern_case_sensitive;
Error Read();
Error ReadSection(std::string & section);

View File

@ -283,8 +283,8 @@ void Languages::InitGuiMessagesTab()
"Mathematical calculator TTCalc %d.%d.%d%s%s\r\n"
"Author: Tomasz Sowa\r\n"
"Contact: t.sowa@slimaczek.pl\r\n"
"Licence: (New) BSD licence\r\n"
"Project page: http://sourceforge.net/projects/ttcalc\r\n"
"Licence: BSD (open source)\r\n"
"Project page: http://ttcalc.sourceforge.net\r\n"
"Bignum library: TTMath %d.%d.%d%s\r\n"
"Programming language: C++\r\n"
"Compiler: %s\r\n"
@ -406,8 +406,8 @@ void Languages::InitGuiMessagesTab()
"Kalkulator matematyczny TTCalc %d.%d.%d%s%s\r\n"
"Autor: Tomasz Sowa\r\n"
"Kontakt: t.sowa@slimaczek.pl\r\n"
"Licencja: (New) BSD\r\n"
"Strona projektu: http://sourceforge.net/projects/ttcalc\r\n"
"Licencja: BSD (open source)\r\n"
"Strona projektu: http://ttcalc.sourceforge.net\r\n"
"Biblioteka du¿ych liczb: TTMath %d.%d.%d%s\r\n"
"Jêzyk programowania: C++\r\n"
"Kompilator: %s\r\n"

View File

@ -1038,7 +1038,8 @@ SHELLEXECUTEINFO exec;
exec.fMask = SEE_MASK_FLAG_NO_UI | SEE_MASK_NOCLOSEPROCESS;
exec.hwnd = 0;
exec.lpVerb = "open";
exec.lpFile = "http://sourceforge.net/projects/ttcalc";
//exec.lpFile = "http://sourceforge.net/projects/ttcalc";
exec.lpFile = "http://ttcalc.sourceforge.net";
exec.lpParameters = 0;
exec.lpDirectory = "";
exec.nShow = SW_SHOWNORMAL;

View File

@ -604,6 +604,11 @@ IniParser::Section temp_variables, temp_functions;
IniParser::Section::iterator ic;
std::string ini_value[20];
iparser.ConvertValueToSmallLetters(false);
iparser.SectionCaseSensitive(false);
// we have variables and functions case-sensitive
iparser.PatternCaseSensitive(true);
iparser.Associate( "global|always.on.top", &ini_value[0] );
iparser.Associate( "global|view", &ini_value[1] );

View File

@ -109,10 +109,10 @@ char * pchar;
pchar = new char[temporary_buffer_size];
GetDlgItemText(hWnd, IDC_EDIT_VARIABLE_NAME, pchar, temporary_buffer_size);
name = ChangeToSmallLetters( StripWhiteCharacters(pchar) );
name = StripWhiteCharacters(pchar);
GetDlgItemText(hWnd, IDC_EDIT_VARIABLE_VALUE, pchar, temporary_buffer_size);
value = ChangeToSmallLetters( StripWhiteCharacters(pchar) );
value = StripWhiteCharacters(pchar);
delete [] pchar;