360 likes | 507 Views
Free Giveaway at the end !!. FOCUS. Advanced Dialog Manager (Adding Muscle to Your App). Joel Starkman Director of Operations June, 2008. Increased length of animation arrow toward the right imposes a time delay before it restarts from the left again. -REPEAT. -RUN. -TYPE.
E N D
Free Giveaway at the end !! FOCUS Advanced Dialog Manager(Adding Muscle to Your App) Joel Starkman Director of Operations June, 2008 Increased length of animation arrow toward the right imposes a time delay before it restarts from the left again.
-REPEAT -RUN -TYPE -{label} -GOTO -SET -INCLUDE -READ -IF What does Dialog Manager REALLY do for you? • Controls your application flow and makes on-the-fly decisions • Even decide to replace the flow in the middle of the flow!) • Creates and varies additional lines of code dynamically • Builds an entire set of logic on the fly, then executes it • Communicates intelligently with the operating system • Reads and writes files in your directory or disk • Prompts for and verifies information interactively • Auto-generates volumes of data at run time • Creates complex [nested] repetitions
Robot Controlled by Dialog Manager! Robotics at Power Company
Pass Values Among SUBROUTINES Single & is local to one focexec and any –INCLUDE’d code Double && is global to all focexecs during the session EX SUBR &ABCValue of &ABC passed into SUBR as &1 EX SUBR ABC=&ABCValue of &ABC passed into SUBR as &ABC -SET &&ABC=&ABC; EX SUBRValue of &&ABC is simply valid in SUBR Recall that: -DEFAULTS &1 = ‘ ‘; -SET &ABC = &1 ; -TYPE &ABC &1 &&ABC SUBR FOCEXEC Passing many variables? Easier to specify as && globals Or do it the long and expensive way: -WRITE them out from here, and –READ them into there
Two unrelated files. Two unrelated files. WHERE-based JOIN can accomplish this too, without Dialog Manager! (see One-Liners on Wed.) SECRET Screen With Unrelated Data TABLE FILE CAR SUM MAX.RCOST ON TABLE HOLD AS ‘FROMHOLD’ END -RUN -SET &MAXRCOST = ‘ ‘ ; -READ FROMHOLD &MAXRCOST TABLE FILE EMPLOYEE PRINT EMP_ID IF SALARY GT &MAXRCOST*3 END Which employees can afford the most expensive car?
-REPEAT vs Incrementing Increment Method -SET &COUNTER = 1 ; -STARTLOOP -* PERFORM SOME LOGIC HERE USING &COUNTER -RUN -SET &COUNTER = &COUNTER + 5 ; -IF &COUNTER GT 10 GOTO ENDLOOP ; -GOTO STARTLOOP -ENDLOOP -REPEAT Method -REPEAT ENDLOOP FOR &COUNTER FROM 1 TO 10 STEP 5 -* PERFORM SOME LOGIC HERE USING &COUNTER -ENDLOOP also available … -REPEAT label n TIMES -REPEAT label WHILE any-DM-conditions
Execute by any of: EX RUNREPORTS EX RUNREPORTS ALL EX RUNREPORTS 2 Run them all, or just one, with .EVAL RUNREPORTS FOCEXEC -DEFAULTS &1 = ‘ALL’ -SET &RUNTHIS = &1 ; -SET &EXITNOW = IF &1 EQ ‘ALL’ THEN ‘‘ ELSE ‘–EXIT’ ; -SET &EXITNOW = IF &1 EQ ‘ALL’ THEN ‘‘ ELSE ‘–GOTO OUT’; -GOTO TABLE&RUNTHIS -TABLEALL -TABLE1 TABLE FILE PRINT ... END -RUN &EXITNOW.EVAL -TABLE2 TABLE FILE PRINT ... END -RUN &EXITNOW.EVAL (More reports here) -OUT pick one &RUNTHIS is substituted with report number or ALL
Execute by either: EX ROUTINE EX ROUTINE TEST Dynamically remove code with .EVAL -DEFAULTS &1 = ‘ ’ -SET &COMMENT = IF &1 EQ ‘TEST’ THEN ‘ ‘ ELSE ‘-*’; TABLE FILE PRINT ... &COMMENT.EVAL IF RECORDLIMIT IS 100 END TABLE FILE PRINT ... -IF &1 EQ ‘TEST’ GOTO NOLIMIT1; IF RECORDLIMIT IS 100 -NOLIMIT1 END [ or make it a global&& to influence all routines at once ] Forces either IF RECORDLIMIT IS 100 or -* IF RECORDLIMIT IS 100 Verbose way to ignore the line (need unique labels each time too)
(RCOST GT DCOST + 1000) AND (TODAY IS ‘&WHATDAY’) AND (THESKY IS ‘BLUE’) CRITERIA FOCEXEC ‘GREEN’ ‘MONEY’ ‘BLUE’ ‘WATER’ ‘BLACK’ ‘CLOUD’ ‘RED’ ‘APPLE’ DECLIST FOCEXEC -INCLUDE Blocks of Code COMPUTE COMPUTEA/A5 = IF -INCLUDE CRITERIA THEN ‘OK’ ELSE ‘NOT_OK’; …many lines of calculations… These may have been generated previously by other source code DEFINE FILE FIELD/A12 = DECODE LIST( -INCLUDE DECLIST ELSE ‘UNKNOWN’); …long list of decode pairs…
Use Common-Code Objects -SET ®ION=‘WEST’; TABLE FILE CAR -INCLUDE HEADLINE SUM MAX.RCOST WHERE REGION EQ ‘®ION’ END -RUN -SET ®ION=‘EAST’; TABLE FILE CAR -INCLUDE HEADLINE SUM MAX.DCOST WHERE REGION EQ ‘®ION’ END TABLE . . . TABLE . . . • -SET &HEADLINE = • - DECODE ®ION ( • - ‘WEST’ ‘WEST COAST’ • - ‘EAST’ ‘EAST COAST’ • - ‘NORTH’ ‘NORTHERN’ • ‘SOUTH’ ‘SOUTHERN’ - ELSE ‘OTHER’); • HEADING CENTER • “DATA FOR &HEADLINE REGION” • “Generated on &DATE “ HEADLINEFOCEXEC
EX DMETL EX DMETL 123 EX DMETL AB EX DMETL SUMMIT EX DMETL ARG=123 EX DMETL 1=123 EX DMETL 1=123N Err1: &1 has no value Err2: Must be alphanumeric Err3: Must be at least 3 char long Result: &1 = SUMMIT Err1: &1 has no value Err2: Must be alphanumeric Result: &1 = 123N results in Amper-Variable Characteristics (.EXIST .TYPE.LENGTH) DMETL FOCEXEC -**-DEFAULTS &1 = 'ABC' -IF &1.EXIST EQ 0 GOTO ERR1; -IF &1.TYPE EQ ‘N‘ GOTO ERR2; -IF &1.LENGTH LT 3 GOTO ERR3; -TYPE Result: &|1 = &1
Indexed Amper-Variables ABC FOCEXEC EX ABC ECHO=ALL -SET &P1 = 'ABC'; -SET &P2 = 'DEF'; -SET &NAME&P1&P2 = 456; -SET &NAME.&P1.&P2 = 789; -SET &NAME= &NAME.&P1.&P2; -SET &NAME= &NAME&P1&P2; -TYPE &NAME.&P1.&P2 -TYPE &NAME&P1&P2 -SET &P1 = 'ABC'; -SET &P2 = 'DEF'; -SET &NAME&P1&P2 = 456 -SET &NAMEABCDEF = 789; -SET &NAME= 789; -SET &NAME= 789ABCDEF; -TYPE 789 789 -TYPE 456ABCDEF 456ABCDEF (this line actually does nothing useful!) Store a series of related values in amper-variables via a loop and reference them later programmatically and selectively. Can be many-dimensional.
ENGLAND ,JAGUAR RETAIL_COST 22,369 DEALER_COST 18,621 DIFF_I1 * DIFF_I2 ** DIFF_I3 *** DIFF_I4 3748 DIFF_I5 3748 DIFF_I6 3748 DIFF_F1 * DIFF_F2 ** DIFF_F3 *** DIFF_F4 3748 DIFF_F5 3748 DIFF_F6 3748 DIFF_D1 * DIFF_D2 ** DIFF_D3 *** DIFF_D4 3,748 DIFF_D5 3,748 DIFF_D6 3,748 result Indexed Amper-Variables Task: Generate all formats in one TABLE (subset) -REPEAT LOOP1 FOR &CNT1 FROM 1 TO 3 -SET &FMT.&CNT1 = DECODE &CNT1 -(1 'I' 2 'F' 3 'D' ELSE 'X'); -LOOP1 -* OTHER CODE HERE TABLE FILE CAR BY COUNTRY NOPRINT BY CAR NOPRINT SUBHEAD "<COUNTRY ,<CAR " SUM RCOST OVER DCOST OVER -REPEAT LOOP3 FOR &CNT1 FROM 1 TO 3 -REPEAT LOOP4 FOR &CNT2 FROM 1 TO 6 COMPUTE DIFF_&FMT.&CNT1&CNT2/&FMT.&CNT1&CNT2 = RCOST - DCOST; OVER -LOOP4 -LOOP3 DCOST NOPRINT IF CAR EQ JAGUAR END Create the format combinations generates no dot no dot COMPUTE DIFF_I1/I1 = RCOST-DCOST; OVER . . . DIFF_D6/D6 = RCOST-DCOST; Add each format combination into TABLE
Sample FOCUS dialog… TABLE FILE CAR HEADING PLEASE SUPPLY VALUES REQUESTED T= How do you get the “&” into AT&T? TABLE FILE CAR HEADING "AT&T" PRINT COUNTRY END TABLE FILE CAR HEADING "AT&T" PRINT COUNTRY END BB&T E&J Gallo Winery Florida A&M Univ IF&P Foods ING Canada P&C N. Carolina A&T St. U. PG&E PSE&G Texas A&M Univ Many programmers gave up and just used AT+T SOLUTIONS -SET &T=‘&T’; HEADING “AT&T” HEADING “AT&|T” HEADING “AT&<+0>T”
“Why Would Anybody Do That?” -SET &VAR = DECODE &VAL( - 1 ‘VAL1’ - 2 ‘VAL2’ - 3 ‘VAL3’ - ELSE ‘VAL9’); -SET &VAR = DECODE &VAL( - 1 ‘VAL1’ - 1 ‘VALX’ - 2 ‘VAL2’ - 3 ‘VAL3’ - 3 ‘VALY’ - ELSE ‘VAL9’); This is a normal DECODE Why would someone want to repeat the same code multiple times in the same DECODE? FOCUS accepts it, but it seems useless and consumes resources. ?
“Why Would Anybody Do That?” COMPUTE DEPT= DECODE DEPTCODE( -* ‘GROUP 1’ 1001 ‘SALES’ 1022 ‘SDDS’ 1134 ‘ETH’ -* ‘GROUP 2’ 2023 ‘SADOSFD’ 2113 ‘WRIOU’ -* ‘GROUP 3’ 3006 ‘ASDB’ . . . ELSE ‘UNKNOWN’) ; DECODE in COMPUTE DECODE in Dialog Manager • -SET &DEPT= DECODE &DEPTCODE( -* ‘GROUP 1’ - 1001 ‘SALES’ - 1022 ‘SDDS’ - 1134 ‘ETH’ -* ‘GROUP 2’ - 2023 ‘SADOSFD’ - 2113 ‘WRIOU’ -* ‘GROUP 3’ - 3006 ‘ASDB’ . . . - ELSE ‘UNKNOWN’) ; C D Comment lines are OK in the middle of COMPUTE FOCUS rejects comments in the middle of a multi-line DM phrase
DECODE in Dialog Manager • -SET &DEPT= DECODE &DEPTCODE( -* ‘GROUP 1’ - 1001 ‘SALES’ - 1022 ‘SDDS’ - 1134 ‘ETH’ -* ‘GROUP 2’ - 2023 ‘SADOSFD’ - 2113 ‘WRIOU’ -* ‘GROUP 3’ - 3006 ‘ASDB’ . . . - ELSE ‘UNKNOWN’) ; D “Why Would Anybody Do That?” -SET &DEPT = DECODE &DEPTCODE( - 0 ‘GROUP 1’ - 1001 ‘SALES’ - 1022 ‘SDDS’ - 1134 ‘ETH’ - 0 ‘GROUP 2’ - 2023 ‘SADOSFD’ - 2113 ‘WRIOU’ - 0 ‘GROUP 3’ - 3006 ‘ASDB’ . . . - ELSE ‘UNKNOWN’) ; DECODE in Dialog Manager C Just re-use an impossible value! Just re-use an impossible value! Just re-use an impossible value!
This code actually does not work It freezes!Why?? Other Dialog Manager Rules and Nuances ECHO across all routines SET DEFECHO = ALL SET DMPRECISION = 7 -RUN TABLE FILE CAR PRINT COUNTRY CAR -INCLUDE GETRAD HEADING CENTER "VALUE OF PI IS &PI“ END -RUN . . . More code -GOTO NOFILE . . . . . . -NOFILE Calculation- and display- precision of &variables Subroutines require format for last arg OS interaction GETRAD FOCEXEC -CMS STATE GETRAD FILE A -IF &RETCODE EQ 1 GOTO NOFILE; -READIT -TYPE READING FROM GETRAD -READ GETRAD &CIRCUM &RADIUS NOCLOSE -IF &RETCODE EQ 1 GOTO NORAD ; -SET &CIRCUM = LJUST (8,&CIRCUM,'A8'); -IF &CIRCUM EQ ' ' GOTO READIT; -SET &PI = &CIRCUM /(2*&RADIUS); -NORAD -NOFILE Embeds the code as if it were already there Without NOCLOSE, loop will re-read the 1st record forever Some system &’s force a -RUN Independent labels! C L U E
FIN FIN FIN FIN FTP Mainframe Analysis PC Analysis Varying Sort Columns on FOCLOG Reports What is FOCLOG? FOCUSOnlineUser FOCUSBatchJob FOCUS OnlineUser FOCUS Batch Job Memory Memory Memory Memory LOG FILE (character flat file) FOCLOG MFD
403 Varying Sort Columns on FOCLOG Reports Select report 403
Varying Sort Columns on FOCLOG Reports Data sorted by User and Session Date
Varying Sort Columns on FOCLOG Reports Select to sort by (D)uration
Varying Sort Columns on FOCLOG Reports Added to the column description
Varying Sort Columns on FOCLOG Reports -* S O R T L I S T -* SDUR -* |SCPU -* ||SEXCP -* ||| -SET &SORT101 = ' '; -SET &SORT102 = ' '; -SET &SORT103 = ' X '; -SET &SORT104 = 'X X'; -SET &SORT105 = 'X X'; -SET &SORT106 = 'X X'; -SET &SORT401 = ' '; -SET &SORT402 = ' '; -SET &SORT403 = ’XXX'; -SET &SORT404 = ' '; -SET &SORT405 = 'XXX'; -SET &SORT406 = ' '; -SET &SORT407 = 'XX '; Duration, Cpu, Excp
Varying Sort Columns on FOCLOG Reports &SORTSEL &ASKSORT
Varying Sort Columns on FOCLOG Reports Indexed &variable creates &SORT403 Whose value is ‘ X X X’ -* CREATE SORT-CHOICES. MAY BE MORE THAN ONE, SO BUILD ASKSORT. -* USE MULTIPLE LINES - &ASKSORT SUBSTITUTION CAN BECOME LONG. -SET &ASKSORT = ‘'; -SET &SORTREP = &SORT.&REPORT ; -SET &ASKSORT= IF (EDIT(&SORTREP,'9$$') EQ 'X') - THEN &ASKSORT | ' ' | '(D)URATION' ELSE - &ASKSORT ; -SET &ASKSORT = IF (EDIT(&SORTREP,'$9$') EQ ‘X‘) - THEN &ASKSORT | ' ' | '(C)PU' ELSE - &ASKSORT ; -SET &ASKSORT = IF (EDIT(&SORTREP,'$$9') EQ 'X') - THEN &ASKSORT | ' ' | '(E)XCP' ELSE - &ASKSORT ; -SET &ASKSORT = IF (&ASKSORT EQ ' ') THEN '(None Available) ' - ELSE &ASKSORT ; -* FORCE 'N' IF NO SORTS -SET &SORTSEL=IF(EDIT(&ASKSORT,'$9999') - EQ 'None') THEN 'N' ELSE ' '; Append each sort option to the list as you go Why should each &ASKSORT be on a line by itself?
Varying Sort Columns on FOCLOG Reports -* VERIFY THE OPTIONAL SORT CRITERIA -* ---------------------------------- -SET &&SORTBY =IF(&SORTSEL EQ ' ') OR (&SORTSEL EQ 'N') THEN ' ' ELSE - IF(&SORTSEL EQ 'D') AND (EDIT(&SORTREP,'9$$') EQ 'X') THEN 'SDUR' - IF(&SORTSEL EQ 'C') AND (EDIT(&SORTREP,'$9$') EQ 'X') THEN 'SCPU' - IF(&SORTSEL EQ 'E') AND (EDIT(&SORTREP,'$$9') EQ 'X') THEN 'SEXCP' - ELSE 'BAD'; -* MARK COLUMN ON REPORT AS THE "SORT" COLUMN (AFTER CALENDAR AGGREG). -SET &&SDUR = IF (&&SORTBY EQ 'SDUR') THEN '**SORT**' ELSE ' '; -SET &&SCPU = IF (&&SORTBY EQ 'SCPU' ) THEN '**SORT**' ELSE ' '; -SET &&SEXCP = IF (&&SORTBY EQ 'SEXCP') THEN '**SORT**' ELSE ' '; -SET &&SORTTEXT = DECODE &&SORTBY (' ' ' ' - 'SDUR' 'BY HIGHEST SESDURATION NOPRINT' - 'SCPU' 'BY HIGHEST SESCPU NOPRINT' - 'SEXCP' 'BY HIGHEST SESEXCP NOPRINT' - ELSE ' ');
Varying Sort Columns on FOCLOG Reports TABLE FILE HEADING CENTER "&&HEADER1" "DAILY USER ACTIVITY DETAIL</1" -* PUT DAY RIGHT UP AGAINST STARTDATE SUM DOWTEXT IN +0 AS ' ' COMPUTE REC/D9 = RECORDS/1000; IN +1 AS '&&CREC, RECORDS,EXTRACTED, (/1000)' COMPUTE LIN/D9 = LINES/1000; IN +1 AS '&&CLINE,LINES OF, OUTPUT, (/1000)' COMPUTE DURVALUE/D11.3 = SESDURATION; NOPRINT -INCLUDE FLISDUR COMPUTE DURSHOW/A11 = DURTIME; AS ' &&SDUR, DURATION, HH:MM:SS' COMPUTE CPUVALUE/D11.3 = SESCPU; NOPRINT -INCLUDE FLISCPU COMPUTE CPUSHOW/A11 = CPUTIME; AS ' &&SCPU, CPU USAGE, HH:MM:SS' -INCLUDE FLISEXCP COMPUTE EXCPSHOW/A11 = EXCPTIME; AS ' &&SEXCP, CPU USAGE, HH:MM:SS' &&SORTTEXT BY USERID AS ' USER ' BY STARTDATE AS ' SESSION' &&IFDATERANGE FOOTING BOTTOM CENTER "&&FOOTER1 &FOCFOCEXEC" &&HOLDFMT END Blank or **SORT** Blank, or alternate sort preceding other BYs
&X &X &X Multi-Purpose Code Objective: Test all places where a date can be assigned (grossly simplified) DEFINE FILE CAR DFIELD/YYMD WITH COUNTRY = 20080602 ; TABLE FILE CAR PRINT COMPUTE TFIELD/YYMD = 20080602 ; NOPRINT MODIFY FILE CAR COMPUTE MFIELD/YYMD = 20080602 ; &COMPUTE &X|FIELD/YYMD &WITH =&YYMD;&NOPRINT Basically the same computation in all three places
Multi-Purpose Code -SET &COMPUTE= IF(&X EQ ‘T' OR ‘M')THEN 'COMPUTE' ELSE ‘'; -SET &WITH = IF(&X EQ 'D') THEN 'WITH COUNTRY‘ELSE ''; -SET &NOPRINT = IF(&X EQ 'T') THEN 'NOPRINT‘ ELSE ‘'; &COMPUTE &X|FIELD/YYMD &WITH = &YYMD; &NOPRINT -* NEW DATE FORMATS &COMPUTE &X|YYMD/YYMD = &X|FIELD; &NOPRINT &COMPUTE &X|MDYY/MDYY = &X|FIELD; &NOPRINT &COMPUTE &X|DMYY/DMYY = &X|FIELD; &NOPRINT &COMPUTE &X|YMD/YMD = &X|FIELD; &NOPRINT &COMPUTE &X|MDY/MDY = &X|FIELD; &NOPRINT . . . NOT Dialog Manager - resolved line substituted into executed (stacked) code Pick up the system date (&YYMD) then propagate to other fields below Actual test suite generates thousands of tests, identically consistent across all areas of the FOCUS language
Capture and Restore SET’ings -* CAPTURE VALUE OF SPACES -? SET SPACES &SPACES_WAS SET SPACES = 1 -RUN TABLE FILE . . . END -RUN SET SPACES = &SPACES_WAS . . . . SET SPACES = 3 . . FOCPARM ERRORS FOCPROF ERRORS PROFILE FOCEXEC Previous FOCEXEC Might be able to use ON TABLE SET instead (not all SETs allow it)
Multi-Purpose Code Objective: Capture current value of all SETs, then reset them after -SET &RC= IF(&1 EQ ‘CAPTURE’) THEN ‘-? SET’ ELSE - IF(&1 EQ ‘RESET’ ) THEN 'SET' ELSE 'BAD'; -SET &EQ= IF(&1 EQ ‘CAPTURE’) THEN ‘ ‘ ELSE - IF(&1 EQ ‘RESET’ ) THEN ‘=‘ ELSE 'BAD'; -* (error here if BAD) &RC.EVAL ASNAMES &EQ.EVAL &&ASNAMES &RC.EVAL SPACES &EQ.EVAL &&SPACES &RC.EVAL ALL &EQ.EVAL &&ALL &RC.EVAL NODATA &EQ.EVAL &&NODATA . . . (very long list of SETs) -? SET ASNAMES &&ASNAMES -? SET SPACES &&SPACES . . . EX GETSETS CAPTURE -RUN ------------------------- LOTS OF FOCEXEC CODE HERE ------------------------- EX GETSETS RESET -RUN Get the full list from ? SET ALL SET ASNAMES = &&ASNAMES SET SPACES = &&SPACES . . . GETSETS FOCEXEC called with parameter ‘CAPTURE’ or ‘RESET’ Advantage? Keep one list of SETs for capture and reset instead of parallel lists
BONUS Giveaway - Scrabble Code Objective: Generate all permutations of a word or string of characters 'THREAD' permutes into 1,800 unique 4- 5- and 6-letter combinations, but only these are actual words: 4-LETTERS: DARE DATE DEAR DRAT HADE HARD HARE HART HATE HEAD HEAR HEAT HERD PART RATE RATH RHEA READ TAHR TARD TARE TEAR 5-LETTERS: DATER DEATH EARTH HATER HEARD HEART TRADE TREAD 6-LETTERS: DEARTH HATRED The routine employs these Dialog Manager techniques: • Indexed &variables • Nested -REPEAT loops • .EVAL suffix on &variables • -WRITE to a file with subsequent Master Show Defs Hide Defs Custom animation arrows move the off-page box on and off the screen with the two hiper-keys at the bottom right. DRAT – confound, annoy HADE – angle between a fault plane and the vertical; inclination of a mining vein HART – a male deer RHEA – flightless South American ostrich-like bird; moon of Saturn TAHR – wild goat TARE – various, or seed of, vetches (climbing plants); vehicle weight without passengers or content DEARTH – scarcity, inadequate supply source: dictionary.com
-*************************** -* SCRABBLE WORD PERMUTATONS -*************************** -* CREATED BY: -* JOEL STARKMAN, DIRECTOR, FOCUS DIVISION, INFORMATION BUILDERS, INC. -* FOR TECH SUMMIT ATTENDEES OF 'ADVANCED DIALOG MANAGER' PRESENTATION -* JUNE 2, 2008 -* PURPOSE: -* GENERATE THE PERMUTATIONS OF A STRING OF LETTERS OR OF A WORD. -* SINCE IT CANNOT DETERMINE WHICH DERIVED WORDS ARE TRULY REAL WORDS, -* ONE MAY FEED THE LIST TO A WORD PROCESSOR TO SELECT VALID WORDS. -* FOR EXAMPLE, THE WORD 'THREAD' PERMUTES INTO 240 COMBINATIONS OF -* 4- 5- AND 6-LETTER WORDS. ONLY THESE 29 ARE ACTUAL WORDS: -* 4-LETTERS: DEAR DARE DATE DRAT -* HARD HERD HATE HARE HEAR HEAD -* PART RATH RATE READ TARD TERD TEAR -* 5-LETTERS: DATER DEATH EARTH HEART TREAD TRADE HATER HATER -* 6-LETTERS: HATRED -* -* THIS ROUTINE APPLIES SEVERAL SOPHISTICATED DIALOG MANAGER TECHNIQUES: -* - NESTED -REPEAT LOOPS -* - INDEXED AMPER VARIABLES -* - .EVAL SUFFIX ON AMPERS -* - -WRITE TO A FILE WITH SUBSEQUENT MASTER -*********************************************************************** -* WHAT IS THE SMALLEST WORD PERMITTED? -SET &MINCHAR = 4 ; -* WHAT IS THE SMALLEST SIZE PERMUTATION? -SET &MINPERM = 4 ; -* WHAT IS THE LARGEST WORD PERMITTED? ANYTHING OVER 7 TAKES SIGNIF CPU -SET &MAXSIZE = 9 ; -******************************** -* INITIAL OPERATING SYSTEM SETUP -******************************** -IF &FOCMODE EQ 'CMS' GOTO CMS_OUTPUT; -MVS_OUTPUT SET TRMOUT = OFF DYNAM FREE FILE PERMUTE DYNAM ALLOC FILE PERMUTE NEW CYL SPACE 10,20 DSORG PS RECFM FB - LRECL 4096 BLKSIZE 4096 SET TRMOUT = ON -RUN -GOTO BUILD_WORDS -CMS_OUTPUT -CMS SET CMSTYPE HT -CMS STATE PERMUTE FOCTEMP A -IF &RETCODE EQ 0 GOTO NOOUTPUT ; -CMS ERASE PERMUTE FOCTEMP A -NOOUTPUT -CMS FILEDEF PERMUTE DISK PERMUTE FOCTEMP A -CMS SET CMSTYPE RT -*--------------------------------------------------------------------- -* PROMPT FOR THE WORD OR STRING, AND VERIFY IT -*--------------------------------------------------------------------- -BUILD_WORDS -DEFAULTS &1 = 'ABCDE'; -SET &ORIGWORD = &1 ; -**-SET &ORIGWORD = ' '; -**-PROMPT &ORIGWORD.ENTER WORD UP TO &MAXSIZE.EVAL CHARACTERS, OR QUIT:. -**TO FORCE THE WORD AFTER PROMPT, USE (SET ANY WORD): -**-SET &ORIGWORD = 'ASCEND'; -**-IF &ORIGWORD EQ 'QUIT' GOTO BOTTOM; -*--------------------------------------------- -* VERIFY THE ENTERED WORD -*--------------------------------------------- -* HOW MANY CHARACTERS ARE IN THE PROVIDED WORD? -SET &MAXCHAR = &ORIGWORD.LENGTH ; -* REMOVE LEADING ZERO INSERTED BY .LENGTH FUNCTION -SET &MAXCHAR = EDIT(&MAXCHAR,'$9'); -IF &MAXCHAR GE &MINCHAR THEN GOTO ENOUGHCHARS ; -TYPE &ORIGWORD IS &MAXCHAR LETTERS LONG. MUST BE AT LEAST &MINCHAR -GOTO BOTTOM -ENOUGHCHARS -IF &MAXCHAR LE &MAXSIZE GOTO TOMANYCHARS; -TYPE &ORIGWORD IS &MAXCHAR LETTERS LONG. MAX IS &MAXSIZE -GOTO BOTTOM -TOMANYCHARS -* VERIFY NO BLANKS IN THE WORD -REPEAT GETCHAR FOR &NUMCHAR FROM 1 TO &MAXCHAR -SET &CHAR.&NUMCHAR = - SUBSTR(&MAXCHAR,&ORIGWORD,&NUMCHAR,&NUMCHAR,1,'A1'); -IF &CHAR.&NUMCHAR NE ' ' GOTO GETCHAR ; -TYPE CHARACTER #&NUMCHAR IS BLANK. PLEASE RETYPE. -GOTO BOTTOM -GETCHAR -* FILL IN THE REST OF THE POSITIONS WITH '*' -IF &MAXCHAR EQ &MAXSIZE GOTO NOMORECHAR2 ; -SET &PLUS1 = &MAXCHAR + 1 ; -REPEAT GETCHAR2 FOR &NUMCHAR FROM &PLUS1 TO &MAXSIZE -SET &CHAR.&NUMCHAR = '*'; -GETCHAR2 -NOMORECHAR2 -TYPE INPUT STRING = &ORIGWORD -WRITE PERMUTE INPUT STRING = &ORIGWORD -IF &MAXCHAR LE 5 GOTO NOMSG; -TYPE *** &MAXCHAR CHARACTERS TAKES SIGNIFICANT TIME TO PROCESS *** -NOMSG -* CAPTURE CPU AT START -SET &CPU1 = &FOCCPU ; -*----------------------------------------------------------- -* DO ONLY AS MANY LOOPS AS THE LENGTH OF THE STRING PROVIDED -*----------------------------------------------------------- -REPEAT MIN_TO_MAX FOR &NUMLETS FROM &MINPERM TO &MAXCHAR -SET &TIME = ' '; -SET &TIME = HHMMSS('A8'); -WRITE PERMUTE &DATE &TIME PERMUTATIONS OF &NUMLETS CHARACTERS ... -TYPE &DATE &TIME PERMUTATIONS OF &NUMLETS CHARACTERS ... -* INITIALIZE NUMBER OF PERMUTATIONS FOR THIS MANY CHARACTERS. -SET &NUMPERMS = 0 ; -********************************************************************** -* LOOP THROUGH EACH LEVEL -********************************************************************** -IF &NUMLETS LT 1 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 1 -REPEAT POS1 FOR &POS1 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -SET &PICKED1 = &CHAR.&POS1 ; -IF &NUMLETS LT 2 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 2 -REPEAT POS2 FOR &POS2 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS2 EQ &POS1.EVAL) - THEN GOTO POS2 ; -SET &PICKED2 = &CHAR.&POS2 ; -IF &NUMLETS LT 3 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 3 -REPEAT POS3 FOR &POS3 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS3 EQ &POS1.EVAL OR &POS2.EVAL) - THEN GOTO POS3 ; -SET &PICKED3 = &CHAR.&POS3 ; -IF &NUMLETS LT 4 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 4 -REPEAT POS4 FOR &POS4 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS4 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL) - THEN GOTO POS4 ; -SET &PICKED4 = &CHAR.&POS4 ; -IF &NUMLETS LT 5 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 5 -REPEAT POS5 FOR &POS5 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS5 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL) - THEN GOTO POS5 ; -SET &PICKED5 = &CHAR.&POS5 ; -IF &NUMLETS LT 6 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 6 -REPEAT POS6 FOR &POS6 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS6 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL) - THEN GOTO POS6 ; -SET &PICKED6 = &CHAR.&POS6 ; -IF &NUMLETS LT 7 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 7 -REPEAT POS7 FOR &POS7 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS7 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL OR &POS6.EVAL) - THEN GOTO POS7 ; -SET &PICKED7 = &CHAR.&POS7 ; -IF &NUMLETS LT 8 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 8 -REPEAT POS8 FOR &POS8 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS8 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL OR &POS6.EVAL - OR &POS7.EVAL) - THEN GOTO POS8 ; -SET &PICKED8 = &CHAR.&POS8 ; -IF &NUMLETS LT 9 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 9 -REPEAT POS9 FOR &POS9 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS9 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL OR &POS6.EVAL - OR &POS7.EVAL OR &POS8.EVAL) - THEN GOTO POS9 ; -SET &PICKED9 = &CHAR.&POS9 ; -SKIPINNER -* CREATE THIS PERMUTATION -SET &PERMUTATION = ''; -REPEAT PERM FOR &EACHLET FROM 1 TO &NUMLETS -SET &PERMUTATION = &PERMUTATION | &PICKED.&EACHLET ; -PERM -*-TYPE &PERMUTATION -WRITE PERMUTE &PERMUTATION -* INCREMENT PERMUTATIONS FOUND. TYPE MESSAGE EVERY 500. -SET &NUMPERMS = &NUMPERMS + 1 ; -SET &IMOD = IMOD(&NUMPERMS, 500, 'I2'); -IF &IMOD NE 0 GOTO NOTYET; -TYPE UP TO &NUMPERMS|TH PERMUTATION -NOTYET -* END THE REPEAT LOOPS (IN REVERSE ORDER) -POS9 -POS8 -POS7 -POS6 -POS5 -POS4 -POS3 -POS2 -POS1 -SET &TIME = HHMMSS('A8'); -WRITE PERMUTE &DATE &TIME &NUMPERMS PERMUTATIONS OF &NUMLETS CHARS -TYPE &NUMPERMS PERMUTATIONS OF &NUMLETS CHARS -* END OF OUTER LOOP. CREATE THE PERMUTATIONS OF THE NEXT # OF LETTERS -MIN_TO_MAX -*********************************************************************** -* CLOSE OUT THE PERMUTATION PROCESS -SET &TIME = HHMMSS('A8'); -WRITE PERMUTE &DATE &TIME END OF PERMUTATIONS -TYPE &DATE &TIME END OF PERMUTATIONS -CLOSE PERMUTE -*********************************** -* GENERATE A SUMMARY REPORT -*********************************** -* HERE IS THE MASTER USED TO PROCESS THE TABLE BELOW. -* COPY THESE LINES TO 'PERMUTE MASTER'. -GOTO SKIPMASTER FILENAME = PERMUTE, SUFFIX = FIX SEGNAME = FLATSEG FIELDNAME = , FILL1, A1, A1, $ FIELDNAME = WORD , WORD, A9, A9, $ FIELDNAME = , FILL2, A35,A35, $ FIELDNAME = , FILL3, A35,A35, $ DEFINE POS_1_45/A45 = FILL1 | WORD | FILL2;,$ DEFINE POS_1_80/A80 = FILL1 | WORD | FILL2 | FILL3;,$ -SKIPMASTER DEFINE FILE PERMUTE SIZE_SORT/I1 = ARGLEN(9,WORD,SIZE_SORT); END TABLE FILE PERMUTE HEADING "SUMMARY FOR INPUT STRING = &ORIGWORD " SUM FST.WORD NOPRINT LST.WORD NOPRINT CNT.WORD NOPRINT BY SIZE_SORT NOPRINT ON SIZE_SORT SUBHEAD "<CNT.WORD>PERMUTATIONS FOR <SIZE_SORT>LETTER WORDS" " FIRST WORD IN LIST = <FST.WORD" " LAST WORD IN LIST = <LST.WORD" -* ELIMINATE SPURIOUS LINES IN THE FLAT FILE. IF POS_1_45 NE ' ' IF POS_1_45 OMITS 'PERMUTATION' OR 'FOCEXEC =' WHERE WORD NE 'NPUT STRI' OR ' ' OR 'ERMUTATIO' ON TABLE SET PAGE NOPAGE ON TABLE SET MSG OFF ON TABLE SET SCREEN OFF ON TABLE SET PAUSE OFF END -RUN -GOTO BOTTOM -******************************************************************* -* PLAY WITH THE CPU UTILIZED BY THIS RUN. -* DETERMINE A BASE NUMBER FROM PREVIOUS RUNS. -SET &BASECPU = IF &MAXCHAR EQ 6 THEN 8200 ELSE - IF &MAXCHAR GT 6 THEN 65300 ELSE 1000 ; -SET &DIFF = &FOCCPU - &CPU1 ; -SET &LOWCPU = &BASECPU - (&DIFF / 10); -SET &HICPU = &BASECPU + (&DIFF / 10); -TYPE LOWCPU = &LOWCPU -TYPE HICPU = &HICPU -TYPE DIFF = &DIFF -IF (&DIFF GE &LOWCPU) AND - (&DIFF LE &HICPU) GOTO CPU_OK ELSE -IF (&DIFF GE &HICPU) GOTO CPU_HI; -CPU_LOW -TYPE CPU USED FOR PERMUTATIONS DROPPED BY MORE THAN 10% -GOTO BOTTOM -CPU_HI -TYPE CPU USED FOR PERMUTATIONS INCREASED BY MORE THAN 10% -GOTO BOTTOM -CPU_OK -TYPE CPU USED FOR PERMUTATIONS WAS WITHIN EXPECTED VALUES -GOTO BOTTOM -BOTTOM -EXIT This is the top of the long object of code, used only to provide a scrolling effect for the slide during presentation. Scroll down to get to the slide itself. This code block is duplicate of below. Just here for presentation scroll effect. BONUS Giveaway - Scrabble Code -*************************** -* SCRABBLE WORD PERMUTATONS -*************************** -* CREATED BY: -* JOEL STARKMAN, DIRECTOR, FOCUS DIVISION, INFORMATION BUILDERS, INC. -* FOR TECH SUMMIT ATTENDEES OF 'ADVANCED DIALOG MANAGER' PRESENTATION -* JUNE 2, 2008 -* PURPOSE: -* GENERATE THE PERMUTATIONS OF A STRING OF LETTERS OR OF A WORD. -* SINCE IT CANNOT DETERMINE WHICH DERIVED WORDS ARE TRULY REAL WORDS, -* ONE MAY FEED THE LIST TO A WORD PROCESSOR TO SELECT VALID WORDS. -* FOR EXAMPLE, THE WORD 'THREAD' PERMUTES INTO 240 COMBINATIONS OF -* 4- 5- AND 6-LETTER WORDS. ONLY THESE 29 ARE ACTUAL WORDS: -* 4-LETTERS: DEAR DARE DATE DRAT -* HARD HERD HATE HARE HEAR HEAD -* PART RATH RATE READ TARD TERD TEAR -* 5-LETTERS: DATER DEATH EARTH HEART TREAD TRADE HATER HATER -* 6-LETTERS: HATRED -* -* THIS ROUTINE APPLIES SEVERAL SOPHISTICATED DIALOG MANAGER TECHNIQUES: -* - NESTED -REPEAT LOOPS -* - INDEXED AMPER VARIABLES -* - .EVAL SUFFIX ON AMPERS -* - -WRITE TO A FILE WITH SUBSEQUENT MASTER -*********************************************************************** -* WHAT IS THE SMALLEST WORD PERMITTED? -SET &MINCHAR = 4 ; -* WHAT IS THE SMALLEST SIZE PERMUTATION? -SET &MINPERM = 4 ; -* WHAT IS THE LARGEST WORD PERMITTED? -* (ANYTHING OVER 7 LETTERS TAKES SIGNIFICANT CPU) -SET &MAXSIZE = 9 ; -******************************** -* INITIAL OPERATING SYSTEM SETUP -******************************** -IF &FOCMODE EQ 'CMS' GOTO CMS_OUTPUT; -MVS_OUTPUT SET TRMOUT = OFF DYNAM FREE FILE PERMUTE DYNAM ALLOC FILE PERMUTE NEW CYL SPACE 10,20 DSORG PS RECFM FB - LRECL 4096 BLKSIZE 4096 SET TRMOUT = ON -RUN -GOTO BUILD_WORDS -CMS_OUTPUT -CMS SET CMSTYPE HT -CMS STATE PERMUTE FOCTEMP A -IF &RETCODE EQ 0 GOTO NOOUTPUT ; -CMS ERASE PERMUTE FOCTEMP A -NOOUTPUT -CMS FILEDEF PERMUTE DISK PERMUTE FOCTEMP A -CMS SET CMSTYPE RT -*--------------------------------------------------------------------- -* PROMPT FOR THE WORD OR STRING, AND VERIFY IT -*--------------------------------------------------------------------- -BUILD_WORDS -DEFAULTS &1 = 'ABCDE'; -SET &ORIGWORD = &1 ; -**-SET &ORIGWORD = ' '; -**-PROMPT &ORIGWORD.ENTER WORD UP TO &MAXSIZE.EVAL CHARACTERS, OR QUIT:. -**TO FORCE THE WORD AFTER PROMPT, USE (SET ANY WORD): -**-SET &ORIGWORD = 'ASCEND'; -**-IF &ORIGWORD EQ 'QUIT' GOTO BOTTOM; -*--------------------------------------------- -* VERIFY THE ENTERED WORD -*--------------------------------------------- -* HOW MANY CHARACTERS ARE IN THE PROVIDED WORD? -SET &MAXCHAR = &ORIGWORD.LENGTH ; -* REMOVE LEADING ZERO INSERTED BY .LENGTH FUNCTION -SET &MAXCHAR = EDIT(&MAXCHAR,'$9'); -IF &MAXCHAR GE &MINCHAR THEN GOTO ENOUGHCHARS ; -TYPE &ORIGWORD IS &MAXCHAR LETTERS LONG. MUST BE AT LEAST &MINCHAR -GOTO BOTTOM -ENOUGHCHARS -IF &MAXCHAR LE &MAXSIZE GOTO TOMANYCHARS; -TYPE &ORIGWORD IS &MAXCHAR LETTERS LONG. MAX IS &MAXSIZE -GOTO BOTTOM -TOMANYCHARS -* VERIFY NO BLANKS IN THE WORD -REPEAT GETCHAR FOR &NUMCHAR FROM 1 TO &MAXCHAR -SET &CHAR.&NUMCHAR = - SUBSTR(&MAXCHAR,&ORIGWORD,&NUMCHAR,&NUMCHAR,1,'A1'); -IF &CHAR.&NUMCHAR NE ' ' GOTO GETCHAR ; -TYPE CHARACTER #&NUMCHAR IS BLANK. PLEASE RETYPE. -GOTO BOTTOM -GETCHAR -* FILL IN THE REST OF THE POSITIONS WITH '*' -IF &MAXCHAR EQ &MAXSIZE GOTO NOMORECHAR2 ; -SET &PLUS1 = &MAXCHAR + 1 ; -REPEAT GETCHAR2 FOR &NUMCHAR FROM &PLUS1 TO &MAXSIZE -SET &CHAR.&NUMCHAR = '*'; -GETCHAR2 -NOMORECHAR2 -TYPE INPUT STRING = &ORIGWORD -WRITE PERMUTE INPUT STRING = &ORIGWORD -IF &MAXCHAR LE 5 GOTO NOMSG; -TYPE *** &MAXCHAR CHARACTERS TAKES SIGNIFICANT TIME TO PROCESS *** -NOMSG -* CAPTURE CPU AT START -SET &CPU1 = &FOCCPU ; -*----------------------------------------------------------- -* DO ONLY AS MANY LOOPS AS THE LENGTH OF THE STRING PROVIDED -*----------------------------------------------------------- -REPEAT MIN_TO_MAX FOR &NUMLETS FROM &MINPERM TO &MAXCHAR -SET &TIME = ' '; -SET &TIME = HHMMSS('A8'); -WRITE PERMUTE &DATE &TIME PERMUTATIONS OF &NUMLETS CHARACTERS ... -TYPE &DATE &TIME PERMUTATIONS OF &NUMLETS CHARACTERS ... -* INITIALIZE NUMBER OF PERMUTATIONS FOR THIS MANY CHARACTERS. -SET &NUMPERMS = 0 ; -********************************************************************** -* LOOP THROUGH EACH LEVEL -********************************************************************** -IF &NUMLETS LT 1 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 1 -REPEAT POS1 FOR &POS1 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -SET &PICKED1 = &CHAR.&POS1 ; -IF &NUMLETS LT 2 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 2 -REPEAT POS2 FOR &POS2 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS2 EQ &POS1.EVAL) - THEN GOTO POS2 ; -SET &PICKED2 = &CHAR.&POS2 ; -IF &NUMLETS LT 3 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 3 -REPEAT POS3 FOR &POS3 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS3 EQ &POS1.EVAL OR &POS2.EVAL) - THEN GOTO POS3 ; -SET &PICKED3 = &CHAR.&POS3 ; -IF &NUMLETS LT 4 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 4 -REPEAT POS4 FOR &POS4 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS4 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL) - THEN GOTO POS4 ; -SET &PICKED4 = &CHAR.&POS4 ; -IF &NUMLETS LT 5 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 5 -REPEAT POS5 FOR &POS5 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS5 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL) - THEN GOTO POS5 ; -SET &PICKED5 = &CHAR.&POS5 ; -IF &NUMLETS LT 6 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 6 -REPEAT POS6 FOR &POS6 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS6 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL) - THEN GOTO POS6 ; -SET &PICKED6 = &CHAR.&POS6 ; -IF &NUMLETS LT 7 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 7 -REPEAT POS7 FOR &POS7 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS7 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL OR &POS6.EVAL) - THEN GOTO POS7 ; -SET &PICKED7 = &CHAR.&POS7 ; -IF &NUMLETS LT 8 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 8 -REPEAT POS8 FOR &POS8 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS8 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL OR &POS6.EVAL - OR &POS7.EVAL) - THEN GOTO POS8 ; -SET &PICKED8 = &CHAR.&POS8 ; -IF &NUMLETS LT 9 GOTO SKIPINNER ; -* LOOP THROUGH EACH CHAR AT LEVEL 9 -REPEAT POS9 FOR &POS9 FROM 1 TO &MAXCHAR -* PICK A CHAR FOR THIS LEVEL. SKIP CHARS ALREADY USED ABOVE -IF (&POS9 EQ &POS1.EVAL OR &POS2.EVAL OR &POS3.EVAL - OR &POS4.EVAL OR &POS5.EVAL OR &POS6.EVAL - OR &POS7.EVAL OR &POS8.EVAL) - THEN GOTO POS9 ; -SET &PICKED9 = &CHAR.&POS9 ; -SKIPINNER -* CREATE THIS PERMUTATION -SET &PERMUTATION = ''; -REPEAT PERM FOR &EACHLET FROM 1 TO &NUMLETS -SET &PERMUTATION = &PERMUTATION | &PICKED.&EACHLET ; -PERM -*-TYPE &PERMUTATION -WRITE PERMUTE &PERMUTATION -* INCREMENT PERMUTATIONS FOUND. TYPE MESSAGE EVERY 500. -SET &NUMPERMS = &NUMPERMS + 1 ; -SET &IMOD = IMOD(&NUMPERMS, 500, 'I2'); -IF &IMOD NE 0 GOTO NOTYET; -TYPE UP TO &NUMPERMS|TH PERMUTATION -NOTYET -* END THE REPEAT LOOPS (IN REVERSE ORDER) -POS9 -POS8 -POS7 -POS6 -POS5 -POS4 -POS3 -POS2 -POS1 -SET &TIME = HHMMSS('A8'); -WRITE PERMUTE &DATE &TIME &NUMPERMS PERMUTATIONS OF &NUMLETS CHARS -TYPE &NUMPERMS PERMUTATIONS OF &NUMLETS CHARS -* END OF OUTER LOOP. CREATE THE PERMUTATIONS OF THE NEXT # OF LETTERS -MIN_TO_MAX -*********************************************************************** -* CLOSE OUT THE PERMUTATION PROCESS -SET &TIME = HHMMSS('A8'); -WRITE PERMUTE &DATE &TIME END OF PERMUTATIONS -TYPE &DATE &TIME END OF PERMUTATIONS -CLOSE PERMUTE -*********************************** -* GENERATE A SUMMARY REPORT -*********************************** -* HERE IS THE MASTER USED TO PROCESS THE TABLE BELOW. -* COPY THESE LINES TO 'PERMUTE MASTER'. -GOTO SKIPMASTER FILENAME = PERMUTE, SUFFIX = FIX SEGNAME = FLATSEG FIELDNAME = , FILL1, A1, A1, $ FIELDNAME = WORD , WORD, A9, A9, $ FIELDNAME = , FILL2, A35,A35, $ FIELDNAME = , FILL3, A35,A35, $ DEFINE POS_1_45/A45 = FILL1 | WORD | FILL2;,$ DEFINE POS_1_80/A80 = FILL1 | WORD | FILL2 | FILL3;,$ -SKIPMASTER DEFINE FILE PERMUTE SIZE_SORT/I1 = ARGLEN(9,WORD,SIZE_SORT); END TABLE FILE PERMUTE HEADING "SUMMARY FOR INPUT STRING = &ORIGWORD " SUM FST.WORD NOPRINT LST.WORD NOPRINT CNT.WORD NOPRINT BY SIZE_SORT NOPRINT ON SIZE_SORT SUBHEAD "<CNT.WORD>PERMUTATIONS FOR <SIZE_SORT>LETTER WORDS" " FIRST WORD IN LIST = <FST.WORD" " LAST WORD IN LIST = <LST.WORD" -* ELIMINATE SPURIOUS LINES IN THE FLAT FILE. IF POS_1_45 NE ' ' IF POS_1_45 OMITS 'PERMUTATION' OR 'FOCEXEC =' WHERE WORD NE 'NPUT STRI' OR ' ' OR 'ERMUTATIO' ON TABLE SET PAGE NOPAGE ON TABLE SET MSG OFF ON TABLE SET SCREEN OFF ON TABLE SET PAUSE OFF END -RUN -GOTO BOTTOM -******************************************************************* -* PLAY WITH THE CPU UTILIZED BY THIS RUN. -* DETERMINE A BASE NUMBER FROM PREVIOUS RUNS. -SET &BASECPU = IF &MAXCHAR EQ 6 THEN 8200 ELSE - IF &MAXCHAR GT 6 THEN 65300 ELSE 1000 ; -SET &DIFF = &FOCCPU - &CPU1 ; -SET &LOWCPU = &BASECPU - (&DIFF / 10); -SET &HICPU = &BASECPU + (&DIFF / 10); -TYPE LOWCPU = &LOWCPU -TYPE HICPU = &HICPU -TYPE DIFF = &DIFF -IF (&DIFF GE &LOWCPU) AND - (&DIFF LE &HICPU) GOTO CPU_OK ELSE -IF (&DIFF GE &HICPU) GOTO CPU_HI; -CPU_LOW -TYPE CPU USED FOR PERMUTATIONS DROPPED BY MORE THAN 10% -GOTO BOTTOM -CPU_HI -TYPE CPU USED FOR PERMUTATIONS INCREASED BY MORE THAN 10% -GOTO BOTTOM -CPU_OK -TYPE CPU USED FOR PERMUTATIONS WAS WITHIN EXPECTED VALUES -GOTO BOTTOM -BOTTOM -EXIT Here’s how to get the code. After Summit, • Go to Information Builders website • Locate the Summit 2008 presentations • Locate the Core FOCUS track • Download ‘Advanced Dialog Manager’ presentation • Copy this code from this slide into a pc file • Transfer code to your FOCUS or WebFOCUS location • Execute the code -- try different words This is the top of the long object of code that appears on the slide during the presentation. This is the one to copy for execution.
Advanced Dialog Manager Thank You !