/* UPDTIDX.CMD * Install a language-specific theme index file, merging it with any existing * one if necessary. * * SYNTAX: updtidx * where: * is the two-letter language code * is the name of the index file being installed * is the directory where the new theme index is to be placed */ CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs' CALL SysLoadFuncs PARSE UPPER ARG cur_lang source_index target IF cur_lang == '' | source_index == '' | target == '' THEN RETURN 0 IF STREAM( source_index, 'C', 'QUERY EXISTS') == '' THEN RETURN 2 target_index = STREAM( target'\THEMES.'cur_lang, 'C', 'QUERY EXISTS') IF target_index == '' & cur_lang == 'EN' THEN target_index = STREAM( target'\THEMES.LST', 'C', 'QUERY EXISTS') /* If the target index file doesn't exist, just copy the new one into place. */ IF target_index == '' THEN DO '@copy' source_index target '>nul' RETURN 0 END /* Read all themes defined in the source index file. These themes are to be * added to the target index file if (and only if) necessary. */ i = 0 CALL LINEIN source_index, 1, 0 DO WHILE LINES( source_index ) theme_def = STRIP( LINEIN( source_index )) IF theme_def == '' THEN ITERATE fc = LEFT( theme_def, 1 ) IF fc == '#' | fc == ';' THEN ITERATE i = i + 1 new_themes.i = theme_def END CALL STREAM source_index, 'C', 'CLOSE' new_themes.0 = i /* Now check the target index file for any themes with the same ID as one in * our set of themes to add; skip all those which are found. Any others are * to be appended to the target file. */ total = 0 DO i = 1 TO new_themes.0 PARSE UPPER VAR new_themes.i theme_id ';' . id_len = LENGTH( theme_id ) id_exists = 0 ok = SysFileSearch( theme_id';', target_index, 'matches.') IF ok == 0 THEN DO j = 1 TO matches.0 IF TRANSLATE( LEFT( matches.j, id_len+1 ) == theme_id';') THEN DO id_exists = 1 LEAVE END END IF id_exists == 1 THEN ITERATE total = total + 1 add_themes.total = new_themes.i END add_themes.0 = total DO i = 1 TO add_themes.0 CALL LINEOUT target_index, add_themes.i END CALL STREAM target_index, 'C', 'CLOSE' RETURN 0