Translinguisme/Programmation

Un livre de Wikibooks.
Aller à : Navigation, rechercher

Sections

[modifier] Types

Langages Types des variables possibles
C char, double, enum, float, int, long, short, signed, struct, union, unsigned, void
OOo Basic boolean, currency, date, double, float, integer, long, single, string
Python basestring, bool, complex, dict, exception, file, float, fonction, frozenset, int, list, long, module, none, NotImplementedType, object, set, slice, str unicode, tuple, type, xrange[1]
SQL bigint, bit varying, char, date, datetime, decimal, double precision, float, integer, numeric, real, smallint, time, varchar, year
VB Byte, Boolean, Integer, Long, Single, Double, String[2]
PHP NULL, boolean, integer, float, string, array, object
HTML text, file, radio, checkbox, submit, hidden

[modifier] Syntaxes de base

[modifier] Structure du code

Langage Bloc d'instructions Condition simple Condition à cas multiples Boucles Sous-programmes Module Programme principal
Windows PowerShell (DOS) (
...
)
if ...condition... ...commande... else ...commande... for %%var in ( liste_ou_file_pattern ) do ... call :nom ...
...
:nom
...
goto :eof
séquence des commandes du fichier
Shell Unix if
...
fi
séquence des commandes du fichier
Python indentation if ... :
...
elif ... :
...
else:
while ... :
for ... :
Ada begin
...
end;
if (...) then ...
elsif (...) then ...
...
else ...
end if;
case (...)
when ... => ...
when others => ...
end case;
while (...) loop
...
end loop;
function nom(parametre:type;...) return type is
...
begin
...
return ...;
end;

procedure nom(parametre:(in/out/in out) type;...) is
...
begin
...
end;
nom.ads (spécification) :
package nom is
...
end nom;
nom.adb (corps) :
package body nom is
...
end nom;
utilisation :
with package,...; -- déclarer
use package,...; -- utiliser l'espace de nom
procedure nom is
...
begin
...
end;
Pascal begin
...
end;
function nom(parametre:type;...) : type;
...
begin
...
nom := ...;
end;

procedure nom(parametre:type;...);
...
begin
...
end;
unit nom;
interface
...
implementation
...
end.
utilisation :
uses unité,...;
program nom;
...
end.
C {
...
}
if (...) ...
else if (...) ...
...
else ...
switch(...)
{
case ...:...
...
default:...
}
while (...) ...
do ... while (...);
for (...;...;...) ...
type_retour nom(type param,...){...} utilisation :
#include fichier
int main(int argc, char** argv)
{ ... }
C++ {
...
}
if (...) ...
else if (...) ...
...
else ...
switch(...)
{
case ...:...
...
default:...
}
while (...) ...
do ... while (...);
for (...;...;...) ...
type_retour nom(type param,...){...} utilisation :
#include fichier
using namespace namespace;
int main(int argc, char** argv)
{ ... }
PHP {
...
}
Java {
...
}
if (...) ...
else if (...) ...
...
else ...
switch(...)
{
case ...:...
...
default:...
}
while (...) ...
do ... while (...);
for (...;...;...) ...
type_retour nom(type param,...){...} Déclaration (1ère ligne) :
package package;
utilisation :
import package.(classe ou *);
public static void main(String[] args)
{ ... }
JavaScript {
...
}
if (...) ...
else if (...) ...
...
else ...
switch(...)
{
case ...:...
...
default:...
}
while (...) ...
do ... while (...);
for (...;...;...) ...
function nom(param,...){...} séquence des commandes du fichier
Visual Basic rien if ... then
...
elseif ... then
...
end if
while ... wend
do while ... loop
for ... next
OOo Basic rien if ... then
...
elseif ... then
...
end if
while ... wend
do while ... loop
for ... next

[modifier] Commentaires et commandes de bases

Langage Ligne de commentaire Bloc de commentaire Écha-
ppement
Afficher Saisir Déclaration Définition Égal Différent Et Ou
Windows PowerShell (DOS) rem <# ... #> ^ echo pause, SET /P variable=[promptString], choix multiple : choice, copie : copy con variable : set, fichier : cp, copy, xcopy = (on appelle ensuite les variables avec %variable%) ==, EQU  !==!, NEQ -and[3] -or
Shell Unix #  : <<'END'...END \ echo sleep, read fichier : touch, cp, mv = =  != && ||
Python # '''...''', """...""" \ print raw_input() rien def ==  != and or
Ada -- rien \ Put(), Put_Line() Get(), GetLine() variable:type  := = /= and or
Pascal rien {...} ou (*...*) Chr() Write(), Writeln() Read(), Readln() var variable:type  := = <> and or
C rien /*...*/ \ printf(), fprintf(), sprintf(), puts() scanf() voir le paragraphe types =, adresse de pointeurs : == ==  != && ||
C++ // /*...*/ \ cout<< cin>> voir le paragraphe types =, adresse de pointeurs : == ==  != && ||
PHP //, ou # /*...*/ \ echo, printf $_GET, $_POST Objet : new =, variable : $ ==  ! && ||
Java // /*...*/ \ System.out.println() .getText() voir le paragraphe types, Objet : new = ==, objet : .equals()  != && ||
JavaScript // /*...*/ \ alert() prompt() var = ==  != && ||
HTML <!--...--> <!--...--> & rien <input> rien = rien rien rien rien
SQL --,
Oracle : rem, @[4]
/*...*/ " select print table : create table variable : :, table : update, insert = not and or
Visual Basic ', rem rien " MsgBox InputBox variable : dim
fonction : sub
= =, fichier : .CopyFile <> and or
OOo Basic ', rem rien " MsgBox InputBox variable : dim
fonction : sub
= = <> and[5] or

