Kit : Améliorations de la gestion du code
Date de publication : 16/11/2006 , Date de mise à jour : 28/01/2006
4. Langages déjà supportés par l'ancien système de coloration
4-A. Action script
4-B. ASP , ASP.NET
4-C. Awk
4-D. Borland C++ , C , C++ , C#
4-E. CSS
4-F. Delphi et Delphi pour .NET
4-G. INI
4-H. Java
4-I. Javascript
4-J. Shell linux
4-K. Oracle
4-L. Autre
4-M. Perso
4-N. PHP
4-O. PostGreSQL
4-P. Python
4-Q. SQL
4-R. VB , VB.NET
4-S. XML
4. Langages déjà supportés par l'ancien système de coloration
4-A. Action script
ActionScript |
on (release) {
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 ;
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 );
while (c = = nEspace) {
c = s. charCodeAt (- - nEnd) ;
}
return s. substring (nBegin, nEnd+ 1 );
}
var sAncienneChaine: String = " Ceci est une chaîne avec des espaces inutiles au début et à la fin " ;
var sltChaine: String = trim (sAncienneChaine);
trace (" -> \" " + sltChaine+ " \" <- " );
trace (" **/*****************************************/** " );
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 ();
}
}
trace (Stage . width + " " + triangle_mc. _width );
|
4-B. ASP , ASP.NET
asp |
< %
idimage_get = Request . QueryString (" idimage " )
Set conn = Server . CreateObject (" ADODB.Connection " )
conn. Open chainedeconnexion
requete = " SELECT type_image, bin_image FROM images WHERE idimage= " & idimage_get
Set rs = conn. Execute (requete)
Response . ContentType = rs (" type_image " )
Response . BinaryWrite (rs (" bin_image " ))
conn. close
Set conn = Nothing
%>
|
aspnet |
< 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%>
< DayStyle Font - Names = " Arial " ForeColor = " # 006600 " > < / DayStyle >
< DayHeaderStyle Font - Names = " Arial " ForeColor = " White " BorderColor = " # 006600 "
BackColor = " # 006600 " > < / DayHeaderStyle >
< OtherMonthDayStyle Font - Names = " Arial " ForeColor = " # 006600 " BorderColor = " White "
BackColor = " White " > < / OtherMonthDayStyle >
< OtherMonthDayStyle Font - Names = " Arial " ForeColor = " # 006600 " BorderColor = " White "
BackColor = " White " > < / OtherMonthDayStyle >
< / asp : calendar >
|
4-C. Awk
awk |
BEGIN {
FS = " / "
}
{
path= " "
for (i = 1 ; i < (NF ); i+ + ) {
path = path $i " / "
}
print path
}
|
4-D. Borland C++ , C , C++ , C#
bcb |
# define ssdfs \ fsdf \
sdfsdf sdfsdf sdfsdf \ sdfsdf
fsdfsdf sdfsdf sdfsfd
# 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 |
char c1, c2, c3, c4;
c1 = 5 ;
c2 = 4 ;
c3 = c1 < < 2 ;
if (a= = b) {
x = 5 ;
} else {
x = 10 ;
}
|
C++ |
# define c / / Machin
# endif
# endif
# endif
# endif
# endif
class Base {
public :
void a () { cout < < " Base::a " < < endl; }
virtual void b (); { cout < < " Base::b " < < endl; }
} ;
int main ()
{
Base x;
x.a ();
x.b ();
}
|
C# |
ArrayList CompteurXML = new ArrayList ();
ArrayList CompteurSQL = new ArrayList ();
#define ssdfsfsdf
#define sùfsmdf
string sNomTable = Table. TableName;
for ( int i = 0 ; i < dsTableSQL. Tables[ 0 ] . Rows. Count - 1 ; i+ + )
{
object [ ] ligne = dsTableSQL. Tables[ 0 ] . Rows[ i] . ItemArray;
}
|
4-E. CSS
css |
select {
font-family : Courier ;
font-size : 10px ;
width : 200px ;
}
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 |
Var i: Integer ;
< a href= "lien. html?parametre1= valeur1¶metre2= valeur2"> test< / a>
begin
For i:= Onglet. PageCount- 1 DownTo 0 Do
Begin
Onglet. ActivePageIndex:= i;
ShowMessage( ' Truc muche ! ' kqjhsd' jhkjh ' ' ' ' ' ' hghg ' ' ' ' hg ' ) ;
FileName:= ' Document.doc ' ;
URL = ' http://toto.com ' ;
End ;
end ;
|
delphi pour .NET |
Var i: Integer ;
begin
For i:= Onglet. PageCount- 1 DownTo 0 Do
Begin
Onglet. ActivePageIndex:= i;
ShowMessage( ' Truc muche ! ' kqjhsd' jhkjh ' ' hghghg ' ) ;
FileName:= ' Document.doc ' ;
URL = ' http://toto.com ' ;
End ;
end ;
|
4-G. INI
ini |
[ 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 |
public class MaClasse{
public static Map uneVariableStatique = new HashMap ();
static {
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;
}
}
|
java |
package test;
import java.io.Serializable;
import java.util.Date;
{@link }
@author
@since
@see
public abstract strictfp class TestAno extends Object implements Serializable {
interface Marqueur { }
@ interface AnnotationMarqueur { }
enum TestEnum { VALEUR1, VALEUR2, VALEUR3; }
private volatile Date date;
protected transient Object obj;
public static final String TEST = " Une chaine et une \"sous-chaine\" " ;
@deprecated
@ Deprecated
public TestAno () {
this (new Date ());
}
< b > < / b >
@param
@throws
@exception
public TestAno (Date d) {
super ();
this .date = new Date (d.getTime ());
}
@return
@ Override
@ SuppressWarnings (" deprecation " )
public String toString () {
return date.getDate () + " / " + date.getMonth () + " / " + (1900 + date.getYear ());
}
public void method (boolean b, short s, int i, long l,
float f, double d, char c) {
synchronized (this ) {
}
}
}
|
4-I. Javascript
JavaScript |
variable1 = document. formulaire. champs1. value;
variable2 = " qhkjqhfkq " ;
total = variable1 + variable2;
|
4-J. Shell linux
linux |
export PATH =$ PATH :.
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 "
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 /
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 |
export PATH =$ PATH :.
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 "
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 /
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 |
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
STORAGE
(
INITIAL 50K
NEXT 50K
MAXEXTENTS 10
PCTINCREASE 25
) ;
|
4-L. Autre
4-M. Perso
Coloration personnalisée |
// 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 correspondants 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 |
if ($ truc = = = TRUE ){
echo(" Hello $ bidule . . . " );
}
|
php_mixte |
<style type = " text / css " >
.machin {
font-family : Verdana , sans-serif ;
}
</style>
<?php
if ($ truc = = = TRUE ){
echo(" Hello $ bidule . . . " );
}
?>
if($truc === TRUE){
echo("Hello $bidule ...");
}
<?
if ($ truc = = = TRUE ){
echo(" Hello $ bidule . . . " );
}
?>
|
php_mixte |
<?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
$ 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 chaîne " ;
$ 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
{
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 );
}
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 = $this ->getTrace ();
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> ' ;
}
}
|
php_mixte |
<?php
require_once (' C:/Mes Documents/Web/includes/poka-yoke/main.php ' );
class Login extends DVP_DataFilter
{
public function __construct ()
{
parent : : __construct ($ _POST );
$this ->filterSingleLine (' login ' );
$this ->untaint (' password ' );
$this ->filterUsingArray (' persistant ' , array (' yes ' ), DVP_DataFilter: : ARRAY_STRINGS);
$this ->clean ();
unset ($ _POST );
}
}
if (! empty($ _POST ))
{
$_POST = new Login ();
$ sql = ' SELECT id
FROM user
WHERE login = " ' . $_POST ->getHTML (' login ' ). ' "
AND password = " ' . md5($_POST ->getRaw (' login ' )). ' " ' ;
if (true )
{
echo ' Connecté en tant que ' . $_POST ->getHTML (' login ' ). ' <br /> ' ;
if (! $_POST ->isEmpty (' persistant ' ))
{
}
}
echo ' <br /><br /> ' ;
foreach ($ _POST as $ field )
{
echo ' <b> ' . $ field . ' </b> : ' . $_POST ->getHTML ($ field ). ' <br /> ' . " \n " ;
}
echo ' <br /><br /> ' ;
}
?>
< form method = " post " action = " <?php echo basename(__FILE__ ); ?> " style=" width : 100 % ; text-align : center ; border : 1px solid black ;" >
< label > < input type = " text " name = " login " / > Nom d'utilisateur< / label > < br / >
< label > < input type = " password " name = " password " / > Mot de passe< / label > < br / >
< label > < input type = " checkbox " name = " persistant " value = " yes " / > Rester connect& eacute ; ?< / label > < br / >
< input type = " submit " value = " Envoyer " / >
< input type = " reset " value = " Rétablir " / >
< / form >
|
4-O. PostGreSQL
postgresql |
SELECT setval(' ma_sequence ' ,456 );
SELECT nextval (' ma_sequence ' );
SELECT currval (' ma_sequence ' );
|
4-P. Python
python |
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)
|
python |
import time
class Toto:
""" classe test """
def __init__ (self):
self.a = 5
self.b = 7
@d eco
def affiche (self):
for i in range (100 ):
if self.value > 10 : print " on affiche un string "
elif self.value < 5 : print ' toto '
else : print 0xA15F
return " ' chaine entre cotes ' "
|
4-Q. SQL
SQL |
SELECT * FROM TOTO WHERE TITI= " ksjdhfskdjhf WHERE "
skdhf
|
4-R. VB , VB.NET
vb |
dfdf " erkejr "
Private Sub Form_Load ()
Dim MaBD As String
Dim i as Integer
MoyMax = Format (MoyMax / 12 , " #0.0 " ddd " eee " )
MoyMax = Format (MoyMax / 12 , " #0.0 ' " )
MSChart1. AllowSelections = False
MoyMax = Format (MoyMax / 12 , " #0.0 ' " )
MoyMax = Format (MoyMax / 12 , " #0.0 ' " )
End Sub
|
vb |
Private Const ERROR_SUCCESS As Long = 0 &
Private Const WM_USER As Long = & H400
Private Const MAX_PATH As Long = 260
Public Declare Function SendMessage Lib " user32 " Alias " SendMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Any) As Long
Private Sub Command1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Integer
On Error GoTo Command1_MouseDown_Error
If Button = 2 Then
Dim objHelp As Chelp
Set objHelp = New Chelp
Call objHelp. Show (App. HelpFile , " W1 " , 10 )
Set objHelp = Nothing
End If
For i = 1 To UBound (Montab)
Debug. Print i
Next i
Do
i = i + 1
Loop Until i > 10
Exit Sub
Command1_MouseDown_Error :
Select Case Err
Case 32755
Case Else
MsgBox " Error " & Err . Number & " ( " & Err . Description & " ) in procedure Command1_MouseDown of Feuille Form1 "
End Select
Err . Clear
End Sub
Private Sub Form_Load ()
Dim objHelp As Chelp
App. HelpFile = App. Path & " \TestProg.chm "
Set objHelp = New Chelp
Call objHelp. HelpInit
Set objHelp = Nothing
MsgBox Me. UserControl11 . MaProp
End Sub
|
MsgBox " Error " & Err . Number & " ( " & Err . Description & " ) in procedure Command1_MouseDown of Feuille Form1 "
|
vbnet |
sdfs<
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 |
<? xml version="1.0" encoding="ISO-8859-1"? >
< document >
< xiti >
< alias > Dotnet< / alias >
< logg_er > logv99< / logg_er >
< id > 12345< / id >
< / xiti >
< / document >
|
< a href = " lien.html?parametre1=valeur1&aparametre2=valeur2 " > test< / a >
& jhgsjdgs ; qsdlfhqsdf ; qsdfqsd & dfdfd dfdf & #9999 & #9999 ; sjskdh
|
Ce document ment ment est issu de http://www.developpez.com et reste la propriété exclusive de son auteur.
La copie, modification et/ou distribution par quelque moyen que ce soit est soumise à l'obtention préalable de l'autorisation de l'auteur.