! ! ! MKISM.BAS ... program to build and execute a command file which will ! allocate a new ISAM file. ! ! Utilizes the empty index block calculations outlined in the article: ! "ISAM: Calculating the Number of Empty Index Blocks" ! - AMSD Journal, November, 1985 ! ! Author: Creed Erickson ! Computer Systems Plus, Inc. ! 1630 Manheim Pike ! Lancaster, Pa. 17601 ! (717)-560-0140 ! ! This program is released to the public domain on 12-June-1986. ! The author assumes no liability for use of this program for any purpose. ! ! edit history (latest first): ! ! [001] New code. 12-Jun-86 / CAE ! program MKISM,1.0(1) map1 STRINGS map2 ISAM'FILE'NAME, S,6 ! name of file to build map2 IS'PRIMARY, S,1 ! primary index? (Y/N) map2 DATA'FILE'DEVN, S,7 ! data file device and drive map2 SECONDARY'INDEX'NAME,S,6 ! secondary index file spec map2 LOAD'FROM'FILE, S,30 ! sequential load file spec map1 REALS map2 KEY'SIZE, F,6 ! user key size map2 KEY'POSITION, F,6 ! position of key within rec map2 RECORD'SIZE, F,6 ! size of data file record map2 NUMBER'OF'RECS, F,6,100 ! number of records to allocate map2 ACTUAL'KEYSIZ, F,6 ! actual size of key on disk map2 DIRECTORY'ENTRY'SIZE,F,6 ! size of ISAM directory entry map2 BLOCKING'FACTOR, F,6 ! # of ISAM directory entries per disk block map2 HALF'FACTOR, F,6 ! one-half of the above number map2 N, F,6 ! work variable map2 FIRST'LEVEL, F,6 !--+ map2 SECOND'LEVEL, F,6 ! \ map2 THIRD'LEVEL, F,6 ! \ map2 FILE'SIZE, F,6 ! >>>--- see referenced article map2 TOP'LEVEL, F,6 ! / map2 MIDDLE'LEVEL, F,6 ! / map2 BOTTOM'LEVEL, F,6 ! / map2 SMALL'SIZE, F,6 !-+ map2 EMPTY'IDX'BLOCKS, F,6 ! # empty index blocks to allocate print "Make ISAM file utility." input line "Name of file to be built ";ISAM'FILE'NAME input line "Size of key "; KEY'SIZE input line "Position of key ";KEY'POSITION input line "Size of record ";RECORD'SIZE input line "Number of records to allocate ";NUMBER'OF'RECS if (KEY'SIZE/2) = int(KEY'SIZE/2) then & ACTUAL'KEYSIZ = KEY'SIZE & else ACTUAL'KEYSIZ = KEY'SIZE + 1 DIRECTORY'ENTRY'SIZE = ACTUAL'KEYSIZ + 4 BLOCKING'FACTOR = int(508/DIRECTORY'ENTRY'SIZE) HALF'FACTOR = int(BLOCKING'FACTOR/2) N = int((NUMBER'OF'RECS-BLOCKING'FACTOR+1)/HALF'FACTOR) THIRD'LEVEL = (N+1) MAX 1 N = int((THIRD'LEVEL-BLOCKING'FACTOR)/HALF'FACTOR) SECOND'LEVEL = (N+1) MAX 1 N = int((SECOND'LEVEL-BLOCKING'FACTOR)/HALF'FACTOR) FIRST'LEVEL = (N+1) MAX 1 FILE'SIZE = FIRST'LEVEL + SECOND'LEVEL + THIRD'LEVEL BOTTOM'LEVEL = int(NUMBER'OF'RECS/BLOCKING'FACTOR) if BOTTOM'LEVEL <> (NUMBER'OF'RECS/BLOCKING'FACTOR) then & BOTTOM'LEVEL = BOTTOM'LEVEL + 1 MIDDLE'LEVEL = int(BOTTOM'LEVEL/BLOCKING'FACTOR) if MIDDLE'LEVEL <> (BOTTOM'LEVEL/BLOCKING'FACTOR) then & MIDDLE'LEVEL = MIDDLE'LEVEL + 1 TOP'LEVEL = int(MIDDLE'LEVEL/BLOCKING'FACTOR) if TOP'LEVEL <> (MIDDLE'LEVEL/BLOCKING'FACTOR) then & TOP'LEVEL = TOP'LEVEL + 1 SMALL'SIZE = TOP'LEVEL + MIDDLE'LEVEL + BOTTOM'LEVEL EMPTY'IDX'BLOCKS = FILE'SIZE - SMALL'SIZE print str(EMPTY'IDX'BLOCKS);" empty index blocks will be allocated" input line "Primary directory? ";IS'PRIMARY IS'PRIMARY = ucs(IS'PRIMARY) input line "Data file device: ";DATA'FILE'DEVN if IS'PRIMARY = "N" then & input line "Secondary index: ";SECONDARY'INDEX'NAME INPUT LINE "Load from file: ";LOAD'FROM'FILE open #1, "MKISM.CMD", output print #1, ":S" print #1, "ERASE MKISM.CMD" print #1, "ISMBLD "+ISAM'FILE'NAME print #1, str(KEY'SIZE) print #1, str(KEY'POSITION) print #1, str(RECORD'SIZE) print #1, str(NUMBER'OF'RECS) print #1, str(EMPTY'IDX'BLOCKS) print #1, IS'PRIMARY print #1, DATA'FILE'DEVN if IS'PRIMARY = "N" then print #1, SECONDARY'INDEX'NAME print #1, LOAD'FROM'FILE print #1, ":R" close #1 chain "MKISM.CMD"