Servus-Woid-Programm

Aus Wikipedia
Wexln zua: Navigation, Suach
Der Artikl is im Dialekt Obaboarisch gschrim worn.
S' Servus-Woid- Programm in da esoterischn Programmiersprach Piet. Die buntn Kastln stenga fia Befehle.

S' "Servus-Woid"-Programm is a Tradition in da Litaratur iaba Programmiersprachn. Do hoasts in deitsche Biacha "Hallo-Welt-Programm" und in de englischn "Hello-World-Program". S' is a oanfachs Programm, des den Text "Servus Woid" aufn Buidschirm schreibt. Ma ko damit zoang, was ma auf jedn Foi in da jeweilign Sproch bracht um iabahaupt a lauffähigs Programm zum schreim. Normalaweis stehts in am jedn Lehrbuach iabas Programmiern glei ganz am Ofang. S'werd a gern heagnumma um zum iabapriafn ob a Compiler oda Interpreter iabahaupt richtig funktioniad. De Tradition gehd aufn Kernighan Brian zruck, ders 1974 in am internen Handbuach iaba C bei Bell Laboratories gschribn hod. In da Effntlichkeit is aba erst bekannt worn, ois da Kernighan Brian zsamad mit'm Ritchie Dennis as Buach The C Programming Language rausbracht hod. Do inna drin wurd de Schreibweis „hello, world“ vawendt. S' Servus-Woid-Programm gherd eingle a zum Liafaumfang vo a jedn Programmiersprach, do findt mas bei de Beispui-Quelltext.

Beispui[VE | Weakln]

Wia ma an de Beispui sigt, is des manchmoi gor ned so oafach an Text aufn Buidschirm zbringa. Wobei des Beispui "Windows API" scho a bissal mera biet, do kriagt ma a richtigs Fensta, des ma umanandaschiam ko und Gress ändern ko ma a.

Assembler[VE | Weakln]

x86-CPU, DOS, MASM[VE | Weakln]

.MODEL Small
.STACK 100h
.DATA
  HW      DB      'Servus Woid!$'
.CODE
 
start:
  MOV AX,@data
  MOV DS,AX
  MOV DX, OFFSET HW
  MOV AH, 09H
  INT 21H
  MOV AH, 4Ch
  INT 21H
end start

x86-CPU, DOS, FASM[VE | Weakln]

; Kompiliert: "FASM HELLO.ASM HELLO.COM" 
  org  $100
  use16    
  mov  ah,9
  mov  dx,hello
  int  $21    ; Textausgob
  mov  ah,$4C
  int  $21    ; Programm beendn
hello db 'Servus Woid!$'

x86-CPU, Linux[VE | Weakln]

# Kompiliert mid "as -o hallo.o hallo.s; ld -o hallo hallo.o"
    .section .data
   s: .ascii "Servus Woid!\n"
    .section .text
    .globl _start
   _start:
    movl $4,%eax      # Syscall-ID 4 (= __NR_write) 
    movl $1,%ebx      # Ausgabe-Filedeskriptor STDOUT (= 1)
    movl $s,%ecx      # Adresse des erstn Zeichns dea Zeichnkettn
    movl $12,%edx     # Länge dea Zeichenkettn (12 Zeichn)
    int $0x80         # Softwäreinterrupt 0x80 um Syscall (write(1,s,12))auszführn
    movl $1,%eax      # Syscall-ID 1 (= __NR_exit)
    movl $0,%ebx      # Rückgobewert 0 (= alles ok)
    int $0x80         # Softwäreinterrupt 0x80 um Syscall (exit(0)) auszführn

BASIC[VE | Weakln]

    10 PRINT "Servus Woid!"

C[VE | Weakln]

#include <stdio.h>
 
int main(void)
{
    printf("Servus Woid!\n");
    return 0;
}

C++[VE | Weakln]

#include <iostream>
using namespace std;
 
int main() {
cout<<"Servus Woid"<<endl;
return 0;
}

JavaScript[VE | Weakln]

document.write("Servus Woid!");

MS-DOS Batch[VE | Weakln]

@echo Servus Woid!

BASH[VE | Weakln]

echo "Servus Woid!"

Object Pascal (Delphi)[VE | Weakln]

program ServusWoid;
{$APPTYPE CONSOLE}
 
begin
  writeln('Servus Woid!');
end.

PHP[VE | Weakln]

<?php
    echo "Servus Woid!";
?>

Python[VE | Weakln]

#! /usr/bin/env python
 
print "Servus Woid!"

Perl[VE | Weakln]

print "Servus Woid!\n";

oda

say "Servus Woid!";

Seed7[VE | Weakln]

$ include "seed7_05.s7i";

const proc: main is func
  begin
    writeln("Servus Woid!");
  end func;

Smalltalk[VE | Weakln]

Transcript show: 'Servus Woid!'.

Windows API (in C)[VE | Weakln]

#include <windows.h>
 
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  MessageBox(0, "Servus Woid!", "Mei ersts Programm", MB_OK);
  return 0;
}

Oder mit am eignem Fensta

#include <windows.h>
 
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
 
char szClassName[] = "MainWnd";
HINSTANCE hInstance;
 
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  HWND hwnd;
  MSG msg;
  WNDCLASSEX wincl;
 
  hInstance = hInst;
 
  wincl.cbSize = sizeof(WNDCLASSEX);
  wincl.cbClsExtra = 0;
  wincl.cbWndExtra = 0;
  wincl.style = 0;
  wincl.hInstance = hInstance;
  wincl.lpszClassName = szClassName;
  wincl.lpszMenuName = NULL; //No menu
  wincl.lpfnWndProc = WindowProcedure;
  wincl.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); //Color of the window
  wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //EXE icon
  wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION); //Small program icon
  wincl.hCursor = LoadCursor(NULL, IDC_ARROW); //Cursor
 
  if (!RegisterClassEx(&wincl))
        return 0;
 
  hwnd = CreateWindowEx(0, //No extended window styles
        szClassName, //Class name
        "", //Window caption
        WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX,
        CW_USEDEFAULT, CW_USEDEFAULT, //Let Windows decide the left and top positions of the window
        120, 50, //Width and height of the window,
        NULL, NULL, hInstance, NULL);
 
  //Make the window visible on the screen
  ShowWindow(hwnd, nCmdShow);
 
  //Run the message loop
  while (GetMessage(&msg, NULL, 0, 0))
  {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
  }
  return msg.wParam;
}
 
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  PAINTSTRUCT ps;
  HDC hdc;
  switch (message)
  {
  case WM_PAINT:
        hdc = BeginPaint(hwnd, &ps);
        TextOut(hdc, 15, 3, "Servus Woid!", 13);
        EndPaint(hwnd, &ps);
        break;
  case WM_DESTROY:
        PostQuitMessage(0);
        break;
  default:
        return DefWindowProc(hwnd, message, wParam, lParam);
  }
  return 0;
}

SQL (Oracle)[VE | Weakln]

SELECT 'Servus Woid!' FROM dual;

Im Netz[VE | Weakln]

 Commons: Hello World – Sammlung vo Buidl, Videos und Audiodateien