4. Langages déjà supportés par l’ancien système de coloration▲
4-A. Action script▲
ActionScript
Sélectionnez
on
(
release) {
//gestion des propriétés de la popup
// variable .variable
getURL
(
"javascript:MM_openBrWindow('intro.html','nomfenetre','width=500, height=370,"
"status=no,scrollbars=no,resizable=no,titlebar=no')"
);
Machin :=
variable
+
1
toto.
variable
;
}
function
trim
(
s:
String
):
String
{
var
nEspace:
Number
=
32
;
// Code représentant l’espace
var
nBegin:
Number
=
0
;
var
nEnd:
Number
=
s.
length
;
var
c:
Number
=
s.
charCodeAt
(
nBegin) ;
while
(
c ==
nEspace) {
c =
s.
charCodeAt
(++
nBegin) ;
}
c =
s.
charCodeAt
(
nEnd-
1
);
/* -1 car les index commencent à 0*/
while
(
c ==
nEspace) {
c =
s.
charCodeAt
(--
nEnd) ;
}
return
s.
substring
(
nBegin,
nEnd+
1
);
// +1 car le second paramètre est l’index du premier caractère /* test */ suivant la chaîne à extraire
}
var
sAncienneChaine:
String
=
" Ceci est une chaine avec des espaces inutiles au début et à la fin "
;
var
sltChaine:
String
=
trim
(
sAncienneChaine);
trace
(
"-> \""
+
sltChaine+
"\" <-"
);
trace
(
"**/*****************************************/**"
);
/*
* Autre exemple
*/
this
.
createEmptyMovieClip
(
"triangle_mc"
,
10
);
triangle_mc.
_x
=
triangle_mc.
_y
=
100
;
drawTriangle
(
triangle_mc,
100
,
0x99FF00,
100
);
function
drawTriangle
(
target_mc:
MovieClip
,
sideLength:
Number
,
fillColor:
Number
,
fillAlpha:
Number
):
Void
{
var
tHeight:
Number
=
sideLength *
Math
.
sqrt
(
3
) /
2
;
with
(
target_mc) {
beginFill
(
fillColor,
fillAlpha);
moveTo
(
sideLength /
2
,
0
);
lineTo
(
sideLength,
tHeight);
lineTo
(
0
,
tHeight);
lineTo
(
sideLength /
2
,
0
);
endFill
(
);
}
}
/* // Fin */
trace
(
Stage
.
width
+
" "
+
triangle_mc.
_width
);
// */
4-B. ASP , ASP.NET▲
asp
Sélectionnez
<%
' récupération du paramètre
idimage_get =
Request
.QueryString
(
"idimage"
)
' création de la connexion à la base de données
Set
conn =
Server
.CreateObject
(
"ADODB.Connection"
)
' ouverture de la connexion
conn.Open
chainedeconnexion ' chainedeconnexion est à préciser sui
' création de la requete
requete =
"SELECT type_image, bin_image FROM images WHERE idimage="
&
idimage_get
' exécution de la requête
Set
rs =
conn.Execute
(
requete)
' positionnement du content-type
Response
.ContentType
=
rs
(
"type_image"
)
' écriture du contenu du champ blob
Response
.BinaryWrite
(
rs
(
"bin_image"
))
' fermeture et destruction de la connexion
conn.close
Set
conn =
Nothing
%>
aspnet
Sélectionnez
<asp:calendar id
=
"Calendar1"
runat
=
"server"
Width
=
"47px"
Height
=
"40px"
>
<TodayDayStyle Font-Names
=
"Arial"
Font-Bold
=
"True"
ForeColor
=
"Red"
></TodayDayStyle>
<SelectorStyle Font-Names
=
"Arial"
></SelectorStyle>
<%
Truc muche sldgj%>
<%-- UneLigne --%>
<DayStyle Font-Names
=
"Arial"
ForeColor
=
"#006600"
></DayStyle>
<DayHeaderStyle Font-Names
=
"Arial"
ForeColor
=
"White"
BorderColor
=
"#006600"
BackColor
=
"#006600"
></DayHeaderStyle>
<!-- The big boss -->
<!-- The big
<OtherMonthDayStyle Font-Names="Arial" ForeColor="#006600" BorderColor="White"
BackColor="White"></OtherMonthDayStyle>
boss -->
<OtherMonthDayStyle Font-Names
=
"Arial"
ForeColor
=
"#006600"
BorderColor
=
"White"
BackColor
=
"White"
></OtherMonthDayStyle>
<%-- The big
<OtherMonthDayStyle Font-Names="Arial" ForeColor="#006600" BorderColor="White"
BackColor="White"></OtherMonthDayStyle>
boss --%>
<OtherMonthDayStyle Font-Names
=
"Arial"
ForeColor
=
"#006600"
BorderColor
=
"White"
BackColor
=
"White"
></OtherMonthDayStyle>
</asp:calendar>
4-C. Awk▲
awk
Sélectionnez
#! /usr/bin/awk -f
BEGIN
{
FS
=
"/"
}
{
path=
""
for
(i =
1
; i <
(NF
); i++
) {
path =
path $i "/"
}
print
path
}
4-D. Borland C++ , C , C++ , C#▲
bcb
Sélectionnez
// qlksfj
#define ssdfs\ fsdf \
sdfsdf sdfsdf sdfsdf \ sdfsdf
fsdfsdf sdfsdf sdfsfd
// skfskjfhd
#define sùfsmdf
void
__fastcall TForm1::
Button1Click(TObject *
Sender)
{
TButton *
Button;
Button =
dynamic_cast
<
TButton *>
(Sender);
if
(Button ==
Button1)
ShowMessage("Butt
\"
on1"
);
else
if
(Button ==
Button2)
ShowMessage("Button2"
);
else
ShowMessage("C’est louche"
);
Button->
Caption =
"Appuyé"
;
}
C
Sélectionnez
char
c1, c2, c3, c4;
/* ..000001
sdfsdf
sdfs01 */
// skjfdhksjdhfks
c1 =
5
; /* ..00000101 */
c2 =
4
; /* ..00000100 */
c3 =
c1 <<
2
; /* 00000101(c1) -> 00010100(c3)*/
if
(
a==
b) {
x =
5
;
}
else
{
x =
10
;
}
C++
Sélectionnez
/* ..000001
sdfsdf
sdfs01 */
// en début de ligne
#define c
// Machin
// commentaire
#endif
#endif
#endif
#endif
#endif
// commentaire
class
Base {
public
:
void
a() {
cout <<
"Base::a"
<<
endl; }
virtual
void
b(); {
cout <<
"Base::b"
<<
endl; }
}
;
int
main()
{
Base x;
x.a(); // affiche Base::a
x.b(); // affiche Base::b
// le cas intéressant
}
C#
Sélectionnez
// code en début
// Déclaration des variables
ArrayList CompteurXML =
new
ArrayList
(
);
ArrayList CompteurSQL =
new
ArrayList
(
);
/* ..0
000
01
00 */
// qlksfj
#define ssdfsfsdf
// skfskjfhd
#define sùfsmdf
string
sNomTable =
Table.
TableName;
// CompteurXML contient maintenant la liste des champs de la table
// passée en paramètre (provenant du fichier XML)
for
(
int
i =
0
;
i <
dsTableSQL.
Tables[
0
].
Rows.
Count -
1
;
i++
)
{
object
[]
ligne =
dsTableSQL.
Tables[
0
].
Rows[
i].
ItemArray;
}
4-E. CSS▲
css
Sélectionnez
/* définition du style de la police, et largeur du select */
select {
font-family :
Courier ;
font-size :
10
px ;
width :
200
px;
}
/* élément de couleur bleue */
option.bl_eu
{
color :
#0000FF
;
background-color :
#00CCFF
;
background :
blue
url(
img.png
)
;
background-color :
blue
;
background-image :
url(
img.png
)
;
}
4-F. Delphi et Delphi pour .NET▲
delphi
Sélectionnez
// Propriétés scalaires avec valeur par défaut
type
TMonSet = set
of
#0
..#31
;
...
property
MonEntier : integer
read
FMonEntier write
FMonEntier default
1
;
property
MonSet : TMonSet read
FMonSet write
FMonSet default
[#0
, #10
, #13
];
delphi
Sélectionnez
// commentaire
{
Un commentaire sur
plusieurs lignes }
{$ une directive }
Var
i:Integer
;
<a href="lien.html?parametre1=valeur1¶metre2=valeur2">test</a>
(*
Et un autre
*)
begin
For
i:=Onglet.PageCount-1
DownTo
0
Do
Begin
Onglet.ActivePageIndex:=i;
// En commentaire d ON ' euuuuuu
ShowMessage('Truc muche !'
kqjhsd'jhkjh’’’’’’hghg’’’’hg'
); // c’est un comment !
{ et un autre }
FileName:= 'Document.doc'
; // ou 'Document.rtf'
URL ='http://toto.com'
;
End
;
end
;
delphi pour .NET
Sélectionnez
// commentaire
{
Un commentaire sur
plusieurs lignes }
{$ une directive }
Var
i:Integer
;
(*
Et un autre
*)
begin
For
i:=Onglet.PageCount-1
DownTo
0
Do
Begin
Onglet.ActivePageIndex:=i;
// En commentaire d ON ' euuuuuu
ShowMessage('Truc muche !'
kqjhsd'jhkjh''hghghg'
); // c’est un comment !
{ et un autre }
FileName:= 'Document.doc'
; // ou 'Document.rtf'
URL ='http://toto.com'
;
End
;
end
;
4-G. INI▲
ini
Sélectionnez
[EditeurXML]
Nouveau
=
Recent0
=
"C:\BRUNO\HTML\kit.4
.0
.17
\documents\tables\tables.xml"
Recent1
=
"C:\BRUNO\HTML\kit.4
.0
.17
\documents\srcdelphi\srcdelphi.xml"
SommaireWidth
=
310
WINDOWSTATE
=
2
WIDTH
=
696
HEIGHT
=
480
LEFT
=
162
TOP
=
44
TimerMAJSommaire
=
1000
4-H. Java▲
java
Sélectionnez
// un comment en deb
public
class
MaClasse{
public
static
Map uneVariableStatique =
new
HashMap
(
);
static
{
/* uneVariableStatique.put("une clef","une valeur");
uneVariableStatique.put("une autre clef","une autre http:// jshdjshd");*/
//etc un comment et import
uneVariableStatique.put
(
"une clef"
,"une http://valeur"
);
uneVariableStatique.put
(
"une autre clef"
,"une autr
\"
e valeur
\\\"
"
);
qal.declareImports
(
"import com.unilog.data.Track"
);
import
toto;
}
}
4-I. Javascript▲
JavaScript
Sélectionnez
variable1 =
document
.
formulaire.
champs1.
value;
/*variable1 = 12 */
variable2 =
"qhkjqhfkq"
;
/*variable2 = 20 */
total =
variable1 +
variable2;
/*total = 1220 */
4-J. Shell linux▲
linux
Sélectionnez
#!/bin/bash
export PATH
=
$PATH
:.
# preparation du repertoire destination
prepareMainDirs html cache archives pdf
prepareGenDirs $1
html cache
echo " Application de la coloration syntaxique"
perl coloration.pl ../documents/$1
/$1
.xml ../ArtTmp.xml >
buildart.log
echo " Construction des pages html"
#Ligne modifiée par sinarf pour générer les fichiers php pour la version online.
perl buildart.pl ./../ArtTmp.xml ./../html/$1
/ ./../cache/$1
/ $1
cd ./../html/
java -jar ./../script/lib/Zippeur.jar ./../archives/$1
.zip $1
if
test $?
-ne 0; then
echo Echec lors de la creation du zip.
exit 1
else
echo ==
OK
==
fi
cp ../documents/$1
/$1
.xml ../html/$1
/
#suppression du fichier temporaire.
rm ../ArtTmp.xml >
buildart.log
xxd xxdxxd 'slfshldfhl'
anacron bison php
lkjlj "lkjlsjdf"
55
55
.999
ddd555 -666
+777
sldfkjg
+999
lksfgh 555
`xc,;vnx; xcvxcv `
shellscript
Sélectionnez
#!/bin/bash
export PATH
=
$PATH
:.
# preparation du repertoire destination
prepareMainDirs html cache archives pdf
prepareGenDirs $1
html cache
echo " Application de la coloration syntaxique"
perl coloration.pl ../documents/$1
/$1
.xml ../ArtTmp.xml >
buildart.log
echo " Construction des pages html"
#Ligne modifiée par sinarf pour générer les fichiers php pour la version online.
perl buildart.pl ./../ArtTmp.xml ./../html/$1
/ ./../cache/$1
/ $1
cd ./../html/
java -jar ./../script/lib/Zippeur.jar ./../archives/$1
.zip $1
if
test $?
-ne 0; then
echo Echec lors de la creation du zip.
exit 1
else
echo ==
OK
==
fi
cp ../documents/$1
/$1
.xml ../html/$1
/
#suppression du fichier temporaire.
rm ../ArtTmp.xml >
buildart.log
xxd xxdxxd 'slfshldfhl'
anacron bison php
lkjlj "lkjlsjdf"
55
55
.999
ddd555 -666
+777
sldfkjg
+999
lksfgh 555
`xc,;vnx; xcvxcv `
4-K. Oracle▲
oracle
Sélectionnez
CREAte
TABLE
hr.emp
(
empno NUMBER
(
5
)
PRIMARY
KEY
,
ename VARCHAR2
(
15
)
NOT
NULL
,
job VARCHAR2
(
10
)
,
mgr NUMBER
(
5
)
,
hiredate DATE
DEFAULT
sysdate
,
sal NUMBER
(
7
,2
)
,
com NUMBER
(
7
,2
)
,
deptno NUMBER
(
3
)
NOT
NULL
CONSTRAINT
dept_fk REFERENCES
hr.departments
(
department_id)
)
TABLESPACE
tbs1
-- on prend tous les entiers de la table #n moins les entiers de la table #n pour
STORAGE
(
INITIAL
50K
NEXT
50K
MAXEXTENTS
10
PCTINCREASE
25
)
;
4-L. Autre▲
other
Sélectionnez
COPY *.* C:\TEMP\BACKUP
4-M. Perso▲
Coloration personnalisée
Sélectionnez
// quartier courant
soit Quarter de type TChartQuarter;
// informations de graphismes du quartier courant dans son état
soit Graphics de type TChartQuarterGraphics;
// angle de départ, de milieu et de fin du quartier
soient MinAngle, MidAngle et MaxAngle de type Single;
// points sur la circonférence correspondant aux angles
soient MinPt, MidPt et MaxPt de type TPoint;
// point sur lequel centrer le texte
soit TextPos de type TPoint;
// le texte à afficher dans le quartier
soit Text de type string;
4-N. PHP▲
php
Sélectionnez
<?php
${
'variable_1'
}
=
'Premier essai'
;
$variable_2
=
'Second essai'
;
echo $varia
?>
str_replace("
\\
"
,
"
\\\"
"
,
"
/
"
,
$current_dir
);
// Utilisateurs de Windows, pens
<?php
error_reporting(E_ALL);
?>
<!
DOCTYPE HTML PUBLIC "
-//W3C//DTD HTML 4.01 Transitional//EN
"
"
http://www
"
>
<
html>
<
head>
<
meta http-
equiv=
"
Content-Type
"
content=
"
text/html; charset=iso-8859-1
"
>
<
title>
Document sans titre</
title>
</
head>
<
body>
<?php
// Exemple de code PHP pour Ano
/*Merci de ne pas faire gaffe à ce code crade*/
/* C’est juste pour un test, donc ce sera horrible volontairement
pis d’abord, si vous être pas content, je vous dit "zut"
Inutile de chercher à exécuter ce code, il ne fait absolument rien... */
/*
En PHP, les blocs de commentaires commencent par /* et finissent par *\/.
Les lignes de code ci-dessous gèrent la connexion à la base :
$host = 'localhost';
$user = 'root';
$bdd = 'ma_base';
$passwd = '';
mysql_connect($host, $user,$passwd) or die('erreur de connexion au serveur');
mysql_select_db($bdd) or die('erreur de connexion a la base de donnees');
si c’est pas mignon tout plein ça...
//*/
$id_temp
=
2.234343
;
$id_temp
+=
.1454545
;
$id_temp
=
$id_temp
-
1.254624
;
$id_temp
=
$id_temp
+
1243423
;
if
(comment ==
FALSE
) {
echo 'Error'
.
$myVar
/*.' !!!!'*/
;
}
$mot
[
0
]
=
"toto c est le plus beau, et c est
\"
Monsieur
\"
toto, "
;
$mot
[
0
]
=
"toto c’, je veux afficher des // , des /* , et des */ dans ma chaine"
;
$mot
[
1
]
=
$_GET
[
'toto'
];
$mot
[
1
]
=
$_POST
[
'toto'
];
$mot
[
1
]
=
$_SERVER
[
'toto'
];
$mot
[
1
]
=
$_ENV
[
'toto'
];
$mot
[
1
]
=
array_diff_uassoc(toto(ARRAY_Multisort(hw_Document_Attributes()));
$SQL_guillemet
=
"SELECT * FROM MA_TABLE WHERE ID =
$id_temp
AND MOT = '
$mot[0]
'"
;
$SQL_quote
=
'SELECT TOTO FROM MA_TABLE WHERE ID = '
.
$id_temp
.
' AND MOT =
\'
'
.
$mot
[
0
].
'
\'
'
;
class
MySystemException extends
Exception
{
/**
* @desc Constructeur
*/
public
function
__construct
($msg
,
$code
,
$file
,
$line
,
$context
)
{
$this
->
message =
$msg
;
$this
->
code =
$code
;
$this
->
line =
$line
;
$this
->
file =
$file
;
$this
->
context =
$context
;
parent
::
__construct
($msg
,
$code
);
}
/**
* @desc Affichage de l’erreur
*/
public
function
showError()
{
echo 'PHP a généré l
\'
erreur système suivante : ['
.
$this
->
code.
' | '
.
$this
->
getMessage().
'] à la ligne '
.
$this
->
line.
' du fichier '
.
$this
->
file;
// $Mytrace contient le contexte de l’exception
// $this->context contient le contexte de l’erreur
$Mytrace
=
$this
->
getTrace();
//print_r($Mytrace);
if
( !
empty($Mytrace
[
'1'
][
'function'
]
))
{
echo ' sur la fonction '
.
$Mytrace
[
'1'
][
'function'
];
}
echo '<br /><br/>Contexte lors de l
\'
erreur :<br/><pre>'
;
print_r($this
->
context);
echo '</pre>'
;
}
}
4-O. PostGreSQL▲
postgresql
Sélectionnez
SELECT
setval(
'ma_sequence'
,456
)
; -- on initialise ma_sequence à 456
SELECT
nextval
(
'ma_sequence'
)
; -- on incremente la proobtenons 457
SELECT
currval
(
'ma_sequence'
)
; -- on demande lanons 457
4-P. Python▲
python
Sélectionnez
def
toHtml
(
self, htmlFile):
"""
Ecris dans un fichier HTML la transformation
du fichier XML.
Si True est retourné, c’est que tout c’est bien passé.
Si def est retourné, des erreurs se sont produites.
"""
if
(
os.path.exists
(
self.xslFile) ==
False
):
print
(
'Le fichier XSL n
\'
existe pas'
)
return
False
if
(
os.path.exists
(
self.xmlFile) ==
False
):
print
(
"Le fichier XML n
\'
existe pas"
)
return
False
if
(
os.path.exists
(
self.xslFile) ==
False
):
print
(
'Le def XSL n
\'
existe pas'
)
return
False
styuri =
OsPathToUri
(
self.xslFile)
srcuri =
OsPathToUri
(
self.xmlFile)
4-Q. SQL▲
SQL
Sélectionnez
-- Commentaire
/* ssfdf
sdfsdfsf SELECT
sdfsdfsd*/
SELECT
*
FROM
TOTO WHERE
TITI=
"ksjdhfskdjhf WHERE"
skdhf
4-R. VB , VB.NET▲
vb
Sélectionnez
dfdf " erkejr "
' Initialisats
Private
Sub
Form_Load
(
)
' Initialisation de l’accès aux données
Dim
MaBD As
String
Dim
i as
Integer
MoyMax =
Format
(
MoyMax /
12
, "#0.0 "
ddd " eee "
) ' commentaire " h
' Initialisation du graphique simple
MoyMax =
Format
(
MoyMax /
12
, "#0.0 ' "
) ' commentaire " tftftf " hghgg
MSChart1.AllowSelections
=
False
' Interdit la sélection dans le graphe
MoyMax =
Format
(
MoyMax /
12
, "#0.0 ' "
) ' commentaire " tftftf " hghgg
MoyMax =
Format
(
MoyMax /
12
, "#0.0 ' "
) ' commentaire " tftftf " hghgg
End
Sub
vbnet
Sélectionnez
' skdjfhskdfh
' sdkfsldkjfsldj
sdfs<
' sfsjldkfjsdf
Imports
System
Imports
System.Text.RegularExpressions
Dim
s As
String
=
"SELECT * FROM matable WHERE madate='aujourd'hui' AND flag=1"
Char
&
NameSpace
ExemplesRegEx &
Public
Class
Verification
Shared
Sub
Main
(
)
Dim
verif as
Regex =
new
Regex
(
"[0-9]{10}"
)
Dim
numero as
String
=
"0123456789"
Dim
isNumero As
Boolean
=
verif.IsMatch
(
numero)
If
isNumero Then
Console.WriteLine
(
"Le numéro de téléphone est valide "
)
Else
Console.WriteLine
(
"Le numéro de téléphone n’est pas valide "
)
End
If
End
Sub
End
Class
End
NameSpace
4-S. XML▲
xml
Sélectionnez
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<xiti>
<!-- compteur Dotnet-->
<alias>
Dotnet</alias>
<logg_er>
logv99</logg_er>
<id>
12345</id>
</xiti>
</document>
Sélectionnez
<a href
=
"lien.html?parametre1=valeur1&aparametre2=valeur2"
>
test</a>
&jhgsjdgs;
qsdlfhqsdf ; qsdfqsd &dfdfd
dfdf ✏
✏
sjskdh