mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 20:59:42 +02:00
+ Objpas unit examples
This commit is contained in:
parent
f1ef577504
commit
00733b7433
@ -38,7 +38,8 @@ OBJECTS=ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex11 ex12 ex13 ex14 \
|
||||
ex41 ex42 ex43 ex44 ex45 ex46 ex47 ex48 ex49 ex50 ex51 ex52 ex53 \
|
||||
ex54 ex55 ex56 ex57 ex58 ex59 ex60 ex61 ex62 ex63 ex64 ex65 ex66 \
|
||||
ex67 ex68 ex69 ex70 ex71 ex72 ex73 ex74 ex75 ex76 ex77 ex78 ex79 \
|
||||
ex80 ex81 ex82 ex83 ex84 ex85 ex86 ex87
|
||||
ex80 ex81 ex82 ex83 ex84 ex85 ex86 ex87 ex88 ex89 \
|
||||
ex90 ex91 ex92 ex93 ex94 ex95
|
||||
|
||||
TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
|
||||
|
||||
@ -50,7 +51,7 @@ onetex : tex
|
||||
$(MAKETEX) $(TEXOBJECTS)
|
||||
|
||||
clean :
|
||||
rm -f *.o *.s $(OBJECTS) $(TEXOBJECTS)
|
||||
rm -f *.o *.s *.rst $(OBJECTS) $(TEXOBJECTS)
|
||||
|
||||
$(OBJECTS): %: %.pp
|
||||
$(PP) $(PPOPTS) $*
|
||||
|
@ -90,3 +90,11 @@ ex84.pp contains an example of the Library keyword.
|
||||
ex85.pp contains an example of the SetLength function.
|
||||
ex86.pp contains an example of the Continue function.
|
||||
ex87.pp contains an example of the Break function.
|
||||
ex88.pp contains an example of the AssignFile function.
|
||||
ex89.pp contains an example of the FreeMem function.
|
||||
ex90.pp contains an example of the GetResourceStringCurrentValue function.
|
||||
ex91.pp contains an example of the GetResourceStringDefaultValue function.
|
||||
ex92.pp contains an example of the GetResourceStringName function.
|
||||
ex93.pp contains an example of the Hash function.
|
||||
ex94.pp contains an example of the SetResourceStringValue function.
|
||||
ex95.pp contains an example of the SetResourceStrings function.
|
||||
|
14
docs/refex/ex88.pp
Normal file
14
docs/refex/ex88.pp
Normal file
@ -0,0 +1,14 @@
|
||||
Program Example88;
|
||||
|
||||
{ Program to demonstrate the AssignFile and CloseFile functions. }
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
Var F : text;
|
||||
|
||||
begin
|
||||
AssignFile(F,'textfile.txt');
|
||||
Rewrite(F);
|
||||
Writeln (F,'This is a silly example of AssignFile and CloseFile.');
|
||||
CloseFile(F);
|
||||
end.
|
13
docs/refex/ex89.pp
Normal file
13
docs/refex/ex89.pp
Normal file
@ -0,0 +1,13 @@
|
||||
Program Example89;
|
||||
|
||||
{ Program to demonstrate the FreeMem function. }
|
||||
{$Mode Delphi}
|
||||
|
||||
Var P : Pointer;
|
||||
|
||||
begin
|
||||
Writeln ('Memory before : ',Memavail);
|
||||
GetMem(P,10000);
|
||||
FreeMem(P);
|
||||
Writeln ('Memory after : ',Memavail);
|
||||
end.
|
18
docs/refex/ex90.pp
Normal file
18
docs/refex/ex90.pp
Normal file
@ -0,0 +1,18 @@
|
||||
Program Example90;
|
||||
|
||||
{ Program to demonstrate the GetResourceStringCurrentValue function. }
|
||||
{$Mode Delphi}
|
||||
|
||||
ResourceString
|
||||
|
||||
First = 'First string';
|
||||
Second = 'Second String';
|
||||
|
||||
Var I,J : Longint;
|
||||
|
||||
begin
|
||||
{ Print current values of all resourcestrings }
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
Writeln (I,',',J,' : ',GetResourceStringCurrentValue(I,J));
|
||||
end.
|
18
docs/refex/ex91.pp
Normal file
18
docs/refex/ex91.pp
Normal file
@ -0,0 +1,18 @@
|
||||
Program Example91;
|
||||
|
||||
{ Program to demonstrate the GetResourceStringDefaultValue function. }
|
||||
{$Mode Delphi}
|
||||
|
||||
ResourceString
|
||||
|
||||
First = 'First string';
|
||||
Second = 'Second String';
|
||||
|
||||
Var I,J : Longint;
|
||||
|
||||
begin
|
||||
{ Print default values of all resourcestrings }
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
Writeln (I,',',J,' : ',GetResourceStringDefaultValue(I,J));
|
||||
end.
|
18
docs/refex/ex92.pp
Normal file
18
docs/refex/ex92.pp
Normal file
@ -0,0 +1,18 @@
|
||||
Program Example92;
|
||||
|
||||
{ Program to demonstrate the GetResourceStringName function. }
|
||||
{$Mode Delphi}
|
||||
|
||||
ResourceString
|
||||
|
||||
First = 'First string';
|
||||
Second = 'Second String';
|
||||
|
||||
Var I,J : Longint;
|
||||
|
||||
begin
|
||||
{ Print names of all resourcestrings }
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
Writeln (I,',',J,' : ',GetResourceStringName(I,J));
|
||||
end.
|
21
docs/refex/ex93.pp
Normal file
21
docs/refex/ex93.pp
Normal file
@ -0,0 +1,21 @@
|
||||
Program Example93;
|
||||
|
||||
{ Program to demonstrate the Hash function. }
|
||||
{$Mode Delphi}
|
||||
|
||||
ResourceString
|
||||
|
||||
First = 'First string';
|
||||
Second = 'Second String';
|
||||
|
||||
Var I,J : Longint;
|
||||
|
||||
begin
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
If Hash(GetResourceStringDefaultValue(I,J))
|
||||
<>GetResourceStringHash(I,J) then
|
||||
Writeln ('Hash mismatch at ',I,',',J)
|
||||
else
|
||||
Writeln ('Hash (',I,',',J,') matches.');
|
||||
end.
|
32
docs/refex/ex94.pp
Normal file
32
docs/refex/ex94.pp
Normal file
@ -0,0 +1,32 @@
|
||||
Program Example94;
|
||||
|
||||
{ Program to demonstrate the SetResourceStringValue function. }
|
||||
{$Mode Delphi}
|
||||
|
||||
ResourceString
|
||||
|
||||
First = 'First string';
|
||||
Second = 'Second String';
|
||||
|
||||
Var I,J : Longint;
|
||||
S : AnsiString;
|
||||
|
||||
begin
|
||||
{ Print current values of all resourcestrings }
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
begin
|
||||
Writeln ('Translate => ',GetResourceStringDefaultValue(I,J));
|
||||
Write ('->');
|
||||
Readln(S);
|
||||
SetResourceStringValue(I,J,S);
|
||||
end;
|
||||
Writeln ('Translated strings : ');
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
begin
|
||||
Writeln (GetResourceStringDefaultValue(I,J));
|
||||
Writeln ('Translates to : ');
|
||||
Writeln (GetResourceStringCurrentValue(I,J));
|
||||
end;
|
||||
end.
|
32
docs/refex/ex95.pp
Normal file
32
docs/refex/ex95.pp
Normal file
@ -0,0 +1,32 @@
|
||||
Program Example95;
|
||||
|
||||
{ Program to demonstrate the SetResourceStrings function. }
|
||||
{$Mode objfpc}
|
||||
|
||||
ResourceString
|
||||
|
||||
First = 'First string';
|
||||
Second = 'Second String';
|
||||
|
||||
Var I,J : Longint;
|
||||
S : AnsiString;
|
||||
|
||||
Function Translate (Name,Value : AnsiString; Hash : longint): AnsiString;
|
||||
|
||||
begin
|
||||
Writeln ('Translate (',Name,') => ',Value);
|
||||
Write ('->');
|
||||
Readln (Result);
|
||||
end;
|
||||
|
||||
begin
|
||||
SetResourceStrings(@Translate);
|
||||
Writeln ('Translated strings : ');
|
||||
For I:=0 to ResourceStringTableCount-1 do
|
||||
For J:=0 to ResourceStringCount(i)-1 do
|
||||
begin
|
||||
Writeln (GetResourceStringDefaultValue(I,J));
|
||||
Writeln ('Translates to : ');
|
||||
Writeln (GetResourceStringCurrentValue(I,J));
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user