Recent

Author Topic: Is there a function called MidStr??  (Read 2382 times)

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: Is there a function called MidStr??
« Reply #15 on: January 30, 2023, 12:30:42 am »
Other midstr option (complete program) using type helper for AnsiString:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2. uses sysutils;
  3. begin
  4.   writeln('Impossible is for the unwilling'.substring(14,3));  // prints for
  5. end.

Can you assign this to a Variable?

Variable:='Impossible is for the unwilling'.substring(14,3)
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

dsiders

  • Hero Member
  • *****
  • Posts: 1077
Re: Is there a function called MidStr??
« Reply #16 on: January 30, 2023, 12:38:37 am »
You have function Copy: **s://www.freepascal.org/docs-html/rtl/system/copy.html

And UTF8Copy: **s://lazarus-ccr.sourceforge.io/docs/lazutils/lazutf8/utf8copy.html
These two links don't seem to work...

The forum software seems to be borking the urls. Replace ** with h-t-t-p (no dashes).

Code: Text  [Select][+][-]
  1. https://www.freepascal.org/docs-html/rtl/system/copy.html
  2. https://lazarus-ccr.sourceforge.io/docs/lazutils/lazutf8/utf8copy.html
« Last Edit: January 30, 2023, 12:43:05 am by dsiders »
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: Is there a function called MidStr??
« Reply #17 on: January 30, 2023, 05:21:44 am »
The forum software seems to be borking the urls. Replace ** with h-t-t-p (no dashes).
Understood.
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14363
  • Sensorship about opinions does not belong here.
Re: Is there a function called MidStr??
« Reply #18 on: January 30, 2023, 08:48:06 am »
Can you assign this to a Variable?

Variable:='Impossible is for the unwilling'.substring(14,3)
Yes. But not on declaration, since substring is a function that is not evaluated at declaration time. But it will if assigned when in the program or procedure body.
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2. uses sysutils;
  3. var s:string; // this is not possible here: = 'Impossible is for the unwilling'.substring(14,3);
  4. begin
  5.   s:= 'Impossible is for the unwilling'.substring(14,3);  // prints for
  6.   writeln(s);
  7. end.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

OC DelGuy

  • Full Member
  • ***
  • Posts: 121
Re: Is there a function called MidStr??
« Reply #19 on: January 31, 2023, 01:55:20 am »
Can you assign this to a Variable?

Variable:='Impossible is for the unwilling'.substring(14,3)
Yes. But not on declaration, since substring is a function that is not evaluated at declaration time. But it will if assigned when in the program or procedure body.
Got it.  8-)
Free Pascal Lazarus Version #: 2.2.4
Date: 24 SEP 2022
FPC Version: 3.2.2
Revision: Lazarus_2_2_4
x86_64-win64-win32/win64

 

TinyPortal © 2005-2018