tw2383.pp 654 B

123456789101112131415161718192021222324252627
  1. { %fail }
  2. { Source provided for Free Pascal Bug Report 2383 }
  3. { Submitted by "Anton Roolaid" on 2003-02-18 }
  4. { e-mail: [email protected] }
  5. program VarParameterLoop;
  6. const
  7. Elements = 3; { Array size }
  8. Arr: array [0 .. Elements - 1] of char = ('B', 'U', 'G');
  9. function FindIndex(chElement: char; var iIndex: integer): boolean;
  10. begin
  11. FindIndex := false; { Not found }
  12. { Using a variable parameter should not be allowed }
  13. for iIndex := 0 to Elements - 1 do
  14. if Arr[iIndex] = chElement then exit(true) { Found }
  15. end;
  16. var
  17. i: integer;
  18. begin
  19. if FindIndex('U', i) then
  20. writeln('The index is ', i)
  21. else
  22. writeln('Not found')
  23. end.