mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-09-30 09:49:09 +02:00
* Convert to webproject, demo enumerator for collection and stringlist
This commit is contained in:
parent
82ad6fa9fa
commit
4bd0bc76bb
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="10"/>
|
<Version Value="11"/>
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<MainUnitHasCreateFormStatements Value="False"/>
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
@ -13,6 +13,12 @@
|
|||||||
<UseAppBundle Value="False"/>
|
<UseAppBundle Value="False"/>
|
||||||
<ResourceType Value="res"/>
|
<ResourceType Value="res"/>
|
||||||
</General>
|
</General>
|
||||||
|
<CustomData Count="4">
|
||||||
|
<Item0 Name="PasJSPort" Value="0"/>
|
||||||
|
<Item1 Name="PasJSURL"/>
|
||||||
|
<Item2 Name="PasJSWebBrowserProject" Value="1"/>
|
||||||
|
<Item3 Name="PJSProjectHTMLFile" Value="democollection.html"/>
|
||||||
|
</CustomData>
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
<Item1 Name="Default" Default="True"/>
|
<Item1 Name="Default" Default="True"/>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
@ -20,9 +26,10 @@
|
|||||||
<Version Value="2"/>
|
<Version Value="2"/>
|
||||||
</PublishOptions>
|
</PublishOptions>
|
||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<FormatVersion Value="2"/>
|
||||||
<FormatVersion Value="1"/>
|
<Modes Count="1">
|
||||||
</local>
|
<Mode0 Name="default"/>
|
||||||
|
</Modes>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="1">
|
<RequiredPackages Count="1">
|
||||||
<Item1>
|
<Item1>
|
||||||
|
@ -58,6 +58,23 @@ begin
|
|||||||
Writeln('Fruit collection: ',s);
|
Writeln('Fruit collection: ',s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure DumpCollection2(C : TMyCollectionItems);
|
||||||
|
|
||||||
|
Var
|
||||||
|
S : String;
|
||||||
|
Itm : TCollectionItem;
|
||||||
|
|
||||||
|
begin
|
||||||
|
S:='';
|
||||||
|
For Itm in C do
|
||||||
|
begin
|
||||||
|
If S<>'' then
|
||||||
|
S:=S+', ';
|
||||||
|
S:=S+'['+IntToStr(Itm.Index)+'] : '+TMyCollectionItem(Itm).MyName;
|
||||||
|
end;
|
||||||
|
Writeln('Fruit collection: ',s);
|
||||||
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
Const
|
Const
|
||||||
MyNames : Array [1..10] of string
|
MyNames : Array [1..10] of string
|
||||||
@ -102,9 +119,9 @@ begin
|
|||||||
DumpCollection(MyC);
|
DumpCollection(MyC);
|
||||||
Writeln('Prefer banana over pear');
|
Writeln('Prefer banana over pear');
|
||||||
MyC.Exchange(1,2);
|
MyC.Exchange(1,2);
|
||||||
DumpCollection(MyC);
|
DumpCollection2(MyC);
|
||||||
Writeln('Indigestion, no more fruit');
|
Writeln('Indigestion, no more fruit');
|
||||||
MyC.Clear;
|
MyC.Clear;
|
||||||
DumpCollection(MyC);
|
DumpCollection2(MyC);
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
13
demo/rtl/demostringlist.html
Normal file
13
demo/rtl/demostringlist.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Stringlist demo</title>
|
||||||
|
<script type="application/javascript" src="demostringlist.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="pasjsconsole"></div>
|
||||||
|
<script type="application/javascript">
|
||||||
|
rtl.run();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
81
demo/rtl/demostringlist.lpi
Normal file
81
demo/rtl/demostringlist.lpi
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
|
<MainUnitHasScaledStatement Value="False"/>
|
||||||
|
<Runnable Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<Title Value="demostringlist"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<CustomData Count="4">
|
||||||
|
<Item0 Name="PasJSPort" Value="0"/>
|
||||||
|
<Item1 Name="PasJSURL"/>
|
||||||
|
<Item2 Name="PasJSWebBrowserProject" Value="1"/>
|
||||||
|
<Item3 Name="PJSProjectHTMLFile" Value="demostringlist.html"/>
|
||||||
|
</CustomData>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<FormatVersion Value="2"/>
|
||||||
|
<Modes Count="0"/>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages Count="1">
|
||||||
|
<Item1>
|
||||||
|
<PackageName Value="pas2js_rtl"/>
|
||||||
|
</Item1>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units Count="2">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="demostringlist.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="demostringlist.html"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit1>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="demostringlist"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<UnitOutputDirectory Value="js"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Other>
|
||||||
|
<CompilerPath Value=""/>
|
||||||
|
<ExecuteBefore>
|
||||||
|
<Command Value=""$MakeExe(IDE,pas2js)" -Jirtl.js -Jc -Jminclude -Tbrowser "-Fu$(ProjUnitPath)" $Name($(ProjFile))"/>
|
||||||
|
<ScanForFPCMsgs Value="True"/>
|
||||||
|
<ScanForMakeMsgs Value="True"/>
|
||||||
|
</ExecuteBefore>
|
||||||
|
</Other>
|
||||||
|
<CompileReasons Compile="False" Build="False" Run="False"/>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
@ -1,12 +1,13 @@
|
|||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
{$H+}
|
{$H+}
|
||||||
uses sysutils,classes;
|
uses browserconsole,sysutils,classes;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
L : TStringList;
|
L : TStringList;
|
||||||
I : Integer;
|
I : Integer;
|
||||||
//S : TJSString;
|
//S : TJSString;
|
||||||
|
S : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
L:=TStringList.Create;
|
L:=TStringList.Create;
|
||||||
for I:=0 to 10 do
|
for I:=0 to 10 do
|
||||||
@ -28,5 +29,8 @@ begin
|
|||||||
Writeln('After sort : ',L.CommaText);
|
Writeln('After sort : ',L.CommaText);
|
||||||
//S:=TJSString.new('abc');
|
//S:=TJSString.new('abc');
|
||||||
//Writeln(S.toUpperCase);
|
//Writeln(S.toUpperCase);
|
||||||
|
Writeln('For in loop:');
|
||||||
|
for S in L do
|
||||||
|
Writeln(S);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user