home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************************************
- MULTI-EDIT MACRO FILE
-
- Name: DIRLIST
-
- DIRLIST - A file list menu generator
- CREATEDIRLIST - Used by dirlist to create the list
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- *******************************************************************************}
-
- $MACRO DIRLIST;
- {*******************************************************************************
- MULTI-EDIT MACRO
-
- Name: DIRLIST
-
- Description: File list menu generator. Designed to be used with sets
- of files that contain a common extension (like .SRC or .TAG).
-
- Parameters:
- /X=n
- /Y=n
-
- /P=str Directory path and file mask (*.TAG for example);
- If no directory is specified, then the Multi-Edit
- directory is used.
-
- /T=str The title to use.
-
- /CR=n 1 = Allow create option. We assume that
- the macro will know that if the file doesn't exist,
- then it is to create it.
-
- /PROTECT=str
- Specifies a file that is to be protected from
- deletion.
-
- /COPY=str Specifies a file that is to be copied up use of the
- create option.
-
-
- /DL=n 1 = Allow delete option.
-
- /DE=n 1 = Display filename extensions.
-
- /MO=n 1 = Allow modify option.
-
- /CP=n 1 = Allow copy option.
-
- /PLAIN=1 Simple directory list.
-
- /M=str The macro to run upon selection of an item.
- This MUST be the last item in the parameter string
- (to allow for parameters to be passed to the macro).
- If this parameter does not exist, then FLIST will
- exit with RETURN_STR set to the file selected.
- RETURN_INT will equal 1 for a select or 2 for a create.
- The following parameters will automatically get passed
- to the macro being run:
- /X=n
- /Y=n
- /F=str The filename that was selected (includes path)
- Up returning from the macro, if RETURN_INT > 0 then
- FLIST will exit.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- *******************************************************************************}
-
-
- Def_Str( astr[20],TStr[120], Tstr2[120], cur_file_entry[100], path_str[80], create_str[80] );
- Def_Str( protect_str[80], event_str[20], drive_str[32] );
- Def_Int( x, y, attr, jx, jy, tbc, t_win, new_id, tcreate,tdelete, tcopy );
- Def_Int( display_ext, t_undo, tmodify, old_attr, cur_drive );
- Def_Int( event_count, column_mode, Separate_Dir );
-
- def_int( column_count, current_column, column_width, show_drives, drive_count );
-
- tbc := box_count;
- refresh := false;
- t_undo := undo_stat;
- undo_stat := false;
- t_win := window_id;
- show_drives := TRUE;
- IF show_drives THEN
- call get_drive_count;
- end;
-
- Separate_Dir := parse_int('/SD=', mparm_str);
- path_str := parse_str('/P=',mparm_str);
- if get_path(path_str) = '' then
- path_str := me_path + path_str;
- end;
-
- display_ext := parse_int('/DE=',mparm_str);
-
- tcopy := parse_int('/CP=', mparm_str );
- tcreate := parse_int('/CR=', mparm_str );
- create_str := parse_str('/COPY=', mparm_str);
- if create_str <> '' then
- if get_path(create_str) = '' then
- create_str := me_path + create_str;
- end;
- create_str := fexpand(create_str);
- end;
-
- protect_str := parse_str('/PROTECT=', mparm_str);
- if protect_str <> '' then
- if get_path(protect_str) = '' then
- protect_str := me_path + protect_str;
- end;
- protect_str := fexpand(protect_str);
- end;
-
- tdelete := parse_int('/DL=',mparm_str);
- tmodify := parse_int('/MO=',mparm_str);
- x := parse_int( '/X=', mparm_str );
- y := parse_int( '/Y=', mparm_str );
- if x = 0 then
- x := 2;
- end;
- if y = 0 then
- y := 3;
- end;
-
- column_mode := 0;
- call column_calc;
-
- column_width := 15;
- column_count := (screen_width - x - 3) / column_width;
- if column_count < 1 then
- column_count := 1;
- end;
- current_column := 1;
-
- cur_file_entry := '';
- switch_window( window_count );
- create_window;
- new_id := window_id;
-
- again:
- call generate_list;
- cur_file_entry := truncate_path(cur_file_entry);
- if display_ext = 0 then
- cur_file_entry := truncate_extension(cur_file_entry);
- end;
- again1:
- tof;
- if search_fwd(cur_file_entry,0) then
- end;
- again2:
- while box_count > tbc do
- kill_box;
- end;
-
- event_count := 4;
- event_str := '@' + str(global_int('MENU_LEVEL')) + 'FLEV';
-
- Set_Global_Str(event_str + '1', '/T=Select/K1=13/K2=28/R=1/LL=1');
- Set_Global_Str(event_str + '2', '/T=Cancel/K1=27/K2=1/R=0/LL=1');
- Set_Global_Str(event_str + '3', '/T=Display/K1=9/K2=15/R=10/LL=1');
- Set_Global_Str(event_str + '4', '/T=Dir of/K1=0/K2=64/R=6/FL=Dir');
-
- IF show_drives THEN
- cur_drive := ASCII(copy(path_str,1,1)) - 64;
- jx := 0;
- While jx < Drive_Count DO
- ++jx;
- IF str_char( drive_str, jx ) <> ' ' THEN
- IF jx = cur_drive THEN
- astr := '|254';
- ELSE
- astr := '|240';
- END;
- ++event_count;
- Set_Global_Str(event_str + str(event_count), '/T=' + CHAR(64 + jx) +
- ':/KC=' + astr + '/LL=2/K1=0/K2=0/R=' + str( 100 + jx ));
- END;
- END;
- END;
-
- IF tcreate THEN
- ++event_count;
- Set_Global_Str(event_str + str(event_count), '/T=Create/K1=0/K2=82/R=2');
- END;
-
- IF tdelete THEN
- ++event_count;
- Set_Global_Str(event_str + str(event_count), '/T=Delete/K1=0/K2=83/R=3');
- END;
-
- IF tcopy THEN
- ++event_count;
- Set_Global_Str(event_str + str(event_count), '/T=Copy/K1=0/K2=62/R=5/FL=Copy');
- END;
-
- IF tmodify THEN
- ++event_count;
- Set_Global_Str(event_str + str(event_count), '/T=Edit/K1=0/K2=61/R=4');
- END;
- tstr := time;
- RM('USERIN^WMENU /X=' + str(x) + '/Y=' + str(y) +
- '/W=25/MARK=1' +
- '/CLW=' + str(column_width) + '/CL#=' + str(column_count) +
- '/DBL=1/S=' + str(c_line) + '/CLC=' + str((c_col / column_width) + 1) +
- '/OR=' + str( c_row ) +
- '/T=' + {parse_str('/T=', mparm_str)} path_str +
- '/H=' + Parse_Str('/H=',MParm_Str) +
- '/NB=0' +
- '/EV=' + event_str + '/EV#=' + str( event_count ) +
- '/NK=1' );
- jx := 0;
- call get_file_name;
-
- {make_message('['+return_str+']'); }
- cur_file_entry := fexpand(get_path(path_str) + return_str);
- if return_int = 0 then
- goto exit;
- end;
-
- If return_int > 100 THEN
- path_str := fexpand(char( (return_int - 100) + 64 ) + ':' + truncate_path(path_str));
- goto again;
- END;
-
- {Toggle display mode}
- IF return_int = 10 THEN
- column_mode := NOT( column_mode );
- goto again;
- END;
-
- {If create was selected and create_str is not nul then we will use
- it as the template file}
- if (return_int = 2) and (create_str <> '') then
- COPY_FILE( create_str , cur_file_entry, false );
- end;
-
- {We will run the macro both on select and on INSERT. We assume that
- the macro will know that if the file doesn't exist, then it is to
- create it.}
-
- if (return_int = 1) THEN
- if copy(return_str,length(return_str),1) = '\' THEN
- cur_file_entry := '';
- path_str := fexpand(get_path(path_str) + return_str + truncate_path(path_str));
- goto again;
- END;
- IF tmodify = TRUE THEN
- return_str := cur_file_entry;
- goto exit;
- ELSE
- return_int := 2;
- END;
- END;
-
- IF (return_int = 4) OR (return_int = 2) then
- jx := xpos('/M=',mparm_str, 1);
- if jx <> 0 then
- tstr := shorten_str(copy(mparm_str,jx + 3, 254 ));
- RM( tstr + ' /X=' + str(x + 3) + '/Y=' + str(y + 2) +
- '/F=' + cur_file_entry );
- if return_int > 0 then
- goto exit;
- end;
- else
- return_str := cur_file_entry;
- goto exit;
- end;
- end;
-
- {Delete was selected here}
- if return_int = 3 then
- working;
- {Don't allow deletion of the create file or the protected file}
- if (cur_file_entry = create_str) or (cur_file_entry = protect_str) then
- RM('MEERROR^BEEPS /C=1');
- else
- del_file( cur_file_entry );
- end;
- end;
-
- {Copy file}
- IF return_int = 5 THEN
- working;
- return_str := '';
- RM('USERSTR /B=1/BL=COPY MARKED FILES TO WHERE?/H=DS/L=40/ML=120/W=40/X=' + str(x + 3) +
- '/Y=' + str(y+2));
- IF return_int THEN
- mark_pos;
- tstr2 := RETURN_STR;
- TOF;
- WHILE search_fwd('|16',0) DO
- call get_file_name;
- call Copy_File;
- END;
- ELSE
- goto again2;
- END;
- END;
-
- IF return_int = 6 THEN
- return_str := path_str;
- RM('USERSTR /B=1/BL=INPUT DIRECTORY TO DISPLAY/H=DS/L=40/ML=120/W=40/X=' + str(x + 3) +
- '/Y=' + str(y+2));
- IF return_int THEN
- path_str := return_str;
- goto again;
- ELSE
- goto again2;
- END;
- END;
- goto again;
-
-
- copy_file:
-
-
- get_file_name:
- IF column_mode = 1 THEN
- return_str := shorten_str(copy(get_line, c_col + 1, column_width - 1));
- ELSE
- return_str := shorten_str(copy(get_line, 2, 8));
- tstr := shorten_str(copy(get_line,12,3));
- IF tstr <> '' THEN
- return_str := return_str + '.' + tstr;
- END;
- IF copy(get_line,18,5) = '<DIR>' THEN
- return_str := return_str + '\';
- END;
- END;
- ret;
-
- column_calc:
- IF column_mode = 0 THEN
- column_width := 45;
- column_count := 1;
- ELSE
- column_width := 15;
- column_count := (screen_width - x - 1) / column_width;
- if column_count < 1 then
- column_count := 1;
- end;
- current_column := 1;
- END;
- RET;
-
- generate_list:
- return_str := path_str;
- if switch_win_id( new_id ) then
- end;
- call column_calc;
- RM('CreateDirList /CC=' + str( column_count ) +
- '/CW=' + str( column_width ) +
- '/CM=' + str( column_mode ) +
- '/SD=' + str( Separate_Dir ) );
- ret;
-
- get_drive_count:
- IF show_drives THEN
- R_AX := $1900;
- Intr($21);
- jy := R_AX and $00FF;
- R_DX := jy;
- R_AX := $0E00;
- Intr($21);
- jx := 0;
- drive_count := R_AX AND $00FF;
- drive_str := '';
- while jx < drive_count DO
- R_DX := jx;
- R_AX := $0E00;
- Intr($21);
- R_AX := $1900;
- Intr($21);
- IF (R_AX and $00FF) = jx THEN
- ++jx;
- drive_str := drive_str + char( jx + 64);
- ELSE
- ++jx;
- drive_str := drive_str + ' ';
- END;
- END;
- R_DX := jy;
- R_AX := $0E00;
- Intr($21);
- END;
- ret;
-
- exit:
- refresh := false;
- undo_stat := t_undo;
- if switch_win_id( new_id ) then
- delete_window;
- end;
- while box_count > tbc do
- kill_box;
- end;
- switch_win_id( t_win );
- set_global_str('!DIRLIST_PATH!', path_str );
-
- END_MACRO;
-
- $MACRO CREATEDIRLIST;
- {*******************************************************************************
- MULTI-EDIT MACRO
-
- Name: CREATEDIRLIST
-
- Description: Used by DIRLIST to create a list of files according to the desired
- directory mask.
-
- Parameters:
- Return_Str Contains the directory mask. Defaults to *.*
- /CC= The number of desired columns in the list.
- /CW= The width of the columns in the list.
- /CM=
- /SD=
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- *******************************************************************************}
-
- def_int(old_attr,
- current_column, column_count, column_width, column_mode,
- Separate_Dir );
-
- return_str := fexpand( return_str );
- if truncate_path(return_str) = '' THEN
- return_str := return_str + '*.*';
- END;
- column_count := parse_int( '/CC=', mparm_str );
- column_width := parse_int( '/CW=', mparm_str );
- column_mode := parse_int( '/CM=', mparm_str );
- Separate_Dir := parse_int( '/SD=', mparm_str );
- current_column := 0;
- old_attr := File_Search_Attr;
- File_Search_Attr := $31;
-
- refresh := false;
- working;
- erase_window;
- tof;
- entry_mode := column_mode;
- IF Separate_Dir THEN
- get_directory_list( Get_Path(return_str) + '*.*', 'N', 1 );
- IF error_level <> 0 THEN
- rm( 'meerror' );
- error_level := 0;
- goto exit;
- END;
- call build_list;
- File_Search_Attr := $21;
- END;
- get_directory_list( return_str, '', 0 );
- IF error_level <> 0 THEN
- rm( 'meerror' );
- error_level := 0;
- goto exit;
- END;
- call build_list;
-
- tof;
- File_Search_Attr := old_attr;
- goto exit;
-
- build_list:
- if first_Entry = 0 then
- goto build_exit;
- end;
- build_loop:
- ++current_column;
- IF (current_column > column_count) THEN
- down;
- current_column := 1;
- END;
- goto_col( (column_width * (current_column - 1)) + 2 );
- text( Entry_Name );
- get_next_file:
- if Next_ENTRY then
- goto build_loop;
- end;
- build_exit:
- RET;
-
- EXIT:
-
- END_MACRO;