Solved

Undefined function

Posted on 2006-07-06
4
912 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 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

765 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