[modifier] Syntaxe et traitement de chaînes

Langage Retour à la ligne Concaténation Wildcard Classer Longueur Majuscule Minuscule Rechercher dans une chaîne Tronquer une chaîne
Windows PowerShell (DOS) \r\n commandes traitant le résultat de la précédente : | * sort /r
Shell Unix \n commandes : &&, ;, commandes traitant le résultat de la précédente : |, variables : >>, fichiers : cat * sort |sed 's/.*/\U&/'
ou |tr '[:lower:]' '[:upper:]'
|tr '[:upper:]' '[:lower:]' fichier : find, locate, programme : whereis fichier : head, tail
Python \n \r ou \r\n [6] + * sort() len() .upper() .lower() .find() []
Ada \n \r ou \r\n [6] chaines : &, commandes : ; * Gnat.Heap_Sort_G[7] variable'Size Characters. Handling. To_Upper() Characters. Handling. To_Lower() chaîne(début..fin)
C \n \r ou \r\n [6] chaines : strcat, commandes : , *, déclaration : ... qsort() sizeof -=32 +=32 strpbrk() strncat()
PHP \n \r ou \r\n [6] . glob("*"), str_replace("*") natcasesort() strlen strtoupper() strtolower() strrpos() substr()
Java \n + * Collections.sort() .length .toUpperCase() .toLowerCase() .indexOf(),
regex : .find()
.substring()
JavaScript \n \r ou \r\n [6] + * sort() .length .toUpperCase() .toLowerCase() .indexOf(), .lastIndexOf() .substr
HTML <br> rien rien rien
SQL rien ||, concat like %... group by count, length upper()[8] lower()[9] like substring()[10]
Visual Basic _ & * UCase() LCase() instr() left$(), mid$(), right$()
OOo Basic _ & * .SearchString mid()
Langage Attribut de classe Constructeur Libération Attendre Lister le répertoire courant Sortie
Windows PowerShell (DOS) del pause dir exit
Shell Unix rm, rmdir sleep, wait ls exit
Python type() self del time.sleep() os.path.normcase(f) fonction : return
boucle : break
Ada automatique delay secondes;
C *, déclaration : ... free() sleep
PHP is_numeric(), is_int(), is_integer(), is_float(), is_real(), is_double(), is_long(), is_scalar() $this-> unset(), unserialize() sleep() __FILE__ return
Java instanceof this automatique .sleep() File[] files = new File(".").listFiles() return
JavaScript getAttribute() window.setTimeout() object.BuildPath(path, name) return
HTML rien rien rien rien rien
SQL rien delete WAITFOR DELAY
Visual Basic .save, .saveas fichier : .DeleteFile Sleep dir() exit, .close, goto
OOo Basic .storeToURL() kill wait dir()

[modifier] Commandes communes aux shells Windows et Unix

  1. cd
  2. date
  3. echo
  4. exit
  5. fdisk
  6. ftp
  7. format
  8. help
  9. hostname
  10. mkdir
  11. more
  12. netstat
  13. nslookup
  14. ping
  15. rmdir

[modifier] Manipuler un fichier Excel

Langage Ouvrir Fermer Sauvegarder Écrire Paramètres des cellules
PHP[11] $this->Spreadsheet_Excel_Writer_Workbook($filename);
$workbook = new Spreadsheet_Excel_Writer();
$workbook->close(); $workbook->sendFile(); $worksheet->write(x,y,'Contenu'); $format = $workbook->addFormat(
array(
'Size' => 10,
'Align' => 'center',
'Color' => 'black',
'FgColor' => 'red'));
Visual Basic[12][13] .Workbooks.Open(ActiveWorkbook.Path & "\" & "NomDuFichier") .Close .Save Sheets(1).Cells(x,y).Value = "Contenu"
ou Sheets("feuille 1").Range(x & y).Value = "Contenu"
Range(x & y).Font.Size = 10
Range(x & y).HorizontalAlignment = xlCenter
Range(x & y).Font.Color = vbBlack
ou Range(x & y).Font.Colorindex = 2
Range(x & y).Interior.ColorIndex = 4

[modifier] Notes et références

  1. Python/Les types de base sur Wikiversité Article sur Wikiversité
  2. Visual Basic/Les types en VB sur Wikiversité Article sur Wikiversité
  3. http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-conditional-logic/
  4. http://www.querytool.com/help/1135.htm
  5. http://wiki.services.openoffice.org/wiki/FR/Documentation/BASIC_Guide/Operators
  6. 6,0, 6,1, 6,2, 6,3 et 6,4 Le retour à la ligne dépend du système d'exploitation et pas du langage de programmation dont le compilateur ou interpréteur peut être capable d'accepter les trois séquences possibles afin de réutiliser des codes sources provenant de systèmes différents :
    • \n pour Unix, Linux
    • \r pour Mac OS
    • \r\n pour DOS, Windows
  7. http://rosettacode.org/wiki/Sort_an_integer_array#Ada
  8. http://msdn.microsoft.com/fr-fr/library/ms180055.aspx
  9. http://msdn.microsoft.com/fr-fr/library/ms174400.aspx
  10. http://msdn.microsoft.com/fr-fr/library/ms187748.aspx
  11. Programmation PHP/La librairie PEAR DB
  12. Fichiers en VB sur Wikiversité Article sur Wikiversité
  13. http://cisternino.free.fr/informatique/excel/vba/cours_vba_excel_fiche_07.pdf


[modifier] Voir aussi

Outils personnels
Espaces de noms

Variantes
Actions
Bibliothèque
Navigation
Aide
Imprimer / exporter
Boîte à outils