! ----- GET_FIRST_LAST.FUN ----- ! ! ----- SUBROUTINE TO GET FIRST AND LAST NAMES ----- ! ! ---------- PASSED: ---------- ! ! ----- ACTION_INDEX = USER_ACTIONS() program action array index ! ----- BACKWARDS = TRUE if we're moving backwards thru prompts ! ----- DEBUG_MODE = TRUE if Debug Mode is enabled ! ----- PLEASE_TRY_AGAIN = "Please Try Again" error message ! ! ---------- RETURNED: ---------- ! ! ----- BACKWARDS = TRUE if we're moving backwards thru prompts ! ----- ENTERED_FIRST = User-entered first name ! ----- ENTERED_LAST = User-entered last name ! ----- ACTION_SEQ = Next User Input Sequence routine to process ! ----- (-1 if done with all user inputs) ! ! ----- Last Change 04/08/94 by Brian Lomasky ----- ! SUB GET_FIRST_LAST(STRING ENTERED_FIRST, STRING ENTERED_LAST) %INCLUDE "NUSER.INC" ! ----- MAX NUMBER OF USERNAMES ----- ! ----- (MUST MATCH VALUE IN SEARCH_SYSUAF) ----- DECLARE WORD CONSTANT MAX_USERNAMES = 40% DECLARE WORD I_O_CHNL_SYSUAF ! SYSUAF I/O CHANNEL TO ACCESS DECLARE WORD RECORD_FOUND ! TRUE IF MATCHING RECORD FOUND DECLARE WORD SYSUAF_CHNL ! SYSUAF.DAT I/O CHANNEL TO USE DECLARE WORD SYSUAF_RECORD_FOUND! TRUE IF SYSUAF RECORD FOUND DECLARE WORD TEMP ! TEMPORARY WORD VARIABLE DECLARE STRING TEMP_STRING ! TEMPORARY STRING DECLARE LONG TEMP_USER ! TEMPORARY USERNAME COUNTER DECLARE STRING TEMP_USER_NAME ! TEMPORARY USERNAME DECLARE WORD VALID_ENTRY ! TRUE IF VALID ENTRY ! ----- LIST OF POSSIBLE USERNAMES ----- ! ----- (MUST MATCH DEFINITION IN SEARCH_SYSUAF) ----- MAP (SEASUAF) STRING THE_USERS(MAX_USERNAMES) = 12% EXTERNAL STRING FUNCTION CAPITALIZE_FIRST( & STRING) ! CAPITALIZE STRING EXTERNAL WORD FUNCTION LOOKUP_DISPLAY_USER_INFO( & WORD, WORD) ! LOOKUP AND DISPLAY USER INFO ! ----- LOCAL FUNCTION TO PROMPT FOR WHETHER THE USER ----- ! ----- WANTS TO TRY A DIFFERENT USERNAME (RETURNS TRUE IF ----- ! ----- "YES" OR "B") ----- DEF WORD GET_DIFF_USERNAME ! ----- ASSUME "YES"/"B"/CONTROL-Z ----- GET_DIFF_USERNAME = TRUE WHILE TRUE TEMP = TRUE WHEN ERROR IN PRINT PRINT " Do you want to" + & " try a username other" & + " than " + & TRM$(ENTERED_USERNAME) & + " "; LINPUT #98%, "? "; TEMP_STRING USE TEMP = FALSE CONTINUE END WHEN ! ----- EXIT IF CONTROL/Z ----- EXIT DEF IF NOT TEMP ! ----- DISCARD ANY GARBAGE CHARS ----- TEMP_STRING = EDIT$(TEMP_STRING, 38%) TEMP_STRING = "N" IF TEMP_STRING = "" EXIT DEF IF TEMP_STRING = "Y" EXIT DEF IF TEMP_STRING = "B" IF TEMP_STRING = "N" THEN ! ----- RETURN "N" RESPONSE ----- GET_DIFF_USERNAME = FALSE EXIT DEF END IF PRINT PRINT "Error - You must enter the" + & " letter Y or N" + & TRM$(PLEASE_TRY_AGAIN) PRINT NEXT END DEF ! ----- LOCAL FUNCTION TO SEE IF A DIFFERENT USERNAME ----- ! ----- SHOULD BE PROMPTED FOR ----- ! ! ----- SEARCHES FOR USER NAME MATCHING USER_NAME. ----- ! ----- DISPLAYS WARNING AND PROMPTS FOR WHETHER USER ----- ! ----- WANTS TO ENTER A DIFFERENT USERNAME, IF AN ACCOUNT ----- ! ----- WITH A MATCHING USERNAME ALREADY EXISTS ON ANY ----- ! ----- NODE. RETURNS TRUE IF USER WANTS TO ENTER A ----- ! ----- DIFFERENT USERNAME, ELSE RETURNS FALSE ----- ! DEF WORD TRY_ANOTHER_USERNAME ! ----- ASSUME NO OTHER USERNAME IS TO BE TRIED ----- TRY_ANOTHER_USERNAME = FALSE ! ----- ASSUME USER IN ALLOWED DIVISION ----- INVALID_DIVISION = FALSE I_O_CHNL_SYSUAF = 0% ! ----- FOR EACH OPEN SYSUAF FILE: ----- WHILE I_O_CHNL_SYSUAF < SYSUAF_COUNTER I_O_CHNL_SYSUAF = I_O_CHNL_SYSUAF + 1% ! ----- SKIP IF SYSUAF UNAVAILABLE ----- ITERATE IF TRM$(SYSUAF_SPECS( & I_O_CHNL_SYSUAF)) = "" IF DEBUG_MODE THEN PRINT "DEBUG> Process" + & " SYSUAF #" + & NUM1$(I_O_CHNL_SYSUAF) END IF ! ----- CALCULATE THE REAL I/O CHANNEL ----- SYSUAF_CHNL = I_O_CHNL_SYSUAF + 49% SYSUAF_RECORD_FOUND = TRUE WHEN ERROR IN GET #SYSUAF_CHNL, KEY #0% EQ & USER_NAME, REGARDLESS USE IF ERR = BUCKET_LOCKED THEN SLEEP 1% RETRY END IF IF ERR = REC_NOT_FOUND THEN SYSUAF_RECORD_FOUND = FALSE CONTINUE END IF EXIT HANDLER END WHEN ITERATE IF NOT SYSUAF_RECORD_FOUND UNLOCK #SYSUAF_CHNL ! ----- SEE IF USER NAME ALREADY FOUND ----- TEMP_USER = 0% WHILE TEMP_USER < THE_USERS_COUNTER TEMP_USER = TEMP_USER + 1% EXIT DEF IF & THE_USERS(TEMP_USER) = USER_NAME NEXT ! ----- INCREMENT COUNT OF POSSIBLE ----- ! ----- USERNAMES ----- THE_USERS_COUNTER = THE_USERS_COUNTER + 1% ! ----- STORE NEW USERNAME IN MEMORY ----- THE_USERS(THE_USERS_COUNTER) = USER_NAME PRINT ! ----- IF SEARCHING THE LOCAL NODE'S ----- ! ----- SYSUAF: ----- IF I_O_CHNL_SYSUAF = 1% THEN PRINT "Note: An account" + & " having the username" +& " of " + TRM$(USER_NAME)& + " already exists." ELSE PRINT "Note: An account" + & " having the username" +& " of " + TRM$(USER_NAME)& + " already exists on" +& " node " + & TRM$(SYSUAF_NODES( & I_O_CHNL_SYSUAF)) END IF ! ----- LOOKUP AND DISPLAY USER INFO ----- TEMP = LOOKUP_DISPLAY_USER_INFO( & I_O_CHNL_SYSUAF, TEMP) ! ----- LOOKUP_DISPLAY_USER_INFO ----- ! ----- returns the following data: ---- ! ----- INVALID_DIVISION = TRUE if a ----- ! ----- non-privileged person ----- ! ----- running NUSER is not ----- ! ----- authorized to modify the ----- ! ----- user that is being ----- ! ----- displayed (based upon ----- ! ----- the process's held ----- ! ----- identifiers) ----- IF GET_DIFF_USERNAME THEN ! ----- SET TO GET ANOTHER ----- ! ----- USERNAME ----- TRY_ANOTHER_USERNAME = TRUE END IF PRINT ! ----- ALL DONE WITH SEARCHING FOR THIS ----- ! ----- USERNAME ----- EXIT DEF NEXT END DEF GET_FIRST_LAST_NAME: ! ----- SEE IF CHANGING AN EXISTING OWNER NAME ----- IF USER_ACTIONS(ACTION_INDEX) = "O" THEN PRINT PRINT END IF BACKWARDS = FALSE ! NOT MOVING BACK THRU PROMPTS VALID_ENTRY = FALSE WHILE NOT VALID_ENTRY RECORD_FOUND = TRUE WHEN ERROR IN LINPUT #98%, & "Enter the user's first name: "; & ENTERED_FIRST USE RECORD_FOUND = FALSE CONTINUE END WHEN IF NOT RECORD_FOUND THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- DISCARD ANY GARBAGE CHARS AND UPPERCASE ----- ENTERED_FIRST = EDIT$(ENTERED_FIRST, 172%) IF ENTERED_FIRST = "B" THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF IF LEN(ENTERED_FIRST) = 0% THEN PRINT PRINT "Error - You must enter a" + & " first name" + TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF ! ----- ENSURE NO EMBEDDED COMMA ----- IF POS(ENTERED_FIRST, ",", 1%) <> 0% THEN PRINT PRINT "Error - Commas are not allowed" & + " in the name" + & TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF ! ----- ENSURE NO EMBEDDED QUOTE ----- IF POS(ENTERED_FIRST, '"', 1%) <> 0% THEN PRINT PRINT "Error - Quotes are not" + & " allowed in the name" + & TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF WHEN ERROR IN LINPUT #98%, & "Enter the user's last name: "; & ENTERED_LAST USE RECORD_FOUND = FALSE CONTINUE END WHEN IF DEBUG_MODE THEN PRINT "DEBUG>Enter_First_Last:" + & " RECORD_FOUND=" + NUM1$(RECORD_FOUND) END IF GOTO GET_FIRST_LAST_NAME IF NOT RECORD_FOUND IF DEBUG_MODE THEN PRINT "DEBUG>Entered Last Name=" + ENTERED_LAST END IF ! ----- DISCARD ANY GARBAGE CHARS AND UPPERCASE ----- ENTERED_LAST = EDIT$(ENTERED_LAST, 172%) GOTO GET_FIRST_LAST_NAME IF ENTERED_LAST = "B" IF LEN(ENTERED_LAST) = 0% THEN PRINT PRINT "Error - You must enter a" + & " last name" + & TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF IF LEN(ENTERED_FIRST) + LEN(ENTERED_LAST) + 2% > 31% THEN PRINT PRINT 'Error - "Last, First" name is' + & ' too long' + TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF ! ----- ENSURE NO EMBEDDED COMMA ----- IF POS(ENTERED_LAST, ",", 1%) <> 0% THEN PRINT PRINT "Error - Commas are not" + & " allowed in the name" + & TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF ! ----- ENSURE NO EMBEDDED QUOTE ----- IF POS(ENTERED_LAST, '"', 1%) <> 0% THEN PRINT PRINT "Error - Quotes are not" + & " allowed in the name" + & TRM$(PLEASE_TRY_AGAIN) PRINT ITERATE END IF ! ----- SEE IF CHANGING AN EXISTING OWNER NAME ----- IF USER_ACTIONS(ACTION_INDEX) = "O" THEN ! ----- CAPITALIZE ONLY THE FIRST ----- ! ----- CHARACTERS ----- ENTERED_FIRST = CAPITALIZE_FIRST(ENTERED_FIRST) ENTERED_LAST = CAPITALIZE_FIRST(ENTERED_LAST) VALID_ENTRY = TRUE ITERATE END IF ! ----- TRY DIFFERENT VARIATIONS OF THE FIRST ----- ! ----- AND/OR LAST NAME AND/OR USERNAME TO SEE ----- ! ----- IF THERE MIGHT BE AN EXISTING ACCOUNT ----- ! ----- SEE IF THE MODIFIED USERNAME ALREADY ----- ! ----- EXISTS ----- TEMP_USER_NAME = TRM$(ENTERED_USERNAME) USER_NAME = RIGHT(TEMP_USER_NAME, 2%) + & LEFT(TEMP_USER_NAME, 1%) ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE MODIFIED USERNAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = & RIGHT(TEMP_USER_NAME, & LEN(TEMP_USER_NAME)) + & LEFT(TEMP_USER_NAME, LEN(TEMP_USER_NAME) - 1%) ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE LAST NAME ALREADY EXISTS ----- USER_NAME = ENTERED_LAST ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE FIRST NAME ALREADY EXISTS ----- USER_NAME = ENTERED_FIRST ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE LAST,FIRST NAME ALREADY EXISTS ----- USER_NAME = ENTERED_LAST + LEFT(ENTERED_FIRST, 1%) ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE FIRST,LAST NAME ALREADY EXISTS ----- USER_NAME = ENTERED_FIRST + LEFT(ENTERED_LAST, 1%) ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE FIRST,LAST NAME ALREADY EXISTS ----- USER_NAME = LEFT(ENTERED_FIRST, 1%) + ENTERED_LAST ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE LAST,FIRST NAME ALREADY EXISTS ----- USER_NAME = LEFT(ENTERED_LAST, 1%) + ENTERED_FIRST ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE USERNAME, LAST NAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = TEMP_USER_NAME + ENTERED_LAST ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE LAST NAME, USERNAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = ENTERED_LAST + TEMP_USER_NAME ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE USERNAME, FIRST NAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = TEMP_USER_NAME + ENTERED_FIRST ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE FIRST NAME, USERNAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = ENTERED_FIRST + TEMP_USER_NAME ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE USERNAME, LAST NAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = TEMP_USER_NAME + LEFT(ENTERED_LAST, 1%) ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE LAST NAME, USERNAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = LEFT(ENTERED_LAST, 1%) + TEMP_USER_NAME ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE USERNAME, FIRST NAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = TEMP_USER_NAME + LEFT(ENTERED_FIRST, 1%) ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- SEE IF THE FIRST NAME, USERNAME ALREADY ----- ! ----- EXISTS ----- USER_NAME = LEFT(ENTERED_FIRST, 1%) + TEMP_USER_NAME ! ----- SEE IF THE USERNAME EXISTS ON ANY NODE ----- IF TRY_ANOTHER_USERNAME THEN BACKWARDS = TRUE! MOVING BACK THRU PROMPTS ACTION_SEQ = ACTION_SEQ - 1% EXIT SUB END IF ! ----- CAPITALIZE ONLY THE FIRST CHARACTERS ----- ENTERED_FIRST = CAPITALIZE_FIRST(ENTERED_FIRST) ENTERED_LAST = CAPITALIZE_FIRST(ENTERED_LAST) VALID_ENTRY = TRUE NEXT ACTION_SEQ = ACTION_SEQ + 1% END SUB