|
From: Pieter P. <pp...@co...> - 2001-03-22 12:49:13
|
I hope I can give a minor contribution to this project by providing some
language example sources.
Here are some language sample sources (it has become quite a long list):
>
> Done
> ==============
> Java
> XML
> Cascading Stylesheets
> HTML
> JavaScript
> Perl
> PHP
> SQL
> VBScript
>
> Not done
> ==============
> HP48
> CA-Clipper
> C++ (this comes from C++ builder)
//--------------------------------------------------------------------------
-
#include <vcl.h>
#pragma hdrstop
USERES("demo.res");
USEFORM("unitmain.cpp", FormMain);
USEFORM("unitabout.cpp", FormAbout);
//--------------------------------------------------------------------------
-
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TFormMain), &FormMain);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
//--------------------------------------------------------------------------
-
> MS-DOS Batch Language
@echo off
title "Example batch program"
echo Hello world
e:
cd "e:\my documents"
for %a in (*.doc) do copy %a d:\documents
echo %1
shift
echo %1
:loop
goto loop
> Delphi C++ Builder Form Definitions
object DemoForm: TDemoForm
Left = 275
Top = 107
BorderStyle = bsDialog
Caption = 'Hello world'
ClientHeight = 136
ClientWidth = 448
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = [fsBold]
end
> AWK Script
> Galaxy
> ObjectPascal
> x86 Assembly Language
mov ax, 10h
mov bx, 243
mov es, ds
mov ch, byte ptr es:[bx]
push eax
pop ebx
add ax, 2
shr bx, 1
add ax, bx
> Python
> Tcl-Tk
> Gembase
> INI files
[Example section]
StringValue=Some example string
NumericValue=10
[Another section]
ThisValue=Test value
> Standard ML
> Visual Basic
Option Explicit
Const MessCount = 7
Dim Messages(MessCount) As String
Sub CreateLoader ()
Dim Db As Database
Dim Dt As Table
Dim i As Integer
DoEvents
Set Db = OpenDatabase(LANGUAGEDB)
Set Dt = Db.OpenTable("ControlLabels")
Dt.Index = "PrimaryKey"
For i = 0 To MessCount - 1
Dt.Seek "=", "English", "M" & Str$(i)
If Dt.NoMatch Then
Dt.AddNew
Dt.Fields("Language") = "English"
Dt.Fields("Control") = "M" & Str$(i)
Dt.Fields("Text") = Messages(i)
Dt.Update
End If
Next
Dt.Close
Db.Close
End Sub
> ADSP21xx
> Sybase SQL (is really this different from SQL?)
> General Multi-Highlighter (do we need this)
I think it is difficult to find a sample code for this. I am using this
general highlighter class in a project, but there is a bug in it. It does
not correctly highlight all the provided keywords. I have fixed this by
changing the IsKeyword method, to look like:
function TSynGeneralSyn.IsKeyword(const AKeyword: string): boolean;
var
First, Last, I, Compare: Integer;
Token: String;
begin
First := 0;
Last := fKeywords.Count - 1;
Result := False;
Token := UpperCase(AKeyword);
while First <= Last do
begin
// PP ---> bug fix: if First+Last is not even, this will skip some keywords,
therefor: add 1
I := (First + Last + 1) shr 1;
// <-- PP
Compare := CompareStr(fKeywords[i], Token);
if Compare = 0 then
begin
Result := True;
break;
end
else
begin
if Compare < 0 then
First := I + 1
else
Last := I - 1
end
end;
end; { IsKeyWord }
> Cache object script
> KIX32
; Sample script for KiXtart
color b/n
BOX(0,0,24,80,grid)
color g/n
at ( 5,1) "DAY" at ( 5,21) "MDAYNO" at ( 5,41) "WDAYNO" at ( 5,61)
"YDAYNO"
at (23,32) "<any key to continue>"
get $x
? ?
> Baan 4GL
> Foxpro
> Fortran
program helloworld
c
character crunid*61, cdirct*256, cmnam*255
integer ierr, i
c
crunid = ' '
cdirct = ' '
c
crunid = cmnam ( )
cdirct = cmnam ( )
c
i = leng ( crunid )
crunid(i+1:i+1) = char(0)
i = leng ( cdirct )
cdirct(i+1:i+1) = char(0)
c
if ( ierr .eq. 0 ) then
write(*,*) 'Successful completion'
else
write(*,*) 'Terminated with error'
endif
c
end
> 68HC11 Assembler
> Progress
> Inno Setup scripts
; Inno Setup Script
; Created with ScriptMaker Version 1.2.4
; 22 March 2001 at 12:22
[Setup]
MinVersion=4.0,4.0
AppName=Hello world
AppVerName=Hello world 1.0
AppCopyright=Copyright(c)2001 by P.L. Polak
Password=password
Bits=32
BackColor=$FF0000
BackSolid=0
WindowShowCaption=1
WindowStartMaximized=1
WindowVisible=1
WindowResizable=1
DisableDirExistsWarning=0
DisableDirPage=0
DisableStartupPrompt=0
CreateAppDir=1
DisableProgramGroupPage=0
AlwaysCreateUninstallIcon=0
OverwriteUninstRegEntries=1
ChangesAssociations=0
Uninstallable=1
AllowNoIcons=0
AlwaysRestart=0
DefaultDirName=c:\program files\Hello World
DefaultGroupName=Hello
MessagesFile=compiler:default.isl
DiskSpanning=0
SourceDir=D:\MyProgs\Hello
> Modelica
> Modula 3
>
> Currently Leon Brown is winning with a total of 7!
>
> -Jeff Rafter
>
I hope this contributes to the project.
Pieter Polak
|