Solved

Undefined function

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now