home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4611 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  6.4 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!doug.cae.wisc.edu!umn.edu!kksys.com!orbit!pnet51!dt
  2. From: dt@pnet51.orb.mn.org (Ryan Williams)
  3. Newsgroups: comp.lang.pascal
  4. Subject: need help with data bases!
  5. Message-ID: <8157@orbit.cts.com>
  6. Date: 27 Jul 92 06:45:14 GMT
  7. Sender: news@orbit.cts.com
  8. Organization: People-Net [pnet51], Minneapolis, MN.
  9. Lines: 419
  10.  
  11.  
  12.  
  13.  
  14. type Sex  = (Male,Female);
  15.  
  16.      User = record
  17.  
  18.              UserName : string[25];
  19.  
  20.              UserNum  : integer;
  21.  
  22.              Location : string[25];
  23.  
  24.              Gender   : sex;
  25.  
  26.              PhoneNum : String[8];
  27.  
  28.              Password : string[12];
  29.  
  30.              UserLevl : integer;
  31.  
  32.             End;
  33.  
  34.      Mesgs = record
  35.  
  36.               From     : string[20];
  37.  
  38.               MTo      : string[20];
  39.  
  40.               Subject  : string[30];
  41.  
  42.              ENd;
  43.  
  44.  
  45.  
  46.  
  47.  
  48. var
  49.  
  50.   UNumRd                      : word;
  51.  
  52.   UNumWr                      : word;
  53.  
  54.   events                      : text;
  55.  
  56.   Chatstatus                  : boolean;
  57.  
  58.   Usern                       : integer;
  59.  
  60.   Pass                        : string[12];
  61.  
  62.   Mch                         : char;
  63.  
  64.   TimeOut                     : integer;
  65.  
  66.   Yn                          : boolean;
  67.  
  68.   Password                    : string;
  69.  
  70.   Yesn                        : char;
  71.  
  72.   GetOff                      : boolean;
  73.  
  74.   Year, Month, Day, Dayofweek : word;
  75.  
  76.   Hour, Minute, Second, Sec100: word;
  77.  
  78.   CCycle                      : integer;
  79.  
  80.   UserFile                    : file of User;
  81.  
  82.  
  83.  
  84.  
  85.  
  86. procedure Startup;
  87.  
  88.  
  89.  
  90. begin
  91.  
  92.  assign(UserFile,'USERS.FIL');
  93.  
  94.  reset(UserFile);
  95.  
  96.  close(UserFile);
  97.  
  98.  assign(events,'EVENTS.TXT');
  99.  
  100.  Append(events);
  101.  
  102.  Gettime(Hour,Minute,Second,Sec100);
  103.  
  104.  Writeln(events,'System brought up at ',Ret_Date,' @  ',Ret_Time);
  105.  
  106.  Close(events);
  107.  
  108.  LastUser:='Nobody';
  109.  
  110. End;
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. procedure NewUserP;
  119.  
  120.  
  121.  
  122. type sex=(Male,Female);
  123.  
  124.  
  125.  
  126.  
  127.  
  128. var
  129.  
  130.   NewUser     : User;
  131.  
  132.   UserName    : String[25];
  133.  
  134.   PhoneNum    : String[8];
  135.  
  136.   Location    : String[25];
  137.  
  138.   Password    : String[12];
  139.  
  140.   Age         : integer;
  141.  
  142.   Good        : Boolean;
  143.  
  144.   CCCycle     : integer;
  145.  
  146.   Chr         : char;
  147.  
  148.   gender      : sex;
  149.  
  150.   response    : char;
  151.  
  152.   A           : byte;
  153.  
  154.   UserNum     : integer;
  155.  
  156.  
  157.  
  158. const
  159.  
  160.   UserLevl    : integer = 2;
  161.  
  162.  
  163.  
  164. begin
  165.  
  166. {whatever}
  167.  
  168. with NewUser do
  169.  
  170.  ClrScr;
  171.  
  172.  Good:=TRUE;
  173.  
  174.  repeat
  175.  
  176.    repeat
  177.  
  178.     Write('What is your name?');
  179.  
  180.     Readln(UserName);
  181.  
  182.    until not (Username='');
  183.  
  184.     Good:=TRUE;
  185.  
  186.     For CCycle:=1 to Totusers do
  187.  
  188.      if UserName=UserNm[CCycle]  then begin
  189.  
  190.                                       Writeln('Sorry, that name is already in
  191. use.');
  192.  
  193.                                       Good:=FALSE;
  194.  
  195.                                       End;
  196.  
  197.      if Copy(UserName,1,1)='0' then Good:=FALSE;
  198.  
  199.      if Copy(UserName,1,1)='1' then good:=false;
  200.  
  201.      if Copy(username,1,1)='2' then good:=false;
  202.  
  203.      if copy(username,1,1)='3' then good:=false;
  204.  
  205.      if copy(username,1,1)='4' then good:=false;
  206.  
  207.      if copy(username,1,1)='5' then good:=false;
  208.  
  209.      if copy(username,1,1)='6' then good:=false;
  210.  
  211.      if copy(username,1,1)='7' then good:=false;
  212.  
  213.      if copy(username,1,1)='8' then good:=false;
  214.  
  215.      if COpy(UserName,1,1)='9' then good:=false;
  216.  
  217.  until Good=TRUE;
  218.  
  219.  repeat
  220.  
  221.   Write('Where are you calling from?');
  222.  
  223.   Readln(Location);
  224.  
  225.  until not (Location='');
  226.  
  227.  repeat
  228.  
  229.   Write('What is your age?');
  230.  
  231.   Readln(Age);
  232.  
  233.  until not (Age=0);
  234.  
  235.  Write('Are you male or female? [M,F] ');
  236.  
  237.  repeat
  238.  
  239.   response:=UpCase(GetChar);
  240.  
  241.  until (response='M') or (response='F');
  242.  
  243.  If Response='M' then Gender:=Male;
  244.  
  245.  If response='F' then Gender:=Female;
  246.  
  247.  Writeln('');
  248.  
  249.  repeat
  250.  
  251.   Writeln('What is your phone number?');
  252.  
  253.   Writeln('Write in form: xxx-xxxx');
  254.  
  255.   Write('Number?');
  256.  
  257.   Readln(PhoneNum);
  258.  
  259.   Good:=TRUE;
  260.  
  261.   if Copy(PhoneNum,1,1)='1' then Good:=FALSE;    {fake number trapping}
  262.  
  263.   If Copy(PhoneNum,1,1)='0' then Good:=FALSE;
  264.  
  265.   If Copy(PhoneNum,1,3)='911' then Good:=FALSE;
  266.  
  267.   If PhoneNum='' then Good:=FALSE;
  268.  
  269.   If PhoneNum='PRI-VATE' then Good:=FALSE;
  270.  
  271.   If PhoneNum=BBSNumber then GOod:=FALSE;
  272.  
  273.   until Good=TRUE;
  274.  
  275.  repeat
  276.  
  277.   Write('What would you like to use for a password?');
  278.  
  279.   Readln(Password);
  280.  
  281.  until not (Password='');
  282.  
  283.  For A:=1 to length(Password) do
  284.  
  285.      Password[A]:= upcase(Password[A]);
  286.  
  287.  ClrScr;
  288.  
  289.  Writeln('       Alias: ',UserName);
  290.  
  291.  Writeln('      Gender: ',Response);
  292.  
  293.  Writeln('    Password: ',Password);
  294.  
  295.  Writeln('      Phone # ',PhoneNum);
  296.  
  297.  Writeln('Calling from: ',Location);
  298.  
  299.  Writeln('');
  300.  
  301.  Write('Is all this information correct? (y/n)');
  302.  
  303.  Yn:=KeyPressed;
  304.  
  305.  Mch:=GetChar;
  306.  
  307.  If Mch='N' then NewUserP;
  308.  
  309.  UserNum:=1;
  310.  
  311.  UserLevl:=2;
  312.  
  313.  reset(UserFile);
  314.  
  315.  Seek(userfile,usernum-1);
  316.  
  317.  Write(Userfile,NewUser);
  318.  
  319.  close(Userfile);
  320.  
  321.  Append(events);
  322.  
  323.  Writeln(events,'New user logon: ',UserName,' ',Ret_Date,' @ ',Ret_Time);
  324.  
  325.  close(events);
  326.  
  327. End;
  328.  
  329.  
  330.  
  331.  
  332.  
  333. procedure InfoCenter;
  334.  
  335.  
  336.  
  337. var
  338.  
  339.    NewUser       : User;
  340.  
  341.    UserName      : string[25];
  342.  
  343.    Location      : string[24];
  344.  
  345.    Phonenum      : string[8];
  346.  
  347.    Password      : string[12];
  348.  
  349.    Gender        : sex;
  350.  
  351.    index         : integer;
  352.  
  353.    Usernum       : integer;
  354.  
  355.    inch          : string;
  356.  
  357.  
  358.  
  359. begin
  360.  
  361.      ClrScr;
  362.  
  363.      repeat
  364.  
  365.      Write('Information>');
  366.  
  367.      Yn:=KeyPressed;
  368.  
  369.      Mch:=GetChar;
  370.  
  371.      case Mch of
  372.  
  373.        'L','U' : begin
  374.  
  375.                    Usernum:=0;
  376.  
  377.                    index:=0;
  378.  
  379.                    ClrScr;
  380.  
  381.                    Writeln('User List:');
  382.  
  383.                    Writeln('NAME---------------|LOCATION------------');
  384.  
  385.                    {$I-} reset(UserFile) {$I+};
  386.  
  387.                    if IOresult<>0 then rewrite(UserFile);
  388.  
  389.                    while (usernum=0) and not eof(Userfile) do begin
  390.  
  391.                     index:=index+1;
  392.  
  393.                     Read(UserFile,User(newuser));
  394.  
  395.                     Writeln(newuser.UserName);
  396.  
  397.                     Writeln(newuser.Password);
  398.  
  399.                     Writeln(newuser.Location);
  400.  
  401.                     Writeln(newuser.PhoneNum);
  402.  
  403.                    End;
  404.  
  405.                    str(filesize(userfile):1,inch);
  406.  
  407.                    writeln('there are ',inch,' users.');
  408.  
  409.                    close(userfile);
  410.  
  411.                  End;
  412.  
  413. {I took the rest out since it wasn't neccesary}
  414.  
  415.  
  416.  
  417.         When the program's booted up, it runs StartUp. NewuserP is the
  418.  
  419.  new user application program. The InfoCenter procedure contains the 'user
  420.  
  421.  list' that I have trouble with. All that's shown in this user list
  422.  
  423.  is complete garbage. Can anyone help me? If you want to see the full source
  424.  
  425.  code(if it helps), just ask.....
  426.  
  427.  
  428.  
  429.  
  430.