Forum > Beginners

String comparing [Split from: Operator prededence with @ and []]

(1/4) > >>

ssawgift:

--- Quote from: Thaddy on November 27, 2022, 08:44:42 am ---Also, things like stricomp are highly discouraged. (Usually bad coding practice) It assumes a zero terminated array of AnsiChar. (Pchar) It is usually better to manipulate strings'the Pascal way: in this case https://www.freepascal.org/docs-html/rtl/sysutils/comparetext.html

--- End quote ---
I don't want to use CompareText and related functions (StartsWith/EndsWith) because the RTL implementation is horrible!

Thaddy:
 >:D Which part is horrible?  ;D then we can fix it.... (but I think you are wrong anyway)
We will always help. Even beginners. And this forum is quite proud of that.

MarkMLl:

--- Quote from: ASerge on November 27, 2022, 10:38:14 am ---
--- Quote from: ssawgift on November 27, 2022, 06:35:10 am ---The doc page (https://wiki.freepascal.org/Operator) does not give me clue on the index operator []. Given the following code:

--- End quote ---
In pascal, [] is not an operator, but a syntactic part (special symbols). It is used for indexing arrays and properties, designating sets and dynamic arrays. It is also used in declaration. Since this is a syntactic part, it is taken into account before any operators.

--- End quote ---

...and that is irrespective of the impression that might be given by anything in the wiki, since A WIKI IS NOT DOCUMENTATION: the project documentation is based at https://www.freepascal.org/docs.html and it is that that the developers maintain and do their best to conform to.

MarkMLl

ssawgift:

--- Quote from: Thaddy on November 27, 2022, 01:00:17 pm --- >:D Which part is horrible?  ;D then we can fix it.... (but I think you are wrong anyway)
We will always help. Even beginners. And this forum is quite proud of that.

--- End quote ---
CompareText first uppercases the string and do a case-senstive compare.
StartsWith/EndsWith is literally making a copy of substrings and then do compare.
That's horrible. I once encountered a ticket on gitlab requesting to improve this.

Sorry, I think StrLComp is good in that it's using assembler code to do its work (at least for i386 arch).

Thaddy:
No that is not horrible but most efficient on most CPU's.
The days of the magic number 97 are looooooooooong gone...

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---begin  writeln (ord('A'):4, ord('a'):4, ord('a')-ord('A'):4);end. and that is a full program.

( You do not understand it anyway)

What,  exactly,  do you want? We will help.

And examine the assembler output when you 'think' you can handle that.

What is so horrible? Cosmetics? Curly Bracket hair?

Navigation

[0] Message Index

[#] Next page

Go to full version