home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- * *
- * $VER: Translate 1.30 (23 May 1995)
- * *
- * Written by Freddy Ariës *
- * *
- * You may have noticed that setting another language in Locale means that *
- * the date (month) fields of your database are no longer recognized *
- * correctly. This is where Translate comes in. *
- * It will convert all the standard language fields in a Scion database (in *
- * v4.0+, that means the Date fields) into another (predefined) language. *
- * Currently only Dutch, German and French are supported, and only *
- * translation to and from English is possible. Adding other languages *
- * is easy, though. *
- * *
- * This version uses (by default) the rexxreqtools.library (which requires *
- * a version of reqtools larger than 2.0 and rexxsyslib.library) *
- * If you do not have these, you need to supply the NOREQ argument (for *
- * Shell output), or the QUIET argument (for no output at all). *
- * *
- * New (requested by Robbie): progress indicator, using rexxarplib.library *
- * *
- ****************************************************************************/
-
- options results
- arg panum outval
-
- versionstr = "1.30"
- NL = '0A'x
- usereq = 1; /* change this to 0 if you don't want to use reqtools */
- outp = 1;
- prgrs = 1; pgopen = 0; /* use RexxArp progress indicator */
- /* change prgrs to 0 for not using it */
-
- /* parse command line options, to allow calling the script automatically,
- * eg. from a function key
- */
-
- do while panum = '?'
- Tell("NUMOPT/N,QUIET/S,NOREQ/s: ")
- pull panum outval
- end
-
- if panum ~= "" then do
- if panum = "QUIET" then do
- panum = ""; outval = "QUIET"
- lang = 0
- end
- else if panum = "NOREQ" then do
- panum = ""; outval = "NOREQ"
- lang = 0
- end
- else
- lang = CheckAnswer(panum)
- end
- else lang = 0
-
- if outval = "QUIET" then do
- outp = 0; usereq = 0; prgrs 0
- end
- else if outval = "NOREQ" then do
- usereq = 0; prgrs = 0
- end
-
- if usereq & ~show('l','rexxreqtools.library') then do
- if exists('libs:rexxreqtools.library') then
- call addlib('rexxreqtools.library',0,-30,0)
- else do
- usereq = 0; outp = 1
- Tell("Unable to open rexxreqtools.library - using text output")
- end
- end
-
- if ~usereq then prgrs = 0
-
- if prgrs & ~show('l','rexxarplib.library') then do
- if exists('libs:rexxarplib.library') then
- call addlib('rexxarplib.library',0,-30,0)
- else
- prgrs = 0
- end
-
- /* These few lines were stolen from Peter Billings - thanks Peter ;-) */
- if ~show('P','SCIONGEN') then do
- TermError('I am sorry to say that the SCION Genealogist' || NL ||,
- 'database is not available. Please start the' || NL ||,
- 'SCION program BEFORE using this script!')
- end
-
- myport = "SCIONGEN"
- address value myport
- GETDBNAME
- dbname = upper(RESULT)
-
- if outp & ~usereq then do
- Tell("Translate - Scion Language Fields Converter "||versionstr||" by Freddy Ariës")
- Tell("Database: "||dbname|| NL)
- end
-
- if lang = 0 then do
- if ~outp then
- TermError("Missing required argument!")
- /* even though you will never get to see the message... */
- if usereq then do
- answ = rtezrequest('Database: '||dbname || NL ||,
- 'Please select one of the following conversions: ' || NL || NL ||,
- ' 1. Dutch to English 5. French to English' || NL ||,
- ' 2. English to Dutch 6. English to French' || NL ||,
- ' 3. German to English' || NL ||,
- ' 4. English to German 0. Abort' ||,
- NL, ' _1 | _2 | _3 | _4 | _5 | _6 | _0 ', 'Translate - Scion Language Field Converter '|| versionstr || ' by Freddy Ariës','rt_pubscrname = SCIONGEN')
- end
- else if outp then do
- Tell("Please select one of the following conversions: ")
- Tell(" 1. Dutch to English 5. French to English")
- Tell(" 2. English to Dutch 6. English to French")
- Tell(" 3. German to English")
- Tell(" 4. English to German 0. Abort" || NL)
- TellNN("Your choice: ")
- pull answ
- end
- lang = CheckAnswer(answ)
- end
-
- if answ = 0 then EXIT
-
- if prgrs then do
- Postmsg(10, 10, "Scion Translate (by Freddy Ariës)\Database: "||dbname||"\ \ ", "SCIONGEN")
- pgopen = 1
- end
-
- select
- /* Make sure the string in datout is always <= the one in datin, or
- * the resulting string might not fit in the field date anymore.
- * Note: some 2-letter fields ('CA', 'VR', 'AV') can't follow this rule.
- */
- when lang = 1 then do
- datin = "MRT MEI OKT CA CIRCA VR VOOR NA"
- datout= "Mar May Oct Abt About Bef Bef Aft"
- end
- when lang = 2 then do
- datin = "MAR MAY ABT ABOUT BEF BEFORE AFT AFTER"
- datout= "Mrt Mei Ca Circa Vr Voor Na Na"
- end
- when lang = 3 then do
- datin = "MÄR MAI OKT DEZ CA UNGEFÄHR VOR NAC NACH"
- datout= "Mar May Oct Dec Abt About Bef Aft Aft"
- end
- when lang = 4 then do
- datin = "MAR MAY OCT DEC ABT ABOUT BEF BEFORE AFT AFTER"
- datout= "Mär Mai Okt Dez Ca Ca Vor Vor Nac Nach"
- end
- when lang = 5 then do
- datin = "FEV FéV FÉV AVR MAI UIN UIL OUT DEC DéC DÉC ENV ENVIRON AV AVANT APR APRES APRèS APRÈS"
- datout = "Feb Feb Feb Apr May Jun Jul Aug Dec Dec Dec Abt About Bef Bef Aft After After After")
- end
- when lang = 6 then do
- datin = "FEB APR MAY JUN JUL AUG DEC ABT ABOUT BEF BEFORE AFT AFTER"
- datout= "Fév Avr Mai uin uil out Déc Env Env Av Avant Apr Après"
- end
- otherwise
- TermError("Invalid option.")
- end
-
- if ~usereq then
- Tell("Parsing Personal Details...")
- else if pgopen then
- Postmsg(,, "\\Processing person:\", "SCIONGEN")
-
- GETTOTALIRN
- TotalIRN = RESULT
- do i = 1 to TotalIRN
- if pgopen then Postmsg(,,"\\\"||i||" (of "||TotalIRN||")", "SCIONGEN")
- EXISTPERSON i
- /* Skip deleted persons */
- if RESULT = 'YES' then
- do
- /* No longer needed in Scion v4; it always uses the English terms,
- * "M", "F" and "?"
- GETSEX i
- sx = ConvertSex(RESULT)
- if sx ~= "" then PUTSEX i sx
- */
- GETBIRTHDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTBIRTHDATE i datestr
- GETBAPTISMDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTBAPTISMDATE i datestr
- GETDEATHDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTDEATHDATE i datestr
- GETBURIALDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTBURIALDATE i datestr
- end
- end
- if ~usereq then do
- Tell("Done ("||TotalIRN||" persons parsed).")
-
- /* Now the list of families... */
- Tell("Parsing Family Details...")
- end
- else if pgopen then
- Postmsg(,, "\\Processing family:\ ", "SCIONGEN")
-
-
- GETTOTALFGRN
- TotalFGRN = Result
- do i = 1 to TotalFGRN
- EXISTFAMILY i
- if pgopen then Postmsg(,, "\\\"||i||" (of "||TotalFGRN||")", "SCIONGEN")
- /* Skip deleted families */
- if RESULT = 'YES' then do
- GETMARRYDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTMARRYDATE i datestr
- GETENGAGEDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTENGAGEDATE i datestr
- GETENDDATE i
- datestr = ParseDate(RESULT)
- if datestr ~= "" then PUTENDDATE i datestr
- end
- end
-
- if pgopen then do
- Postmsg()
- pgopen = 0
- end
- if usereq then do
- rtezrequest('Scion Translation is ready.' || NL || 'Parsed '||,
- TotalIRN||' persons and '||TotalFGRN||' families.',,'Translate Message:','rt_pubscrname = SCIONGEN')
- end
- else do
- Tell("Done ("||TotalFGRN||" families parsed)."||NL)
- end
- EXIT
-
- CheckAnswer: PROCEDURE EXPOSE outp
- parse arg str
- str = left(str, 1)
- if ~DATATYPE(str, 'w') then
- TermError("Not a valid number -- program terminated.")
- if str < 0 | str > 6 then
- TermError("Not a valid number -- program terminated.")
- return str
-
- ConvertSex: PROCEDURE EXPOSE lang
- parse arg sxstr
- if lang = 1 & sxstr = "V" then sxstr = "F"
- else if lang = 2 & sxstr = "F" then sxstr = "V"
- else if lang = 3 & sxstr = "W" then sxstr = "F"
- else if lang = 4 & sxstr = "F" then sxstr = "W"
- /* French: 'M' and 'F', same as in English */
- else sxstr = ""
- return sxstr
-
- /* PARSEDATE SUBROUTINE */
- /* For each word in the datestr string, see if it occurs in the datin
- * string. If it does, replace it with the equivalent in the datout string
- */
- ParseDate: PROCEDURE EXPOSE datin datout
- parse arg datestr
- datestr = strip(datestr); /* remove leading blanks */
- if datestr = "" then return datestr
- rdate = translate(datestr,' ','-.'); /* replace all '.' or '-' by ' ' */
-
- datestr = upper(rdate)
- /* keep rdate in its original case, so we don't accidentally change
- * the case of any other words in the resulting
- */
- cp = 1
-
- /* check all words with the datin string */
- do cnt = 1 to words(datestr)
- cw = word(datestr, cnt)
- num = find(datin, cw)
- if num > 0 then do
- rep = word(datout, num)
- rl = length(rep)
- cl = length(cw)
- cp = index(upper(rdate), cw, cp)
- rdate = delstr(rdate, cp, cl)
- rdate = insert(rep, rdate, cp-1)
- end
- end
- return rdate
-
- Tell: PROCEDURE EXPOSE outp
- parse arg str
- if outp then
- writeln(stdout, str)
- return 0
-
- TellNN: PROCEDURE EXPOSE outp
- parse arg str
- if outp then
- writech(stdout, str)
- return 0
-
- TermError: PROCEDURE EXPOSE outp usereq pgopen
- parse arg str
- /* If you turned off stdout, no error messages will be shown! */
- if usereq then
- rtezrequest(str,'E_xit','Translate Message:','rt_pubscrname = SCIONGEN')
- else do
- Tell(str || '0A'x)
- end
- if pgopen then Postmsg()
- EXIT
-