Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

help me to creat a progam with vars...plssss?

red3warlordred3warlord Posts: 77Member
please help me to be familiar with vars.
first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
how about the other, example, using a procedure in a var?

what else can i do using the var?

i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?

that's all for now that i am needing... thank you for helping me.
this is a great support for me to eal with pascal....

Comments

  • zibadianzibadian Posts: 6,349Member
    : please help me to be familiar with vars.
    : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : how about the other, example, using a procedure in a var?
    :
    : what else can i do using the var?
    :
    : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    :
    : that's all for now that i am needing... thank you for helping me.
    : this is a great support for me to eal with pascal....
    :
    Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    - integer
    - real
    - string
    - boolean
    - array
    - record
    - pointer
    - TObject
    These types are listed from simplest to understand to hardest.

    Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    [code]
    uses
    Crt;

    var
    x, dir: integer;
    begin
    x := 4;
    dir := 1;
    repeat
    GotoXY(x, 10); write(' '); { Delete previous asterix }
    x := x + dir; { Update the location }
    GotoXY(x, 10); write('*'); { Write the new asterix }
    if x > 20 then { Limit the path of the asterix }
    dir := -1
    else if x < 4 then
    dir := 1;
    Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    until Keypressed;
    readkey;
    end.
    [/code]
  • red3warlordred3warlord Posts: 77Member
    : : please help me to be familiar with vars.
    : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : how about the other, example, using a procedure in a var?
    : :
    : : what else can i do using the var?
    : :
    : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : :
    : : that's all for now that i am needing... thank you for helping me.
    : : this is a great support for me to eal with pascal....
    : :
    : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : - integer
    : - real
    : - string
    : - boolean
    : - array
    : - record
    : - pointer
    : - TObject
    : These types are listed from simplest to understand to hardest.
    :
    : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : [code]
    : uses
    : Crt;
    :
    : var
    : x, dir: integer;
    : begin
    : x := 4;
    : dir := 1;
    : repeat
    : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : x := x + dir; { Update the location }
    : GotoXY(x, 10); write('*'); { Write the new asterix }
    : if x > 20 then { Limit the path of the asterix }
    : dir := -1
    : else if x < 4 then
    : dir := 1;
    : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : until Keypressed;
    : readkey;
    : end.
    : [/code]
    :
    thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
  • zibadianzibadian Posts: 6,349Member
    : : : please help me to be familiar with vars.
    : : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : : how about the other, example, using a procedure in a var?
    : : :
    : : : what else can i do using the var?
    : : :
    : : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : : :
    : : : that's all for now that i am needing... thank you for helping me.
    : : : this is a great support for me to eal with pascal....
    : : :
    : : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : : - integer
    : : - real
    : : - string
    : : - boolean
    : : - array
    : : - record
    : : - pointer
    : : - TObject
    : : These types are listed from simplest to understand to hardest.
    : :
    : : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : : [code]
    : : uses
    : : Crt;
    : :
    : : var
    : : x, dir: integer;
    : : begin
    : : x := 4;
    : : dir := 1;
    : : repeat
    : : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : : x := x + dir; { Update the location }
    : : GotoXY(x, 10); write('*'); { Write the new asterix }
    : : if x > 20 then { Limit the path of the asterix }
    : : dir := -1
    : : else if x < 4 then
    : : dir := 1;
    : : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : : until Keypressed;
    : : readkey;
    : : end.
    : : [/code]
    : :
    : thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
    :
    The codepedia contains a few function to perform such conversions. For more info on other types of numbers see the wikipedia. I would suggest that you learn to use them on paper first. Hint: view numbers as follows:
    decimal 123: 1*10^2 + 2*10^1 + 3*10^0 = 123 (decimal)
    octal 123: 1*8^2 + 2*8^1 + 3*8^0 = 83 (decimal)
    binary 1011: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 11 (decimal)
  • red3warlordred3warlord Posts: 77Member
    : : : : please help me to be familiar with vars.
    : : : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : : : how about the other, example, using a procedure in a var?
    : : : :
    : : : : what else can i do using the var?
    : : : :
    : : : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : : : :
    : : : : that's all for now that i am needing... thank you for helping me.
    : : : : this is a great support for me to eal with pascal....
    : : : :
    : : : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : : : - integer
    : : : - real
    : : : - string
    : : : - boolean
    : : : - array
    : : : - record
    : : : - pointer
    : : : - TObject
    : : : These types are listed from simplest to understand to hardest.
    : : :
    : : : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : : : [code]
    : : : uses
    : : : Crt;
    : : :
    : : : var
    : : : x, dir: integer;
    : : : begin
    : : : x := 4;
    : : : dir := 1;
    : : : repeat
    : : : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : : : x := x + dir; { Update the location }
    : : : GotoXY(x, 10); write('*'); { Write the new asterix }
    : : : if x > 20 then { Limit the path of the asterix }
    : : : dir := -1
    : : : else if x < 4 then
    : : : dir := 1;
    : : : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : : : until Keypressed;
    : : : readkey;
    : : : end.
    : : : [/code]
    : : :
    : : thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
    : :
    : The codepedia contains a few function to perform such conversions. For more info on other types of numbers see the wikipedia. I would suggest that you learn to use them on paper first. Hint: view numbers as follows:
    : decimal 123: 1*10^2 + 2*10^1 + 3*10^0 = 123 (decimal)
    : octal 123: 1*8^2 + 2*8^1 + 3*8^0 = 83 (decimal)
    : binary 1011: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 11 (decimal)
    :
    my point is this: when you type a certain decimal number, and then you enter, it will converted into hexadecimal, octal, or binary...
  • zibadianzibadian Posts: 6,349Member
    : : : : : please help me to be familiar with vars.
    : : : : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : : : : how about the other, example, using a procedure in a var?
    : : : : :
    : : : : : what else can i do using the var?
    : : : : :
    : : : : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : : : : :
    : : : : : that's all for now that i am needing... thank you for helping me.
    : : : : : this is a great support for me to eal with pascal....
    : : : : :
    : : : : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : : : : - integer
    : : : : - real
    : : : : - string
    : : : : - boolean
    : : : : - array
    : : : : - record
    : : : : - pointer
    : : : : - TObject
    : : : : These types are listed from simplest to understand to hardest.
    : : : :
    : : : : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : : : : [code]
    : : : : uses
    : : : : Crt;
    : : : :
    : : : : var
    : : : : x, dir: integer;
    : : : : begin
    : : : : x := 4;
    : : : : dir := 1;
    : : : : repeat
    : : : : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : : : : x := x + dir; { Update the location }
    : : : : GotoXY(x, 10); write('*'); { Write the new asterix }
    : : : : if x > 20 then { Limit the path of the asterix }
    : : : : dir := -1
    : : : : else if x < 4 then
    : : : : dir := 1;
    : : : : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : : : : until Keypressed;
    : : : : readkey;
    : : : : end.
    : : : : [/code]
    : : : :
    : : : thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
    : : :
    : : The codepedia contains a few function to perform such conversions. For more info on other types of numbers see the wikipedia. I would suggest that you learn to use them on paper first. Hint: view numbers as follows:
    : : decimal 123: 1*10^2 + 2*10^1 + 3*10^0 = 123 (decimal)
    : : octal 123: 1*8^2 + 2*8^1 + 3*8^0 = 83 (decimal)
    : : binary 1011: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 11 (decimal)
    : :
    : my point is this: when you type a certain decimal number, and then you enter, it will converted into hexadecimal, octal, or binary...
    :
    Here is a start:
    [code]
    var
    i: integer;
    begin
    write('Enter decimal number: ');
    readln(i);
    writeln('Binary: ', IntToBin(i));
    readln;
    end.
    [/code]
    See the codepedia under Delphi for the IntToBin() function.
  • red3warlordred3warlord Posts: 77Member
    : : : : : : please help me to be familiar with vars.
    : : : : : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : : : : : how about the other, example, using a procedure in a var?
    : : : : : :
    : : : : : : what else can i do using the var?
    : : : : : :
    : : : : : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : : : : : :
    : : : : : : that's all for now that i am needing... thank you for helping me.
    : : : : : : this is a great support for me to eal with pascal....
    : : : : : :
    : : : : : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : : : : : - integer
    : : : : : - real
    : : : : : - string
    : : : : : - boolean
    : : : : : - array
    : : : : : - record
    : : : : : - pointer
    : : : : : - TObject
    : : : : : These types are listed from simplest to understand to hardest.
    : : : : :
    : : : : : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : : : : : [code]
    : : : : : uses
    : : : : : Crt;
    : : : : :
    : : : : : var
    : : : : : x, dir: integer;
    : : : : : begin
    : : : : : x := 4;
    : : : : : dir := 1;
    : : : : : repeat
    : : : : : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : : : : : x := x + dir; { Update the location }
    : : : : : GotoXY(x, 10); write('*'); { Write the new asterix }
    : : : : : if x > 20 then { Limit the path of the asterix }
    : : : : : dir := -1
    : : : : : else if x < 4 then
    : : : : : dir := 1;
    : : : : : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : : : : : until Keypressed;
    : : : : : readkey;
    : : : : : end.
    : : : : : [/code]
    : : : : :
    : : : : thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
    : : : :
    : : : The codepedia contains a few function to perform such conversions. For more info on other types of numbers see the wikipedia. I would suggest that you learn to use them on paper first. Hint: view numbers as follows:
    : : : decimal 123: 1*10^2 + 2*10^1 + 3*10^0 = 123 (decimal)
    : : : octal 123: 1*8^2 + 2*8^1 + 3*8^0 = 83 (decimal)
    : : : binary 1011: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 11 (decimal)
    : : :
    : : my point is this: when you type a certain decimal number, and then you enter, it will converted into hexadecimal, octal, or binary...
    : :
    : Here is a start:
    : [code]
    : var
    : i: integer;
    : begin
    : write('Enter decimal number: ');
    : readln(i);
    : writeln('Binary: ', IntToBin(i));
    : readln;
    : end.
    : [/code]
    : See the codepedia under Delphi for the IntToBin() function.
    :
    CAN I ASK A QUESTION?
    you ahd given me the psuedocode of IntToBin before, i had debugged it, but, honestly, i don't know how to make the procedure run in the program after i had declared it. this is my prob: i had removed some parts, changed, and even add some. the only thing that makes the program unable to run is in this part:

    [code]

    Begin
    Clrscr;
    IntToBin;
    Readln;
    End;

    [/code]

    the bug lies on the part of declaring the procedure (IntToBin) appearing the errorcode ("(" expected)
    i don't know yet the solution because i am only new in this pascal world.
  • zibadianzibadian Posts: 6,349Member
    : : : : : : : please help me to be familiar with vars.
    : : : : : : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : : : : : : how about the other, example, using a procedure in a var?
    : : : : : : :
    : : : : : : : what else can i do using the var?
    : : : : : : :
    : : : : : : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : : : : : : :
    : : : : : : : that's all for now that i am needing... thank you for helping me.
    : : : : : : : this is a great support for me to eal with pascal....
    : : : : : : :
    : : : : : : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : : : : : : - integer
    : : : : : : - real
    : : : : : : - string
    : : : : : : - boolean
    : : : : : : - array
    : : : : : : - record
    : : : : : : - pointer
    : : : : : : - TObject
    : : : : : : These types are listed from simplest to understand to hardest.
    : : : : : :
    : : : : : : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : : : : : : [code]
    : : : : : : uses
    : : : : : : Crt;
    : : : : : :
    : : : : : : var
    : : : : : : x, dir: integer;
    : : : : : : begin
    : : : : : : x := 4;
    : : : : : : dir := 1;
    : : : : : : repeat
    : : : : : : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : : : : : : x := x + dir; { Update the location }
    : : : : : : GotoXY(x, 10); write('*'); { Write the new asterix }
    : : : : : : if x > 20 then { Limit the path of the asterix }
    : : : : : : dir := -1
    : : : : : : else if x < 4 then
    : : : : : : dir := 1;
    : : : : : : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : : : : : : until Keypressed;
    : : : : : : readkey;
    : : : : : : end.
    : : : : : : [/code]
    : : : : : :
    : : : : : thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
    : : : : :
    : : : : The codepedia contains a few function to perform such conversions. For more info on other types of numbers see the wikipedia. I would suggest that you learn to use them on paper first. Hint: view numbers as follows:
    : : : : decimal 123: 1*10^2 + 2*10^1 + 3*10^0 = 123 (decimal)
    : : : : octal 123: 1*8^2 + 2*8^1 + 3*8^0 = 83 (decimal)
    : : : : binary 1011: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 11 (decimal)
    : : : :
    : : : my point is this: when you type a certain decimal number, and then you enter, it will converted into hexadecimal, octal, or binary...
    : : :
    : : Here is a start:
    : : [code]
    : : var
    : : i: integer;
    : : begin
    : : write('Enter decimal number: ');
    : : readln(i);
    : : writeln('Binary: ', IntToBin(i));
    : : readln;
    : : end.
    : : [/code]
    : : See the codepedia under Delphi for the IntToBin() function.
    : :
    : CAN I ASK A QUESTION?
    : you ahd given me the psuedocode of IntToBin before, i had debugged it, but, honestly, i don't know how to make the procedure run in the program after i had declared it. this is my prob: i had removed some parts, changed, and even add some. the only thing that makes the program unable to run is in this part:
    :
    : [code]
    :
    : Begin
    : Clrscr;
    : IntToBin;
    : Readln;
    : End;
    :
    : [/code]
    :
    : the bug lies on the part of declaring the procedure (IntToBin) appearing the errorcode ("(" expected)
    : i don't know yet the solution because i am only new in this pascal world.
    :
    If you look at IntToBin declaration, it says:
    [code]
    function IntToBin(Value: integer): string;
    [/code]
    this reads that after the IntToBin word, there must be a "(" followed by some integer literal or variable, and finally a ")". The complete call needs to look something like this:
    [code]
    IntToBin(12);
    [/code]
    this will return the binary representation of 12. If you want to see the binary representation of a value inside a variable you need to pass a variable into the IntToBin function:
    [code]
    IntToBin(SomeIntVar);
    [/code]
    Calling IntToBin without any parameters (the value inside the "(" and ")") is useless, because the computer doesn't know, which value to convert into binary.
  • red3warlordred3warlord Posts: 77Member
    [b][red]This message was edited by red3warlord at 2007-1-11 0:39:4[/red][/b][hr]
    [b][red]This message was edited by red3warlord at 2007-1-11 0:38:20[/red][/b][hr]
    : : : : : : : : please help me to be familiar with vars.
    : : : : : : : : first and foremost, as of now, what i know is just on how to use concat, integer, and string in a basic way.
    : : : : : : : : how about the other, example, using a procedure in a var?
    : : : : : : : :
    : : : : : : : : what else can i do using the var?
    : : : : : : : :
    : : : : : : : : i know that gotoxy can make a simple presentation of an image by using characters, digits, special characters, etc. but i don't know how to make them move. how is it?
    : : : : : : : :
    : : : : : : : : that's all for now that i am needing... thank you for helping me.
    : : : : : : : : this is a great support for me to eal with pascal....
    : : : : : : : :
    : : : : : : : Variables are storage containers for data, no matter what that data is. The type of the variable determines the type of data it can store. I would suggest that you look at the following types in the help files to get an idea of what is possible (look also at the examples):
    : : : : : : : - integer
    : : : : : : : - real
    : : : : : : : - string
    : : : : : : : - boolean
    : : : : : : : - array
    : : : : : : : - record
    : : : : : : : - pointer
    : : : : : : : - TObject
    : : : : : : : These types are listed from simplest to understand to hardest.
    : : : : : : :
    : : : : : : : Here is an example of a moving asterix using GotoXY(). Pressing any key will stop the animation:
    : : : : : : : [code]
    : : : : : : : uses
    : : : : : : : Crt;
    : : : : : : :
    : : : : : : : var
    : : : : : : : x, dir: integer;
    : : : : : : : begin
    : : : : : : : x := 4;
    : : : : : : : dir := 1;
    : : : : : : : repeat
    : : : : : : : GotoXY(x, 10); write(' '); { Delete previous asterix }
    : : : : : : : x := x + dir; { Update the location }
    : : : : : : : GotoXY(x, 10); write('*'); { Write the new asterix }
    : : : : : : : if x > 20 then { Limit the path of the asterix }
    : : : : : : : dir := -1
    : : : : : : : else if x < 4 then
    : : : : : : : dir := 1;
    : : : : : : : Sleep(250); { Timing of the animation. Interrupt code for 250 ms }
    : : : : : : : until Keypressed;
    : : : : : : : readkey;
    : : : : : : : end.
    : : : : : : : [/code]
    : : : : : : :
    : : : : : : thank you for helping me, at least my worry lessened down, another thing i would like to ask if you don't mind to, but, as of now, i have been recieved an assignment to make a converter, can i have any tip about how to convert a number from decimal to hexadecimal, binary, and octal? i had a hard time dealing on it because i dion't have yet learned how to use other type of numbers except decimal....
    : : : : : :
    : : : : : The codepedia contains a few function to perform such conversions. For more info on other types of numbers see the wikipedia. I would suggest that you learn to use them on paper first. Hint: view numbers as follows:
    : : : : : decimal 123: 1*10^2 + 2*10^1 + 3*10^0 = 123 (decimal)
    : : : : : octal 123: 1*8^2 + 2*8^1 + 3*8^0 = 83 (decimal)
    : : : : : binary 1011: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 11 (decimal)
    : : : : :
    : : : : my point is this: when you type a certain decimal number, and then you enter, it will converted into hexadecimal, octal, or binary...
    : : : :
    : : : Here is a start:
    : : : [code]
    : : : var
    : : : i: integer;
    : : : begin
    : : : write('Enter decimal number: ');
    : : : readln(i);
    : : : writeln('Binary: ', IntToBin(i));
    : : : readln;
    : : : end.
    : : : [/code]
    : : : See the codepedia under Delphi for the IntToBin() function.
    : : :
    : : CAN I ASK A QUESTION?
    : : you ahd given me the psuedocode of IntToBin before, i had debugged it, but, honestly, i don't know how to make the procedure run in the program after i had declared it. this is my prob: i had removed some parts, changed, and even add some. the only thing that makes the program unable to run is in this part:
    : :
    : : [code]
    : :
    : : Begin
    : : Clrscr;
    : : IntToBin;
    : : Readln;
    : : End;
    : :
    : : [/code]
    : :
    : : the bug lies on the part of declaring the procedure (IntToBin) appearing the errorcode ("(" expected)
    : : i don't know yet the solution because i am only new in this pascal world.
    : :
    : If you look at IntToBin declaration, it says:
    : [code]
    : function IntToBin(Value: integer): string;
    : [/code]
    : this reads that after the IntToBin word, there must be a "(" followed by some integer literal or variable, and finally a ")". The complete call needs to look something like this:
    : [code]
    : IntToBin(12);
    : [/code]
    : this will return the binary representation of 12. If you want to see the binary representation of a value inside a variable you need to pass a variable into the IntToBin function:
    : [code]
    : IntToBin(SomeIntVar);
    : [/code]
    : Calling IntToBin without any parameters (the value inside the "(" and ")") is useless, because the computer doesn't know, which value to convert into binary.
    :
    i felt something wrong with this declaration:
    [code]
    IntToBin(Val : Integer): String;
    [/code]

    the code ( String;) makes the procedure never works. instead, an error message will appear: ";" needed.
    when i had debugged it, another error message appears: "BEGIN" expected.




  • Phat NatPhat Nat Posts: 757Member
    : : If you look at IntToBin declaration, it says:
    : : [code]
    : : function IntToBin(Value: integer): string;
    : : [/code]
    : : this reads that after the IntToBin word, there must be a "(" followed by some integer literal or variable, and finally a ")". The complete call needs to look something like this:
    : : [code]
    : : IntToBin(12);
    : : [/code]
    : : this will return the binary representation of 12. If you want to see the binary representation of a value inside a variable you need to pass a variable into the IntToBin function:
    : : [code]
    : : IntToBin(SomeIntVar);
    : : [/code]
    : : Calling IntToBin without any parameters (the value inside the "(" and ")") is useless, because the computer doesn't know, which value to convert into binary.
    : :
    : i felt something wrong with this declaration:
    : [code]
    : IntToBin(Val : Integer): String;
    : [/code]
    :
    : the code ( String;) makes the procedure never works. instead, an error message will appear: ";" needed.
    : when i had debugged it, another error message appears: "BEGIN" expected.

    Make sure that you are declaring it as a FUNCTION and not a PROCEDURE. Note the difference is that a FUNCTION returns a value, whereas a PROCEDURE does not.

    eg.
    [code]
    PROCDURE ShowValue(Val : Integer);
    Begin
    WriteLn(Val);
    End;

    FUNCTION ReturnValue(Val : Integer) : String;
    Begin
    IntToBin := Val;
    End;

    Begin
    ShowValue(12);
    WriteLn(ReturnValue(13));
    End.
    [/code]

    Procedures require that you use the data inside them, then they are gone (although there are exceptions to this) and function will return values to the line that called the function so that you can use the data again.

    Phat Nat
Sign In or Register to comment.