home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / miscdb2.zip / NAMEBRK.CMD < prev    next >
OS/2 REXX Batch file  |  1987-02-14  |  3KB  |  95 lines

  1. * NAMEBRK.CMD
  2. * (the small letter commands are for demo. running only)
  3. set talk off
  4. erase
  5. @ 12,0
  6. accept 'Name is?  ' to NAME
  7. ?
  8. ?
  9.  
  10. * NAME BREAK. CMD    11-3-82    J Shea    SIBAL Engineering
  11. * A routine that allows entering a name in full, normal order but
  12. * seperates the name on the blank into FNAME & LNAME. if there is
  13. * no space the entered name is considered the last name (LNAME),
  14. * if a middle initial is used it becomes part of FNAME.
  15.  
  16. * Assumption:  Name enters this routine as a variable called NAME
  17.  
  18. * first trim off the trailing blanks since most name gathering is
  19. * done in a fixed length read, or get mode.
  20. STORE TRIM(NAME) TO NAMET
  21.  
  22. * now we get the length, this is for possible later use, not needed
  23. * in this program. used if you wanted to eliminate spaces in a form
  24. * letter.
  25. STORE LEN(NAMET) TO LENGTH
  26.  
  27. * let's find the break in the words
  28. STORE @(' ',NAMET) TO DEPTH
  29.  
  30. * we have to check if there wasn't any. if not we assume that the name
  31. * is a last name. this is done so a FIND command can locate a name
  32. * indexed on the last name.
  33. IF DEPTH = 0
  34. * no spaces therefore a single word name entered, make it the last name
  35.    STORE NAMET TO LNAME
  36. * to take care of no first name (minimizes errors!)
  37.    STORE ' ' TO FNAME
  38.  
  39. ELSE
  40. * we have a break and that's all we need to seperate them
  41. STORE $(NAMET,1,DEPTH) TO FNAME
  42.  
  43. * easy huh? now we have to check the last name for a space that
  44. * will indicate that a middle initial or name was used.
  45. * first we isolate the remaiming letters and consider it the lastname
  46. STORE $(NAMET,DEPTH + 1) TO LNAME
  47.  
  48. * now we look for more spaces just like we did for the variable NAMET
  49. STORE @(' ',LNAME) TO DEPTH2
  50.  
  51. * any spaces?
  52.     IF DEPTH2  > 0
  53. * there is another space so we break it up into LNAME & MNAME
  54.        STORE $(LNAME,1,DEPTH2) TO MNAME
  55. * here comes the last name
  56.        STORE $(LNAME,DEPTH2 + 1) TO LNAME
  57. * next comes the attaching of first name and middle initial or name
  58.            STORE FNAME+MNAME TO FNAME
  59. * all done (If some clown insists they have four names you can repeat
  60. * this 'IF' for each name you want to cover!)
  61. * get rid of MNAME before leaving
  62.        RELEASE MNAME
  63.     ENDIF two spaces, middle initial
  64.  
  65. ENDIF no space single word
  66.  
  67. * (for demo purposes only)
  68. disp memo
  69.  
  70. * the jobs' not done until the cleanup is
  71. RELEASE NAME, NAMET, DEPTH, DEPTH2
  72.  
  73. * and if you don't need length add it to the above line
  74. RELEASE LENGTH
  75.  
  76. * you exit with FNAME & LNAME ,bye bye!
  77.  
  78. * (demo again)
  79. ?
  80. ?
  81. ? 'Name: last name first  ',LNAME,',',FNAME
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.