You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
$DirectoryName = "C:\Temp\rename_test_new"
Try {
$newDirectoryName = $DirectoryName -replace "_new", "_old"
Rename-Item -path $DirectoryName -newName $newDirectoryName
}
Catch {
Write-host "Error. Exit!"
Write-Error $_.Exception.Message
exit # Wenn das Script hart beendet werden soll, dann kann exit verwendet werden
}
26
Delphi
Exceptions
Try Catch Except
try
// Code
except
// Handle the exception here...
end;
160
Python
Exceptions
Try Catch Except
try:
print 1/0
except Exception as e:
print traceback.extract_stack()
else:
print "this is the else block"
finally:
print "finally clean up or something"
195
Python
Exceptions
Exception auslösen
if (a!=b):
raise Exception("Not implemented, yet")
214
T-SQL
Exceptions
Try Catch Except
-- See also: http://msdn.microsoft.com/de-de/library/ms175976(v=sql.105).aspx
-- !!
-- TRY-CATCH cannot be used for all operations/situations in T-SQL.
-- Be careful and refer to the link above for details
-- !!
BEGIN TRY
SELECT 1/0;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
28
Delphi
Prozeduren, Funktionen, Methoden
Verarbeitung gezielt beenden
procedure TForm1.Proz(Sender: TObject);
begin
If 1<>2 Then exit;
ShowMessage('Test');
end;
167
Bash Script
Prozeduren, Funktionen, Methoden
Deklaration einer Funktion/Prozedur
#!/bin/sh
do_something()
{
echo $1
echo $2
}
do_something "this is my first" " and second argument"
# this is my first and second argument
188
Python
Prozeduren, Funktionen, Methoden
Deklaration einer Funktion/Prozedur
def this_is_my_function_name(param1):
print "do something inside the function " + param1
print "do something outside the function"
# call the function
this_is_my_function_name("hello world")
30
Java
Zahlen/Rechnen
Nachkommastellen
import java.text.*;
// mindestens 1 Vorkommastelle, genau 2 Nachkommastellen
DecimalFormat f = new DecimalFormat("#0.00");
double d1 = 1234.4843;
double d2 = 0.2;
System.out.println(f.format(d1));
System.out.println(f.format(d2));
// Ausgabe d1=1234,4843 <--- man beachte das Komma!
// Ausgabe d2=0,2