Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Neka mi netko objasni variable?

[es] :: Pascal / Delphi / Kylix :: Neka mi netko objasni variable?

[ Pregleda: 2557 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

LP4ever

Član broj: 50539
Poruke: 15
*.tel.net.ba.



Profil

icon Neka mi netko objasni variable?24.03.2005. u 18:17 - pre 232 meseci
Zašto služe, kad se koriste i koja su pravila korištenja?
 
Odgovor na temu

Srki_82
Srdjan Tot
Me @ My Home
Ljubljana

Član broj: 28226
Poruke: 1403
82.208.201.*

ICQ: 246436949


+10 Profil

icon Re: Neka mi netko objasni variable?24.03.2005. u 18:46 - pre 232 meseci
Ha
Mozda bi bilo lakse objasniti za sta ne sluze
 
Odgovor na temu

LP4ever

Član broj: 50539
Poruke: 15
*.tel.net.ba.



Profil

icon Re: Neka mi netko objasni variable?24.03.2005. u 18:48 - pre 232 meseci
A za šta onda nesluže?
 
Odgovor na temu

Srki_82
Srdjan Tot
Me @ My Home
Ljubljana

Član broj: 28226
Poruke: 1403
82.208.201.*

ICQ: 246436949


+10 Profil

icon Re: Neka mi netko objasni variable?24.03.2005. u 23:58 - pre 232 meseci
Iz Delphi help-a:

A variable is an identifier whose value can change at runtime. Put differently, a variable is a name for a location in memory; you can use the name to read or write to the memory location. Variables are like containers for data, and, because they are typed, they tell the compiler how to interpret the data they hold.

Declaring variables
The basic syntax for a variable declaration is

var identifierList: type;

where identifierList is a comma-delimited list of valid identifiers and type is any valid type. For example,

var I: Integer;

declares a variable I of type Integer, while

var X, Y: Real;

declares two variables--X and Y--of type Real.

Consecutive variable declarations do not have to repeat the reserved word var:

var
X, Y, Z: Double;
I, J, K: Integer;
Digit: 0..9;
Okay: Boolean;

Variables declared within a procedure or function are sometimes called local, while other variables are called global. Global variables can be initialized at the same time they are declared, using the syntax

var identifier: type = constantExpression;

where constantExpression is any constant expression representing a value of type type. Thus the declaration

var I: Integer = 7;

is equivalent to the declaration and statement

var I: Integer;
...
I := 7;

Multiple variable declarations (such as var X, Y, Z: Real;) cannot include initializations, nor can declarations of variant and file-type variables.

If you don't explicitly initialize a global variable, the compiler initializes it to 0. Local variables, in contrast, cannot be initialized in their declarations and contain random data until a value is assigned to them.

When you declare a variable, you are allocating memory which is freed automatically when the variable is no longer used. In particular, local variables exist only until the program exits from the function or procedure in which they are declared.

You can create a new variable that resides at the same address as another variable. To do so, put the directive absolute after the type name in the declaration of the new variable, followed by the name of an existing (previously declared) variable. For example,

var
Str: string[32];
StrLen: Byte absolute Str;

specifies that the variable StrLen should start at the same address as Str. Since the first byte of a short string contains the string's length, the value of StrLen is the length of Str.

You cannot initialize a variable in an absolute declaration or combine absolute with any other directives.

You can create dynamic variables by calling the GetMem or New procedure. Such variables are allocated on the heap and are not managed automatically. Once you create one, it is your responsibility ultimately to free the variable's memory; use FreeMem to destroy variables created by GetMem and Dispose to destroy variables created by New. Other standard routines that operate on dynamic variables include ReallocMem, AllocMem, Initialize, Finalize, StrAlloc, and StrDispose.

Long strings, wide strings, dynamic arrays, variants, and interfaces are also heap-allocated dynamic variables, but their memory is managed automatically.

Thread-local (or thread) variables are used in multithreaded applications. A thread-local variable is like a global variable, except that each thread of execution gets its own private copy of the variable, which cannot be accessed from other threads. Thread-local variables are declared with threadvar instead of var. For example,

threadvar X: Integer;

Thread-variable declarations

cannot occur within a procedure or function.
cannot include initializations.
cannot specify the absolute directive.

Dynamic variables that are ordinarily managed by the compiler--long strings, wide strings, dynamic arrays, variants, and interfaces--can be declared with threadvar, but the compiler does not automatically free the heap-allocated memory created by each thread of execution. If you use these data types in thread variables, it is your responsibility to dispose of their memory from within the thread, before the thread terminates. For example,

threadvar S: AnsiString;
S := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
...
S := ''; // free the memory used by S

Note

Use of such constructs is discouraged.

You can free a variant by setting it to Unassigned and an interface or dynamic array by setting it to nil.

Eto... variable se koriste za sve i svasta.
 
Odgovor na temu

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Član broj: 32202
Poruke: 4391
*.yu1.net.

Sajt: https://avramovic.info


+46 Profil

icon Re: Neka mi netko objasni variable?25.03.2005. u 00:00 - pre 232 meseci
najkrace: variable sluze da cuvas neku informaciju i da manipulises njome koristeci (najcesce) funkcije... a ne sluze... paaaaa... ne mogu da se setim... jer se skoro svuda koriste

[Ovu poruku je menjao JaHvram dana 25.03.2005. u 01:14 GMT+1]
Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
Odgovor na temu

Srki_82
Srdjan Tot
Me @ My Home
Ljubljana

Član broj: 28226
Poruke: 1403
82.208.201.*

ICQ: 246436949


+10 Profil

icon Re: Neka mi netko objasni variable?25.03.2005. u 00:09 - pre 232 meseci
Kratko i jednostavno
Ako si mislio da mozes bes promenljivih grdno si se prevario
 
Odgovor na temu

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Član broj: 32202
Poruke: 4391
*.yu1.net.

Sajt: https://avramovic.info


+46 Profil

icon Re: Neka mi netko objasni variable?25.03.2005. u 00:15 - pre 232 meseci
moze, moze da koristi tagove pojedinih kontrola... :D ali to je samo integer... i to su u stvari variable... samo sto ne treba da ih definise :)
Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
Odgovor na temu

Goran1987
Goran Markovic
Doboj

Član broj: 49831
Poruke: 13
81.94.11.*



Profil

icon Re: Neka mi netko objasni variable?29.03.2005. u 00:24 - pre 232 meseci
Variable se koriste za identifikaciju objekata u programu. Naprimjer ako imas program koji ti izracunava povrsinu trougla na osnovu unjetih kateta,recimo a i b, gdje si povrsinu oznacio kao P i gdje ti ustvari a,b i P predstavljaju variable,odnosno promjenljive.Kad ih deklarises mozes ih koristiti tokom citavog programa.Jednostavno receno te promjenjive koristis da bi ti i program znali sta je sta i da ne bi doslo do zabune samog kompajlera(naprimjer:postavis promjenljivu a i b,koje ce predstavljati katete trougla i postavis P koji ce predstavljati povrsinu).
Naravno pri postavljanju(deklaraciji)promjenljivih moras obratiti paznju na tip promjenljive koji moze biti:cjelobrojni(integer),realni(real),znakovni(char) i logicki(boolean).
Naravno oznaka ovih tipova vazi za pascal.Isti je smisao i kod drugih jezika samo sto se koriste razlicite rijeci za oznacavanje.
Jezik kosti nema, ali kosti lomi.
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Neka mi netko objasni variable?

[ Pregleda: 2557 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.