home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / NWTP04 / XBINDRY / SWAPNAME.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-29  |  3KB  |  79 lines

  1. {$X+,B-,V-}
  2. program swapnames;
  3.  
  4. { Example for the nwBindry unit / NwTP 0.4 API. (c) 1994, R.Spronk }
  5.  
  6. { AREA:NOVELL
  7. (1394)  Thu 30 Sep 93 16:07
  8. By: JAMES SIMONSON
  9. To: All
  10. Re: Novell 3.11/4.01 bindery access
  11. ------------------------------------------------------------
  12.  
  13. Is there a way to access the full name information inthe bindery files?
  14. Here's the scoop:
  15.  
  16. We've got "firstname mi lastname" in the FULLNAME space in the user record.
  17. We need to convert that to "lastname, firstname mi" & place that
  18. information BACK into the FULLNAME field. Is there any relatively fast way
  19. to do this conversion?
  20.  
  21. --- SLMAIL v3.0  (#0623)
  22.  * Origin: WorkStations Unlimited / 312-404-2824 (1:115/404) }
  23.  
  24. { This program will reverse all first& last names in the bindery.
  25.   Lastname is defined as being everything after the last space in the full name.
  26.   This may not be true for all names.
  27.   If there is no space in the full name, nothing changes. }
  28.  
  29. uses nwBindry;
  30.  
  31. Var lastObjSeen:LongInt;
  32.     objName    :string;
  33.     objType    :word;
  34.     objId      :LongInt;
  35.     objFlag,objSec:Byte;
  36.     hasProp    :boolean;
  37.  
  38.     propVal  :propertyType;
  39.     moreseg  :boolean;
  40.     propFlags:Byte;
  41.  
  42.     NewName,FullName:string;
  43.     t:byte;
  44. begin
  45. LastObjSeen:=-1;
  46. WHILE ScanBinderyObject('*',1,LastObjSeen,
  47.                   objName,objType,objId,objFlag,objSec,hasProp)
  48.  do begin
  49.     IF ReadPropertyValue(objName,objType,'IDENTIFICATION',1,
  50.                          propVal,moreSeg,propFlags)
  51.     then begin
  52.          t:=1;
  53.          while (propVal[t]<>0)
  54.           do begin FullName[t]:=chr(propVal[t]);inc(t) end;
  55.          FullName[0]:=chr(t-1);
  56.          IF pos(',',FullName)=0
  57.           then begin
  58.                writeln(FullName);
  59.                while fullName[ord(fullName[0])]=' '
  60.                 do dec(FullName[0]);
  61.                t:=ord(FullName[0]);
  62.                while (t>0) and (FullName[t]<>' ') do dec(t);
  63.                if t>0
  64.                 then begin
  65.                      NewName:=copy(FullName,t+1,255)+', '
  66.                                    +copy(FullName,1,t-1);
  67.                      writeln(newname);
  68.                      fillChar(propVal,SizeOf(propVal),#0);
  69.                      for t:=1 to ord(newName[0])
  70.                       do propVal[t]:=ord(newName[t]);
  71.                      WritePropertyValue(objName,objType,
  72.                          'IDENTIFICATION',1,propVal,FALSE);
  73.                      end;
  74.                end;
  75.          end;
  76.     end;
  77.  if nwBindry.result<>$FC then writeln('error scanning bindery');
  78. end.
  79.