how to do this ?

Hi,Im new to pascal ..
I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.

And another question is how do i express 'null' in pascal ?

Thank you for reading this message!

Comments

  • [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : Hi,Im new to pascal ..
    : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    :
    : And another question is how do i express 'null' in pascal ?
    :
    : Thank you for reading this message!
    :
    :
    Here is a code, which checks the users input for non-empty inputs:
    [code]
    repeat
    readln(s);
    if s = '' then
    writeln('type at least something');
    until s <> '';
    [/code]
    If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).


  • : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : Hi,Im new to pascal ..
    : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : :
    : : And another question is how do i express 'null' in pascal ?
    : :
    : : Thank you for reading this message!
    : :
    : :
    : Here is a code, which checks the users input for non-empty inputs:
    : [code]
    : repeat
    : readln(s);
    : if s = '' then
    : writeln('type at least something');
    : until s <> '';
    : [/code]
    : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    :
    :
    : Thank you very much, problem solved.

  • : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : Hi,Im new to pascal ..
    : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : :
    : : And another question is how do i express 'null' in pascal ?
    : :
    : : Thank you for reading this message!
    : :
    : :
    : Here is a code, which checks the users input for non-empty inputs:
    : [code]
    : repeat
    : readln(s);
    : if s = '' then
    : writeln('type at least something');
    : until s <> '';
    : [/code]
    : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    :
    :
    : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?

  • : : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : : Hi,Im new to pascal ..
    : : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : : :
    : : : And another question is how do i express 'null' in pascal ?
    : : :
    : : : Thank you for reading this message!
    : : :
    : : :
    : : Here is a code, which checks the users input for non-empty inputs:
    : : [code]
    : : repeat
    : : readln(s);
    : : if s = '' then
    : : writeln('type at least something');
    : : until s <> '';
    : : [/code]
    : : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    : :
    : :
    : : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?
    :
    :
    Could you be more specific? Which expression s = '' or s <> ''? Also did you make s a string or something else?
  • : : : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : : : Hi,Im new to pascal ..
    : : : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : : : :
    : : : : And another question is how do i express 'null' in pascal ?
    : : : :
    : : : : Thank you for reading this message!
    : : : :
    : : : :
    : : : Here is a code, which checks the users input for non-empty inputs:
    : : : [code]
    : : : repeat
    : : : readln(s);
    : : : if s = '' then
    : : : writeln('type at least something');
    : : : until s <> '';
    : : : [/code]
    : : : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    : : :
    : : :
    : : : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?
    : :
    : :
    : Could you be more specific? Which expression s = '' or s <> ''? Also did you make s a string or something else?
    :
    The error goes '<28,7> Error: Incompatible types: got "SMALLINT" expected "SHORTSTRING"' and other error is 'Fatal: There were 1 errors comiling module, stopping' I knew something was wrong with the expressions ' ' and < > '' so i delibrately changed ' ' to 0 then i go to compile, once again there is no error, thus i come to realise that the problem occurs at ' ' . But im not sure why ' ' wouldn't work but theres got to be a way to fix it. Once again thanks for your continuous help.


  • : : : : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : : : : Hi,Im new to pascal ..
    : : : : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : : : : :
    : : : : : And another question is how do i express 'null' in pascal ?
    : : : : :
    : : : : : Thank you for reading this message!
    : : : : :
    : : : : :
    : : : : Here is a code, which checks the users input for non-empty inputs:
    : : : : [code]
    : : : : repeat
    : : : : readln(s);
    : : : : if s = '' then
    : : : : writeln('type at least something');
    : : : : until s <> '';
    : : : : [/code]
    : : : : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    : : : :
    : : : :
    : : : : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?
    : : :
    : : :
    : : Could you be more specific? Which expression s = '' or s <> ''? Also did you make s a string or something else?
    : :
    : The error goes '<28,7> Error: Incompatible types: got "SMALLINT" expected "SHORTSTRING"' and other error is 'Fatal: There were 1 errors comiling module, stopping' I knew something was wrong with the expressions ' ' and < > '' so i delibrately changed ' ' to 0 then i go to compile, once again there is no error, thus i come to realise that the problem occurs at ' ' . But im not sure why ' ' wouldn't work but theres got to be a way to fix it. Once again thanks for your continuous help.
    :
    :
    :
    The problem is that the variable you are using is an integer and you cannot check if an user-entered integer is empty (which is not the same as 0).
    If you still want to check if the user input is not empty, you need to use a temporary string-variable to hold the input. If the user ahs entered something, you can then convert that into an integer.
  • : : : : : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : : : : : Hi,Im new to pascal ..
    : : : : : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : : : : : :
    : : : : : : And another question is how do i express 'null' in pascal ?
    : : : : : :
    : : : : : : Thank you for reading this message!
    : : : : : :
    : : : : : :
    : : : : : Here is a code, which checks the users input for non-empty inputs:
    : : : : : [code]
    : : : : : repeat
    : : : : : readln(s);
    : : : : : if s = '' then
    : : : : : writeln('type at least something');
    : : : : : until s <> '';
    : : : : : [/code]
    : : : : : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    : : : : :
    : : : : :
    : : : : : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?
    : : : :
    : : : :
    : : : Could you be more specific? Which expression s = '' or s <> ''? Also did you make s a string or something else?
    : : :
    : : The error goes '<28,7> Error: Incompatible types: got "SMALLINT" expected "SHORTSTRING"' and other error is 'Fatal: There were 1 errors comiling module, stopping' I knew something was wrong with the expressions ' ' and < > '' so i delibrately changed ' ' to 0 then i go to compile, once again there is no error, thus i come to realise that the problem occurs at ' ' . But im not sure why ' ' wouldn't work but theres got to be a way to fix it. Once again thanks for your continuous help.
    : :
    : :
    : :
    : The problem is that the variable you are using is an integer and you cannot check if an user-entered integer is empty (which is not the same as 0).
    : If you still want to check if the user input is not empty, you need to use a temporary string-variable to hold the input. If the user ahs entered something, you can then convert that into an integer.
    :

    Hi again, can you tell me how to write a temporary string- variable ? and what exactly is a temporary string-variable.
  • : : : : : : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : : : : : : Hi,Im new to pascal ..
    : : : : : : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : : : : : : :
    : : : : : : : And another question is how do i express 'null' in pascal ?
    : : : : : : :
    : : : : : : : Thank you for reading this message!
    : : : : : : :
    : : : : : : :
    : : : : : : Here is a code, which checks the users input for non-empty inputs:
    : : : : : : [code]
    : : : : : : repeat
    : : : : : : readln(s);
    : : : : : : if s = '' then
    : : : : : : writeln('type at least something');
    : : : : : : until s <> '';
    : : : : : : [/code]
    : : : : : : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    : : : : : :
    : : : : : :
    : : : : : : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?
    : : : : :
    : : : : :
    : : : : Could you be more specific? Which expression s = '' or s <> ''? Also did you make s a string or something else?
    : : : :
    : : : The error goes '<28,7> Error: Incompatible types: got "SMALLINT" expected "SHORTSTRING"' and other error is 'Fatal: There were 1 errors comiling module, stopping' I knew something was wrong with the expressions ' ' and < > '' so i delibrately changed ' ' to 0 then i go to compile, once again there is no error, thus i come to realise that the problem occurs at ' ' . But im not sure why ' ' wouldn't work but theres got to be a way to fix it. Once again thanks for your continuous help.
    : : :
    : : :
    : : :
    : : The problem is that the variable you are using is an integer and you cannot check if an user-entered integer is empty (which is not the same as 0).
    : : If you still want to check if the user input is not empty, you need to use a temporary string-variable to hold the input. If the user ahs entered something, you can then convert that into an integer.
    : :
    :
    : Hi again, can you tell me how to write a temporary string- variable ? and what exactly is a temporary string-variable.
    :
    I assume that you what a string variable is. A temporary variable is nothing more than a variable, which only holds a value for a short time. These are often used to perform a check, speed-up a process, or for debug purposes.
    In this case you want the user to enter a number, but you also want to check if the number he entered isn't empty. In this case the following code doesn't work correctly:
    [code]
    var
    i: integer;
    begin
    readln(i);
    if i = 0 then
    writeln('empty text');
    end;
    [/code]
    because the ser can enter a 0, which isn't an empty text. The correct way to handle such a thing is to store the entered number in a string, and check if that string is empty:
    [code]
    var
    i, c: integer;
    s: string
    begin
    readln(s);
    if s = '' then
    writeln('empty text');
    Val(s, i, c);
    end;
    [/code]
    Now if the user presses ENTER without typing anything before it, the s variable will hold an empty string. After the Val() statement, the value in the string is obsolete, since it is the same value as the i. You can even expand this code to check if the string was a number or not.
    I hope this explains, what I mean by a temporary variable.
  • : : : : : : : [b][red]This message was edited by zibadian at 2004-6-21 4:12:56[/red][/b][hr]
    : : : : : : : : Hi,Im new to pascal ..
    : : : : : : : : I have compiled a program that allows ppl to enter their salesdatas , they have to enter the months for some selected years. the problem is how do i code a warning message that will be displayed whenever the user hasn't entered anything.
    : : : : : : : :
    : : : : : : : : And another question is how do i express 'null' in pascal ?
    : : : : : : : :
    : : : : : : : : Thank you for reading this message!
    : : : : : : : :
    : : : : : : : :
    : : : : : : : Here is a code, which checks the users input for non-empty inputs:
    : : : : : : : [code]
    : : : : : : : repeat
    : : : : : : : readln(s);
    : : : : : : : if s = '' then
    : : : : : : : writeln('type at least something');
    : : : : : : : until s <> '';
    : : : : : : : [/code]
    : : : : : : : If you are referring to a null-pointer, you need to use the word "nil" an empty string is a " '' " (two single quotes).
    : : : : : : :
    : : : : : : :
    : : : : : : : hi after i sub the codes into my program, the compiler gives me an error saying something is wrong with the expression '' . can anybody help?
    : : : : : :
    : : : : : :
    : : : : : Could you be more specific? Which expression s = '' or s <> ''? Also did you make s a string or something else?
    : : : : :
    : : : : The error goes '<28,7> Error: Incompatible types: got "SMALLINT" expected "SHORTSTRING"' and other error is 'Fatal: There were 1 errors comiling module, stopping' I knew something was wrong with the expressions ' ' and < > '' so i delibrately changed ' ' to 0 then i go to compile, once again there is no error, thus i come to realise that the problem occurs at ' ' . But im not sure why ' ' wouldn't work but theres got to be a way to fix it. Once again thanks for your continuous help.
    : : : :
    : : : :
    : : : :
    : : : The problem is that the variable you are using is an integer and you cannot check if an user-entered integer is empty (which is not the same as 0).
    : : : If you still want to check if the user input is not empty, you need to use a temporary string-variable to hold the input. If the user ahs entered something, you can then convert that into an integer.
    : : :
    : :
    : : Hi again, can you tell me how to write a temporary string- variable ? and what exactly is a temporary string-variable.
    : :
    : I assume that you what a string variable is. A temporary variable is nothing more than a variable, which only holds a value for a short time. These are often used to perform a check, speed-up a process, or for debug purposes.
    : In this case you want the user to enter a number, but you also want to check if the number he entered isn't empty. In this case the following code doesn't work correctly:
    : [code]
    : var
    : i: integer;
    : begin
    : readln(i);
    : if i = 0 then
    : writeln('empty text');
    : end;
    : [/code]
    : because the ser can enter a 0, which isn't an empty text. The correct way to handle such a thing is to store the entered number in a string, and check if that string is empty:
    : [code]
    : var
    : i, c: integer;
    : s: string
    : begin
    : readln(s);
    : if s = '' then
    : writeln('empty text');
    : Val(s, i, c);
    : end;
    : [/code]
    : Now if the user presses ENTER without typing anything before it, the s variable will hold an empty string. After the Val() statement, the value in the string is obsolete, since it is the same value as the i. You can even expand this code to check if the string was a number or not.
    : I hope this explains, what I mean by a temporary variable.
    :
    Thank you i made the change and the Val thing got working ; )
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories