Advertisement
AssazziN

Thai ID Generator

Mar 19th, 2013
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.40 KB | None | 0 0
  1. use Win32::GUI();
  2.  
  3. sub makeTSSN {
  4. $id[0]=int(rand(8))+1;
  5. $last=$id[0];
  6. foreach $z (2..12) {
  7.    $id[$z-1]=int(rand(9));
  8.    $tmp[$z-1]=$id[$z-1]*(14-$z);
  9.    $last+=$tmp[$z-1];
  10. }
  11. $last=11-($last%11);
  12. if ($last==11) {
  13.    $last=1;
  14. }
  15. elsif ($last==10) {
  16.    $last=0;
  17. }
  18. $key=join('',@id);
  19. $key.=$last;
  20. #return $key;
  21. return "$id[0]-$id[1]$id[2]$id[3]$id[4]-$id[5]$id[6]$id[7]$id[8]$id[9]-$id[10]$id[11]-$last";
  22. }
  23.  
  24. $main=Win32::GUI::Window->new(
  25.    -name   => 'Main',
  26.    -width  => 350,
  27.    -height => 200,
  28.    -title => "TSSN By AssazziN : 24.11.2010",
  29. );
  30. $main->AddLabel(
  31.    -name => "Text",
  32.    -left => 100,
  33.    -top => 20,
  34.    -width => 150,
  35.    -height => 20,
  36.    -text => "Thai ID Gen : AssazziN",
  37. );
  38. $main->AddTextfield(
  39.    -name   => "TextField",
  40.    -left   => 70,
  41.    -top    => 60,
  42.    -width  => 200,
  43.    -height => 25,
  44.    -prompt => "ID Gen : ",
  45.    -text => &makeTSSN,
  46.  
  47. );
  48. $main->AddButton(
  49.    -name    => 'Button',
  50.    -text    => 'Ok',
  51.    -default => 1,
  52.    -ok      => 1,
  53.    -width   => 60,
  54.    -height  => 20,
  55.    -left    => $main->ScaleWidth() - 200,
  56.    -top     => $main->ScaleHeight() - 50,
  57. );
  58.  
  59.  
  60. $main->Show();
  61. Win32::GUI::Dialog();
  62. exit(0);
  63. sub Main_Terminate {
  64.    return -1;
  65. }
  66.  
  67. sub Button_Click {
  68.    #$main->AddLabel(
  69.    #-text => &makeTSSN,
  70. #);
  71.    $main->TextField->Text(&makeTSSN);
  72.  
  73.  
  74.    print &makeTSSN,"\n";
  75.    return 0;
  76. }
  77. #http://comfreedom.blogspot.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement