Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Undefined function

Posted on 2006-07-06
4
Medium Priority
?
939 Views
Last Modified: 2013-11-17
I'm a novice with cBuilder 6 and am having a problem with a "function" call.

I'm trying to fill an AnsiString variable with the leftmost 7 charaters of another variable or literal value.

If I try and use:
   branchnum = LeftStr("Programmer", 7);  or
   branchnum = MidStr("Programmer", 1, 7);

  I receive a "Call to undefined function" ('LeftStr', 'MidStr' respectively)

*******************************************************
However
  branchnum = UpperCase("Programmer");
  Works OK

What am I missing?

Thanks
0
Comment
Question by:jdr0606
  • 3
4 Comments
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17050890
Hi the LeftStr and MidStr functions are members of the AnsiString class so you should do:

branchnum.LeftStr("Programmer", 7);  or
branchnum.MidStr("Programmer", 1, 7);
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17050950
The error >>  "Call to undefined function" ('LeftStr', 'MidStr' respectively)

means the functions do not exist. Make sure you have included the correct headers.

Btw I am not sure if the LeftStr and MidStr functions are members of AnsiString it is a long time sice I have used builder.

The reason UpperCase works is because you have included the correct libraries, ie the header files.
0
 
LVL 11

Expert Comment

by:Jase-Coder
ID: 17050989
You must include #include "strutils.h"
0
 
LVL 25

Accepted Solution

by:
kode99 earned 2000 total points
ID: 17051918
As pointed out there are no midstr, leftstr functions in the actual AnsiString class.  You would just use SubString which allows you to do left, mid and also right type functionality.

So your example would go like this,

AnsiString branchnum;
AnsiString SomeVar = "Programmer";

branchnum = SomeVar.SubString(1,7);


In the SubString call the first number is the index, which starts at 1 and the second is the length or the desired section.

I would suggest taking a good read over the help for AnsiString as it has a lot of functionality built in which can save re-inventing the wheel.

So for the caps version,

branchnum = SomeVar.UpperCase();

The reason that UpperCase(<str here>) works is because it is also a part of the string handing functions,  so look under help for 'string handling routines' and you will get a full list of additional functions for working with AnsiStrings.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question