Ok this is the problem...

Basically when someone enters a figure, say £100, I want to remove the £ sound before doing some processing.

at the moment I have this:

program remove_pound;

uses
crt, sysutils;

var
s: string;
p: char;

begin
P := chr(156);
Writeln('Please enter an amount of money: ');
readln(s);
if p in s then  // At the moment this is wrong. I have no idea why
  begin
       // I then need some code here to remove the £ sign
  end;

The main problem is that I don't have a wide knowledge of all the possible commands in pascal, only been programming for a couple of days!!

If someone could explain how to achieve the above I would be most grateful.

Thanks

Greg
end.

program remove_pound;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
I:    Integer;
P:    Char;
S:    string;

begin
  P := Chr(156);
  Writeln('Please enter an amount of money: ');
  Readln(S);
  I := Pos(P, S);
  if (I>0) then 
    Delete(S, I, 1);
  Writeln('Amount of money: ' + S);
  Readln;
end.

I used delete procedure as finalist did it.
Just I do it a bit otherwise.

program remove_pound;

uses
crt, sysutils;

var
   s: string;  (*this stores maximum 255 character,this can be treat as array too*)
   p: char;    (*this holds only one character*)
   i:byte;     (*loop variable*)
   temp:string;(*temp var*)
   count:integer;

begin
     P := chr(156);  (*after this ,p is equals to Ł*)
     writeln('Please enter an amount of money: ');
     readln(s);

     count:=1;
     temp:='';
     for i:=1 to length(s) do begin
         if s[i] = p then begin
           delete(s,i,count); (*look at the notes!*)
         end;
         temp:=s;
     end;
     writeln('temp is: ',temp);

(*
Delete (procedure)

Deletes a substring from a string.

Declaration
procedure Delete(var S: String; Index: Integer; Count:Integer);
Target:Windows, Real, Protected
Remarks
S is a string-type variable.
Index and Count are integer-type expressions.
Delete deletes Count characters from S starting at the Indexth position.
If Index is larger than the length of S, no characters are deleted.
If Count specifies more characters than remain starting at the Indexth position,
the remainder of the string is deleted.

*)

    readln;
end.
(*fixed by FlamingClaw 2010.01.23.*)

There is another way without using the procedure Delete();, just using an additional string variable:

program removepound;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
I:    Integer;
L:    Integer;
C:    Char;
S:    string;
T:    string;

begin
  T := '';
  C := Chr(156);
  Writeln('Please enter an amount of money: ');
  Readln(S);
  L := Length(S);
  for I := 1 to L do
    if (S[I]<>C) then
      T := T + S[I];
  Writeln('Amount of money: ' + T);
  Readln;
end.

I created another solution without delete procedure.
This program writes only numbers to the screen,so any else character is ignored... :idea:

program remove_pound2;

uses crt;

var h:set of char;
    s,temp:string;
    i:byte;

begin
     clrscr;
     temp:='';
     h:=[];
     h:=['0'..'9']; (*just numbers*)
     write('please enter an amount of money: ');
     readln(s);
     for i:=1 to length(s) do begin
         if (s[i] in h) then temp:=concat(temp,s[i]);
     end;
     write('the entered amount: ',temp);
     readln;
end.
(*by FlamingClaw 2010.01.24.sunday*)
program pound_remove;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
I:    Integer;
L:    Integer;
C:    Char;
S:    string;
T:    string;

begin
  T := '';
  C := '.';  { Decimal Separator }
  Writeln('Please enter an amount of money: ');
  Readln(S);
  L := Length(S);
  for I := 1 to L do
    if (S[I] in [C,'0'..'9']) then  { Only Decimal Separator & Digits }
      T := T + S[I];
  Writeln('Amount of money: ' + T);
  Readln;
end.

finalist
I think,now we can wait for marking as solved :D

finalist
I think,now we can wait for marking as solved :D

FlamingClaw,
you and me waiting for accepting this thread as solved:icon_idea:

Thanks you guys once again for solving my problems ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.