Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

understanding string handling procedures and functions 5

Status
Not open for further replies.

delphiwiz

Instructor
Sep 5, 1999
2
ZA
Can anyone suggest a way to understand the basic string handling procedures and fuctions used in Delphi:<br>
Copy,delet, insert, length, pos? <br>
Thanks<br>
Also, what is the fastest way of learning Delphi? (I don't know pascal)
 
If you're a past C programmer, you have to relearn string thinking. It took me a while. Don't worry about memory allocation, it takes care of itself. There is no terminator character either, there is a length 'byte' (it's a 32 bit longword, in reality). Without oversimplifying, a string is a dynamic array of characters with an auto-calculating length. The function 'length' is a good example for this, as it is an overloaded function, working on both strings and dynamic arrays, returning the length of the string (in characters), or the dynamic array (in array base units, whatever they happen to be). A string of length 0 is an empty string, and the other routines give you access to the string by character position.<br>
<br>
The easiest way to learn Delphi: I took a lot of old visual C++ programs I had written, and rewrote them (Back in the days of Delphi 1) This assumes you're a VC programmer. If you're coming from VB, I don't know, as I've never done it, and I understand it's not really OO.
 
there are two types of string in delphi. you can use pascal string types or PChar. the difference between the two is that PChar uses a pointer and it begin with s[0] and terminated with #0 character and when using this you have to worry about allocating memory for the string value, string functions for PChar is different from Pascal string, you can use stralloc to allocate memory for the string and strdispose to dispose the allocated memory for the string and some other functions you have to look in the delphi help, PChar is very useful in passing a string parameter in a dll, since it cannot accept a pascal string type. In Pascal string type you don't have to worry about the memory allocation and deallocation, the value begins with s[1] up to s[length] and there is no terminator because the value of the length is in s[0]. the functions you have mention is for the pascal string types. i hope this will help you.<br>
<br>
Rommel<br>
<br>

 
I am answering the second part of your question as the first part has been answered.<br>
<br>
The best way to learn Delphi is to first learn Pascal by reading any of the Mastering Turbo Pascal books written by Tom Swan. If you can get hold of the Turbo Pascal manuals, they are also well written.<br>
<br>
The visual part of Delphi is pretty intuitive and obvious. After a few hours of dabbling and reading the online help you should get a hang of it. But the real power is in the underlying language of pascal. You derive maximum pleasure (at least I do) by writing pure code. The visual part is like the icing on a cake.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top