Solved

Undefined function

Posted on 2006-07-06
4
915 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

695 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