home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / rexx / personinfo.rexx < prev    next >
OS/2 REXX Batch file  |  1993-10-25  |  9KB  |  322 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                            PersonInfo.rexx                               */
  4. /*                                                                          */
  5. /* Written by: Peter Billing, RMB 1240, Yinnar 3869, Australia              */
  6. /*                                                                          */
  7. /* Last saved: Wednesday 29-Sep-93                                          */
  8. /*                                                                          */
  9. /* This program should print out information about a person in the SCION    */
  10. /* database. The database must be running for this AREXX script to work.    */
  11. /*                                                                          */
  12. /****************************************************************************/
  13.  
  14. /* Return the Database Name */
  15.  
  16. options results
  17. /*test = show('P','SCIONGEN')
  18. if test = 0  then
  19. say
  20. say "I am sorry to say that the SCION Genealogist database is not available."
  21. say "Please start the SCION program BEFORE using this script."
  22. say
  23. exit */
  24.  
  25. myport = "SCIONGEN"
  26. address value myport
  27. getdbname
  28. dbname = upper(result)
  29. output = "STDOUT"
  30. writeln(output, " ")
  31. writeln(output,center("This script will give you a",80))
  32. heading = "Listing of a Person in the" dbname "database on" date()
  33. writeln(output,center(heading,80))
  34. writech(output,"Type in the IRN of the Person you require or ALL for all. " )
  35. pull irn
  36. gettotalirn
  37. total = result
  38. if irn = "ALL" then do
  39.   writech(stdout,"Do you want a sorted list Y/N ")
  40.   pull sorted
  41.   if sorted = "" then sorted = "N"
  42.   start = 1
  43.   finish = total
  44.   end
  45. if irn ~= "ALL" then do
  46.   start = irn
  47.   finish = irn
  48.   end
  49. if irn ~= "ALL" & irn > total then do
  50.   say "I am sorry to say that there are only" total "people available. "
  51.   exit
  52. end
  53. writech(output, "Output to Screen or File S/F ")
  54. pull out
  55. if out = "" then out = "S"
  56.  
  57. if sorted = "Y" then do
  58.   file_name = "ram:sort"
  59.   open(sort_File,file_Name,"w")
  60.   do a = 1 to total
  61.     getlastname a
  62.     person = upper(result)
  63.     getfirstname a
  64.     person = person result a
  65.     writeln(sort_File,person)
  66.   end
  67.   close(sort_file)
  68.   address command "c:sort ram:sort ram:sort2"
  69.   file_name = "ram:sort2"
  70.   open(sort_File,file_Name,"r")
  71. end
  72.  
  73. output = "STDOUT"
  74. code1 = "" /* Bold */
  75. code2 = "" /* Normal */
  76.  
  77. if out = "F" then do
  78.    code1 = ""  /* Bold on */
  79.    code2 = "" /* Bold off */
  80.    filename = "RAM:PersonInfo_"dbname"_"irn".Scion"
  81.    open(w_file,filename,"w")
  82.    output = w_file
  83.    writeln(stdout,"")
  84.    writeln(stdout,"Writing file to" filename)
  85.    end
  86.  
  87. heading = "Personal information in the" dbname "database on" date()
  88.  
  89. do  j = start to finish
  90. if sorted = "Y" then do
  91.   person = readln(sort_file)
  92.   p = word(person,words(person))
  93. end
  94. else do
  95.   p = j
  96. end
  97. if out = "F" then do
  98.   if (j+2)/3 = (j+2)%3 then do
  99.     writech(stdout,".")
  100.     if j ~= 1 then do
  101.       writeln(output,"--------------------------------------------------------------------------------")
  102.       writech(output," ")
  103.     end
  104.     writeln(output,center(heading,80))
  105.   end
  106. end
  107. getlastname p
  108. name = code1 left(result,15)code2
  109. getfirstname p
  110. name = name left(result,25)
  111. principal = name
  112. sp = 3
  113. getsex p
  114. sex = result
  115. getage(p)
  116. writeln(output,"================================================================================")
  117. writeln(output,principal "  ["p"]  Sex:" sex " Age:" age  Life)
  118. writeln(output,"--------------------------------------------------------------------------------")
  119. getbirthdate p
  120. birthdate = result
  121. getbirthplace p
  122. birthplace = result
  123. writeln(output,right(" ",sp)left("Born:",12) right(birthdate,14) right("Place:",8) birthplace)
  124. writeln(output,right(" ",sp)left("Christened:",12) right(" ",14) right("Place:",8))
  125. getdeathdate p
  126. deathdate = result
  127. getdeathplace p
  128. deathplace = result
  129. writeln(output,right(" ",sp)left("Died:",12) right(deathdate,14) right("Place:",8) deathplace)
  130. getburialdate p
  131. burialdate = result
  132. getburialplace p
  133. burialplace = result
  134. writeln(output,right(" ",sp)left("Buried:",12) right(burialdate,14) right("Place:",8) burialplace)
  135. getpersuser1 p
  136. user1 = result
  137. writeln(output,right(" ",sp)left("Occupation:",12) user1)
  138. getpersuser2 p
  139. user2 = result
  140. writeln(output,right(" ",sp)left("Comments:",12) user2)
  141. getpersuser3 p
  142. user3 = result
  143. writeln(output,right(" ",sp)left("References:",12) user3)
  144. getparents p
  145. parents = result
  146. getprincipal parents
  147. p1 = result
  148. MakeName(p1)
  149. principalParent = name
  150. getspouse parents
  151. s1 = result
  152. MakeName(s1)
  153. spouseParent = name
  154. getsex s1
  155. if result = "M" then do
  156.   temp = spouseParent
  157.   spouseParent = principalParent
  158.   principalParent = temp
  159.   t1 = s1
  160.   s1 = p1
  161.   p1 = t1
  162. end
  163. writeln(output,right(" ",sp)left("Parents:",12) PrincipalParent "["p1"]")
  164. writeln(output,right(" ",sp)right(" ",12) SpouseParent "["s1"]")
  165.  
  166. getmarriage p 0
  167. fgrn = result
  168. getspouse fgrn
  169. s = result
  170. getsex s
  171. if sex = result then do
  172.   getprincipal fgrn
  173.   s = result
  174. end
  175. MakeName(s)
  176. spouse = name
  177. writeln(output,"--------------------------------------------------------------------------------")
  178. writech(output,right(" ",sp)left("Spouse:",12) spouse)
  179. if fgrn ~= "" then do
  180.   writeln(output, "["s"]")
  181.   end
  182. else do
  183.   writeln(output,"")
  184. end
  185. getmarrydate fgrn
  186. marrydate = result
  187. getmarryplace fgrn
  188. marryplace = result
  189. writeln(output,right(" ",sp)left("Married:",12) right(marrydate,14) right("Place:",8) marryplace)
  190.  
  191. getfamuser1 fgrn
  192. user1 = result
  193. writeln(output,right(" ",sp)left("Celebrant:",12) user1)
  194. getfamuser2 fgrn
  195. user2 = result
  196. writeln(output,right(" ",sp)left("Comments:",12) user2)
  197. /* writeln(output,"--------------------------------------------------------------------------------") */
  198. writech(output,right(" ",sp)"Other Marriages: ")
  199. fix = 0
  200. do m = 0 to 9
  201.   getmarriage p m
  202.   if result ~= "" & result ~= fgrn then do /* only display marriages apart */
  203.                                              /* from the present */
  204.     writech(output," ["result"]")
  205.     fix = 1
  206.   end
  207. end
  208. if fix = 1 then writeln(output,"")
  209. else
  210. writeln(output," None recorded.")
  211. writech(output,right(" ",sp)"Children:")
  212. fix = 0
  213. if fgrn ~= "" then do
  214. do c = 0 to 39
  215.   getchild fgrn c
  216.   if result ~= "" then do
  217.     writech(output," ["result"]")
  218.     fix = 1
  219.   end
  220. end
  221. end
  222. if fix = 1 then writeln(output,"")
  223. else
  224. writeln(output,"  None recorded.")
  225.  
  226. end
  227. if out = "F" then do
  228.   writeln(output," ")
  229.   close(w_file)
  230.   writeln(stdout,"")
  231.   writeln(stdout,"All Finished")
  232.   end
  233. exit
  234.  
  235. MakeName:
  236. parse arg irn
  237. getfirstname irn
  238. name = left(result,25)code1
  239. getlastname irn
  240. name = name left(result,15)code2
  241. return name
  242.  
  243. GetAge:
  244. parse arg irn
  245. age = ""
  246. life = ""
  247. day1   = substr(date(),1,2)
  248. Month1 = substr(date(),4,3)
  249. Year1  = substr(date(),8,4)
  250. CheckMonth(upper(Month1))  /* turn the month into a number */
  251. m1 = x
  252.  
  253. birth = ""
  254. getbirthdate irn
  255. birth = result
  256. if birth ~= "" then do
  257. if length(birth) > 3 then do                  /* check if there is a date */
  258.   day2   = word(birth,1)                      /* if there is then continue */
  259.   Month2 = substr(word(birth,2),1,3)
  260.   Year2  = substr(birth,length(birth)-3,4)
  261.   CheckMonth(upper(Month2))
  262.   m2 = x
  263. end
  264. else do                                      /* no date */
  265.   break                                      /* no need going any futher */
  266. end
  267.  
  268. death = ""
  269. getdeathdate irn
  270. death = result
  271. if length(death) > 3 then do               /* is if the person has a death date */
  272.   day3   = word(death,1)                   /* if there is a date then work out */
  273.   Month3 = word(death,2)                   /* age at death */
  274.   Year3  = substr(death,length(death)-3,4)
  275.   CheckMonth(upper(Month3))
  276.   m3 = x
  277.   age = year3 - year2
  278.   if m3 < m2 then age = age -1
  279.   if m3 = m2 then do
  280.     if day3 < day2 then age = age -1
  281.    end
  282.    Life = "D"
  283. end
  284.  
  285. /* Person is still alive */
  286.  
  287. if length(death) < 3 & length(birth) > 3 then do /* check there is a bith date */
  288. age = year1 - year2                              /* work out the age using the year */
  289. Life = "L"
  290. if m1 < m2 then                                  /* if birth month is less than today */
  291.          age = age -1                            /* then person is a year younger */
  292.     if m1 = m2 then do                           /* if the months are the same then */
  293.                                                  /*  check the days */
  294.    if day1 < day2 then do                        /* if birth day is less than today */
  295.      age = age -1                                /* then person is a year younger */
  296.      end
  297.      end
  298.      end
  299.      if age > 105 then do
  300.        age = ""
  301.        Life = ""
  302.      end
  303. end
  304. return age
  305.  
  306. CheckMonth:
  307. parse arg m
  308. if m = "JAN" then x = 1
  309. if m = "FEB" then x = 2
  310. if m = "MAR" then x = 3
  311. if m = "APR" then x = 4
  312. if m = "MAY" then x = 5
  313. if m = "JUN" then x = 6
  314. if m = "JUL" then x = 7
  315. if m = "AUG" then x = 8
  316. if m = "SEP" then x = 9
  317. if m = "OCT" then x = 10
  318. if m = "NOV" then x = 11
  319. if m = "DEC" then x = 12
  320. return x
  321.  
  322.