Commit 47c135bb authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

partial commit -working on commands

parent 2d1e7588
Loading
Loading
Loading
Loading
+31 −39
Original line number Diff line number Diff line
@@ -883,13 +883,13 @@ CONTAINS
  !-------------------------------------------------------------
  !> Implementation COMMAND: clear
  !! Examples:
  !!    clear [all|resolution|sample|background|data|vars]
  !!    clear run
  !!    clear [all|data|vars|resolution|sample|background]
  !!    clear run  <run>
  !!    clear slot <slot>
  !-------------------------------------------------------------
  subroutine cmd_clear()
    !
    logical :: clear_vars, clear_scan
    character(len=MAX_LINE_LENGTH) :: cwhat
    integer :: i, role, run, slot, inew, iunused

    role       = ROLE_UNDEFINED
@@ -898,40 +898,30 @@ CONTAINS
    clear_scan = .false.
    clear_vars = .false.

    cwhat = trim(chrnxt('clear', ier)) ! weird way of getting next parameter
    if (ier>0) then
        if (trim(cwhat)=='all') then
            role = ROLE_ANY
            clear_vars = .true.
        else if (trim(cwhat)=='data') then
            role = ROLE_ANY
        else if (trim(cwhat)=='vars') then
            clear_vars = .true.
        else
            role = get_data_role(tolower(trim(cwhat)))
        end if
    end if

    !
    run  = get_named_value('run   ', -1, inew)
    if ( inew>0 ) clear_scan = .true.
    slot = get_named_value('slot  ', -1, inew)
    if ( inew>0 ) clear_scan = .true.

    if (found('res')  .or. found('resolution')) role = ior(role, ROLE_REFERENCE)
    if (found('sam')  .or. found('sample')    ) role = ior(role, ROLE_SAMPLE)
    if (found('bgr')  .or. found('background')) role = ior(role, ROLE_BACKGROUND)
    if (found('data') .or. found('all'))        role = -1 ! all roles
    if (found('data') .or. found('all')) role = ROLE_ANY    ! all roles
    if (found('vars') .or. found('all')) clear_vars = .true.

    ! parse data role (using get data role)
    i = 0
    do i=1,inamf()
        if ( item_used(i) ) cycle
        role = ior(role, get_data_role(tolower(vnamef(i))))
    end do

    ! if role is anything but 0, clear a scan
    if (role/=ROLE_UNDEFINED) clear_scan = .true.

!!mmnc
    call unused( icmdus=0, ivnuse=2, irpuse=2, iretus=iunused)
    call unused( icmdus=1, ivnuse=1, irpuse=1, iretus=iunused)
    ! this is not working
    if(iunused .ne. 0) then
       call msg_error('drspine', "unknown option in command clear", ERROR_OPTION_UNKNOWN)
       return
    endif
!!mmnc


    if (.not.clear_scan .and. .not.clear_vars) then
       call msg_info("drspine", "cmd_clear: nothing to clear")
@@ -956,6 +946,7 @@ CONTAINS
       call clrudf('all') ! clear all user variables
       call set_progvar() ! restore   program variables
    end if

  end subroutine cmd_clear


@@ -972,7 +963,6 @@ CONTAINS
    integer :: nrange ! number of tof range
    integer :: i, inew
    integer :: iwhat, ibins
    type(detector_struct), pointer :: detector
    integer :: iunused
    integer, parameter :: E_PIX=1,&
                          E_TOF=2
@@ -991,7 +981,8 @@ CONTAINS
       return
    endif

    detector => instrument_parameters%detector

    associate(detector => instrument_parameters%detector) !shortcut for detector structure

    if (iwhat==0 .or. ibins==0) then ! just print
       write(output_unit,'(1x,a)') 'tof bins: '//trim(cformat_bin_struct(tbins))
@@ -1050,6 +1041,7 @@ CONTAINS
       end select
    end select bins

    end associate

!!mmnc
    call unused( icmdus=0, ivnuse=2, irpuse=2, iretus=iunused)
+11 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@

#include "linenoise.h"

#define MAX_COMMAND 256
#define MAX_COMMAND 1024

static char* historyFileName=NULL;
static char* completionList[MAX_COMMAND] = { NULL, };
@@ -65,9 +65,19 @@ fclinenoise_add(char *command)
{
  int cmdlen = strlen(command);
  char *buffer;
  int i;
  /* check if already there */
  for(i=0;i<completionListSize;i++) {
	if (strncmp(completionList[i], command, cmdlen+1)==0) {
		return 0;
	}
  }
  if ( completionListSize>=MAX_COMMAND )
    return -1;
  buffer   = malloc(cmdlen+1);
  if (buffer==NULL) return -1;
  /* adding new command */
  /* printf("addin new %s (%d)\n", command, completionListSize+1);*/
  strncpy(buffer, command, cmdlen+1);
  completionList[completionListSize] = buffer;
  completionListSize++;
+1 −0
Original line number Diff line number Diff line
@@ -2109,6 +2109,7 @@ CONTAINS
    do i=1,inames
       if(compar(vname(i),pname//' ')) then
          vused(i) = .true.
          item_used(i) =.true.
          ifound=i
          lstnam=i
          last_item = name_nr_item(i)