Recent

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

OC DelGuy

  • Full Member
  • ***
  • Posts: 112
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: 816
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 2.3.0 documentation at: https://dsiders.gitlab.io/lazdocsnext

OC DelGuy

  • Full Member
  • ***
  • Posts: 112
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: 12898
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.
Who is responsable for that!! The caller or the callee.. Out! ya'll, NOW. In UTC time, please, so maybe Yesterday or tomorrow.

OC DelGuy

  • Full Member
  • ***
  • Posts: 112
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