On Thu, 31 Jan 2002 21:02:28 -0600, Craig L Solomon <[log in to unmask]>
wrote:
>Speedware Question…
>
>As most of you know I am not a programmer, nor do I play one on TV, so
>if this question seems simple, I apologize.
>
>A friend of mine is working on a project using an older version of
>Speedware 5.x (reactor) and needs to pull name information out of a
>database on the e3000.
>
>The name is stored in a single field as follows
>
>Public/John Q
>
>However the customer wants it to be reported back to them as: John Q.
>Public, but here is the twist, they want fixed fields
>
>1 2 3 4 5 6 7 8 9 10 |11 12 13 14 15 16 17 18 19 20 21 22 |23
>
>Locations 1-10 = 1st Name
>Locations 11-22 = Last Name
>Location 23 = Middle Initial.
>
>Any help would be appreciated!
>
>Please email me at [log in to unmask] or post back to the forum!
>
>Cordially,
>
>Craig S.
Craig,
I've always found REACTOR a clumsy language for string processing, but
here's a routine I wrote to parse a Summit Spectrum name field (30 chars
formatted LAST/FIRST MI) into individual FirstName, MidInit, LastName
fields. I've modified it slightly to fit your field sizes.
#I, #J, and #N are TYPE(I,9)
#NAME, #XNAM, and #STR are TYPE(X,30)
HTH,
Tom
COMPUTE-PARSE-NAME: ;
(* *************************************************************** *)
(* This subroutine parses the Spectrum format name contained *)
(* in #NAME into separate first name, middle initial and last *)
(* name fields in #FNAM, #MI and #LNAM. It uses the temporary *)
(* variables #XNAM, #I, #J, #N, and #STR. *)
(* *************************************************************** *)
BEGIN
CALCUL #NAME = #XNAM, " " = #FNAM = #MI = #LNAM;
(* Extract the last name - *)
(* Take everything left of the '/' (up to 11 characters max) *)
CALCUL 1 = #I;
WHILE #I <= 11 AND #XNAM[1-1] <> "/" DO
BEGIN
CALCUL #LNAM[2-11] + #XNAM[1-1] = #LNAM;
CALCUL #XNAM[2-30] + " " = #XNAM;
CALCUL #I + 1 = #I;
END;
IF #LNAM[1-1] = " " THEN CALCUL
#LNAM CLE = #LNAM,
#LNAM[2-11] + " " = #LNAM;
(* Find the first '/' (if any) and skip past it *)
WHILE #I <= 30 AND #XNAM[1-1] <> "/" DO
BEGIN
CALCUL #XNAM[2-30] + " " = #XNAM;
CALCUL #I + 1 = #I;
END;
CALCUL #XNAM[2-30] + " " = #XNAM;
(* Find the last non-blank character and set #N to the number *)
(* of characters available for the first name and middle init *)
CALCUL 30 - #I = #N;
IF #N > 0 THEN
BEGIN
CALCUL #XNAM = #STR;
CALCUL 1 = #I, 0 = #J;
WHILE #I <= #N DO
BEGIN
IF #STR[1-1] <> " " THEN CALCUL #I = #J;
CALCUL #STR[2-30] + " " = #STR;
CALCUL #I + 1 = #I;
END;
CALCUL #J = #N;
(* If the string ends with a blank and a single character, *)
(* save it as the middle initial. *)
CALCUL (#XNAM RJU = #STR);
IF #N > 2 AND #STR[29-29] = " "
AND #STR[30-30] <> "/" THEN
BEGIN
CALCUL #STR[30-30] = #MI;
CALCUL #N - 2 = #N;
END;
(* Take whatever is left (up to 10 characters) as the first *)
(* name. *)
IF #N > 10 THEN CALCUL 10 = #N;
CALCUL 1 = #I;
WHILE #I <= #N DO
BEGIN
CALCUL #FNAM[2-10] + #XNAM[1-1] = #FNAM;
CALCUL #XNAM[2-30] + " " = #XNAM;
CALCUL #I + 1 = #I;
END;
WHILE #I <= 10 DO
BEGIN
CALCUL #FNAM[2-10] + " " = #FNAM;
CALCUL #I + 1 = #I;
END;
END;
END;
EXIT;
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|