Recent

Author Topic: Case String of Error  (Read 1134 times)

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Case String of Error
« on: November 27, 2020, 09:38:14 am »
Hello,


Pls Help i don't understand:

Code: Pascal  [Select][+][-]
  1. Case Trim(SamBesch) Of
  2.  
  3.       ('1/2 '+Afz+Afz),('½'+Afz+Afz) : Begin
  4.           If EinAus = 0 then Begin      //Ein
  5.              BsamEin.Caption := (12.7).toString;
  6.           End Else Begin
  7.              BSamAus.Caption := (12.7).toString;
  8.           End;
  9.       End;
  10.  

it is expecting String Case types BUT this is A String Case type (AFZ is ascii char 39)
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Case String of Error
« Reply #1 on: November 27, 2020, 09:51:03 am »
This is simply a case statement with string selectors of the form:
Code: Pascal  [Select][+][-]
  1. case Trim(SamBesch) of
  2.   string1, string2:
  3.      begin
  4.         some code...
  5.      end;
  6. end;

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Re: Case String of Error
« Reply #2 on: November 27, 2020, 10:01:18 am »
doesn't work
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

bytebites

  • Hero Member
  • *****
  • Posts: 633
Re: Case String of Error
« Reply #3 on: November 27, 2020, 10:36:45 am »
Show whole code

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Case String of Error
« Reply #4 on: November 27, 2020, 11:08:14 am »
And explain a little more what "doesn't work" means: what does it do that it shouldn't?, what doesn't do that it should?, what are the inputs?, etc.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Re: Case String of Error
« Reply #5 on: November 27, 2020, 11:29:37 am »
Its Just A Case String of
   ...
 ...

But i Get The Error that "('1/2 '+Afz+Afz)" isn't a String
 i use Afz Because the " ' " Char is used for Strings so i wasn't Sure if i could have just done this : ('1/2 ''''')
im Just building this String and then use it in case Statement
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Re: Case String of Error
« Reply #6 on: November 27, 2020, 11:30:01 am »
replaced Case with If and Else
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Case String of Error
« Reply #7 on: November 27, 2020, 11:45:38 am »
i use Afz Because the " ' " Char is used for Strings so i wasn't Sure if i could have just done this : ('1/2 ''''')
im Just building this String and then use it in case Statement

Whenever you need a quote inside a string constant,
'You''ve just to double it',
so yeah, '1/2 ''''' would store: 1/2 '' in the string.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Weitentaaal

  • Hero Member
  • *****
  • Posts: 503
  • Weitental is a very beautiful garbage depot.
Re: Case String of Error
« Reply #8 on: November 27, 2020, 11:50:57 am »
Thanks Works Now
Lazarus: 2.0.12 x86_64-win64-win32/win64
Compiler Version: 3.2.2

 

TinyPortal © 2005-2018