/* ADDTHEME.CMD * Install a theme by adding it to the theme index files for all known * languages. The theme files must already be unpacked into the proper * directory structure. * * SYNTAX: addtheme * where: * is the directory where the theme files are located * is the directory where the theme index is located */ CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs' CALL SysLoadFuncs CALL RxFuncAdd 'VRParseFileName', 'VROBJ.DLL', 'VRParseFileName' ARG theme_src target IF theme_src == '' | target == '' THEN RETURN 0 /* Read the English definition to use as a default */ en_id = '' en_name = '' en_desc = '' IF STREAM( theme_src'\EN.LST', 'C', 'QUERY EXISTS') <> '' THEN DO CALL ParseThemeDef theme_src'\EN.LST' en_id = t_id en_name = t_name en_desc = t_desc END idx_langs.0 = 0 CALL SysFileTree target'\THEMES.*', 'idx_langs.', 'FO' DO i = 1 TO idx_langs.0 idx_langs.i = TRANSLATE( idx_langs.i ) cur_lang = VRParseFileName( idx_langs.i, 'E') IF cur_lang == 'LST' THEN cur_lang = 'EN' IF STREAM( theme_src'\'cur_lang'.LST', 'C', 'QUERY EXISTS') <> '' THEN DO CALL ParseThemeDef theme_src'\'cur_lang'.LST' IF en_id == '' THEN en_id = t_id IF en_name == '' THEN en_name = t_name IF en_desc == '' THEN en_desc = t_desc /* Make sure this theme doesn't already exist in the index file */ id_len = LENGTH( t_id';') id_exists = 0 ok = SysFileSearch( t_id';', idx_langs.i, 'lines.') IF ok == 0 THEN DO j = 1 TO lines.0 IF TRANSLATE( LEFT( lines.j, id_len ) == t_id';') THEN DO id_exists = 1 LEAVE END END IF id_exists == 1 THEN ITERATE CALL LINEOUT idx_langs.i, t_id';'t_name';'t_desc END ELSE IF en_id <> '' THEN CALL LINEOUT idx_langs.i, en_id';'en_name';'en_desc CALL LINEOUT idx_langs.i END RETURN 1 ParseThemeDef: PROCEDURE EXPOSE t_id t_name t_desc ARG index_file t_id = '' t_name = '' t_desc = '' CALL LINEIN index_file, 1, 0 DO WHILE LINES( index_file ) theme_def = STRIP( LINEIN( index_file )) IF theme_def == '' THEN ITERATE fc = LEFT( theme_def, 1 ) IF fc == '#' | fc == ';' THEN ITERATE PARSE VAR theme_def t_id ';' t_name ';' t_desc IF t_name <> '' THEN LEAVE END CALL STREAM index_file, 'C', 'CLOSE' t_id = TRANSLATE( t_id ) RETURN