Solved

Undefined function

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Eclipse variable value view scroll 3 154
How to edit a midi track 9 166
AJAX function() is succeeding, but not posting correctly 6 75
I could not build boost code, 10 87
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
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 and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

770 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