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.