Sephiroth
http://sephiroth.scifi-action.de/board/

$perso()
http://sephiroth.scifi-action.de/board/viewtopic.php?f=4&t=118
Seite 1 von 1

Autor:  Sephiroth [ 1. Dezember 2010 21:39 ]
Betreff des Beitrags:  $perso()

;; Usage: $perso(Personalausweisnummer)
;; Returns true or false
;; Example: $perso(2406055684D-6810203-0705109-6) should return $true
;; Example: $perso(2406055684D-6810203-0705109-7) should return $false
;; Example from: http://www.pruefziffernberechnung.de/P/Personalausweis-DE.shtml
alias perso {
  var %x = $len($1),%t return $true,%f return $false
  tokenize 45 $1
  if ((%x != 29) || ($len($1) != 11) || ($len($2) != 7) || ($len($3) != 7) || ($len($4) != 1) || ($right($1,1) !isletter)) %f
  tokenize 32 $left($1,-1) $2-
  if ($p($1)) && ($p($2)) && ($p($3)) && ($p($remove($1-,$chr(32)))) { %t } | else { %f }
}
alias -l p {
  if ($1 !isnum) { return $false }
  var %x $1,%o 0,%s
  while ($mid(%x,2)) {
    inc %o
    %s = %s $right($calc($gettok(7 3 1,%o,32) * $left(%x,1)),1)
    %x = $v1
    if (%o == 3) %o = 0
  }
  if ($right($sum(%s),1) == $right($1,1)) { return 1 }
}

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/