Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
help me to creat a progam with vars...plssss? Posted by red3warlord on 1 Jan 2007 at 8:03 PM
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....
Report
Re: help me to creat a progam with vars...plssss? Posted by zibadian on 2 Jan 2007 at 12:25 AM
: 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:
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.

Report
Re: help me to creat a progam with vars...plssss? Posted by red3warlord on 8 Jan 2007 at 9:47 PM
: : 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:
:
: 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.
: 

:
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....
Report
Re: help me to creat a progam with vars...plssss? Posted by zibadian on 8 Jan 2007 at 10:03 PM
: : : 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:
: :
: : 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.
: : 

: :
: 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)
Report
Re: help me to creat a progam with vars...plssss? Posted by red3warlord on 8 Jan 2007 at 11:48 PM
: : : : 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:
: : :
: : : 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.
: : : 

: : :
: : 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...
Report
Re: help me to creat a progam with vars...plssss? Posted by zibadian on 9 Jan 2007 at 12:21 AM
: : : : : 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:
: : : :
: : : : 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.
: : : : 

: : : :
: : : 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:
var
  i: integer;
begin
  write('Enter decimal number: ');
  readln(i);
  writeln('Binary: ', IntToBin(i));
  readln;
end.

See the codepedia under Delphi for the IntToBin() function.
Report
Re: help me to creat a progam with vars...plssss? Posted by red3warlord on 10 Jan 2007 at 5:34 PM
: : : : : : 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:
: : : : :
: : : : : 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.
: : : : : 

: : : : :
: : : : 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:
:
: var
:   i: integer;
: begin
:   write('Enter decimal number: ');
:   readln(i);
:   writeln('Binary: ', IntToBin(i));
:   readln;
: end.
: 

: 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:


Begin
Clrscr;
IntToBin;
Readln;
End;



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.
Report
Re: help me to creat a progam with vars...plssss? Posted by zibadian on 10 Jan 2007 at 8:35 PM
: : : : : : : 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:
: : : : : :
: : : : : : 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.
: : : : : : 

: : : : : :
: : : : : 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:
: :
: : var
: :   i: integer;
: : begin
: :   write('Enter decimal number: ');
: :   readln(i);
: :   writeln('Binary: ', IntToBin(i));
: :   readln;
: : end.
: : 

: : 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:
:
:
: 
: Begin
: Clrscr;
: IntToBin;
: Readln;
: End;
: 
: 

:
: 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:
function IntToBin(Value: integer): string;

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:
  IntToBin(12);

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:
  IntToBin(SomeIntVar);

Calling IntToBin without any parameters (the value inside the "(" and ")") is useless, because the computer doesn't know, which value to convert into binary.
Report
Re: help me to creat a progam with vars...plssss? Posted by red3warlord on 11 Jan 2007 at 12:37 AM
This message was edited by red3warlord at 2007-1-11 0:39:4

This message was edited by red3warlord at 2007-1-11 0:38:20

: : : : : : : : 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:
: : : : : : :
: : : : : : : 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.
: : : : : : : 

: : : : : : :
: : : : : : 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:
: : :
: : : var
: : :   i: integer;
: : : begin
: : :   write('Enter decimal number: ');
: : :   readln(i);
: : :   writeln('Binary: ', IntToBin(i));
: : :   readln;
: : : end.
: : : 

: : : 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:
: :
: :
: : 
: : Begin
: : Clrscr;
: : IntToBin;
: : Readln;
: : End;
: : 
: : 

: :
: : 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:
:
: function IntToBin(Value: integer): string;
: 

: 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:
:
:   IntToBin(12);
: 

: 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:
:
:   IntToBin(SomeIntVar);
: 

: 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:
IntToBin(Val : Integer): String;


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.




Report
Re: help me to creat a progam with vars...plssss? Posted by Phat Nat on 12 Jan 2007 at 3:05 PM
: : If you look at IntToBin declaration, it says:
: :
: : function IntToBin(Value: integer): string;
: : 

: : 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:
: :
: :   IntToBin(12);
: : 

: : 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:
: :
: :   IntToBin(SomeIntVar);
: : 

: : 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:
:
: IntToBin(Val : Integer): String;
: 

:
: 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.
PROCDURE ShowValue(Val : Integer);
Begin
     WriteLn(Val);
End;

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

Begin
     ShowValue(12);
     WriteLn(ReturnValue(13));
End.


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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.