0

This procedure is called just before the answer is written to a binary file to ensure it is in the correct format. It works but I need it to repeat until it is an integer. I was trying to use a 'repeat','until' but wasnt sure what the 'until' condition woudld be. At the moment it displays the message and then carries on regardless.

Procedure ValidateAnswer;
begin
 try
  ValidatedAnswer:=StrToInt(QuestionnaireForm.Answer.Text);
 except
 ShowMessage('Answer must be an integer');
 end;
end;

Thanks!

2
Contributors
3
Replies
7
Views
4 Years
Discussion Span
Last Post by pritaeas
0

I don't think it can be done in it's current form. The input text will never change inside any loop, so it will be endless. Please explain what you are trying to achieve. (or perhaps some more code)

0

I am writing answers to a binary file. The answer to one of the questions needs to be an integer. So that the program doesn't crash I need to make sure it is an integer before assigning it into the binary file.

I ideally want it to display the message and then go back to the form allowing someone to correct their answer. At the moment It just displays the message and then carries on regardless.

I suppose I don't want a 'repeat' but I don't want it to do anything else such as writing to the file until this answer has been changed.

Hope that makes sense!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.