function value=getparam(parametername,Info,display);

%GETPARAM   Get parameter from Info vector by name
%
%   value=GETPARAM(parametername,Info,display);
%
%   Inputs: parametername - string containing name of the
%                           desired parameter.
%           Info          - Info vector from READINFO
%           display       - optional flag. Set display=0 to 
%                           aviod display of warning messages.
%                           (default: display=1)
%
%   Output: value - value of the requested parameter
%
%   The function is case insensitive, uppercase letters
%   are converted to lowercase in the function.
%   Use DISPINFO to get a complete display of parameters
%   in the vector and their names.
%
%   If the Info vector is not valid, or if the requested
%   parameter is not found, the function returns 0. 
%   
%   Some parameters not found in the EchoPAC file are 
%   also set = 0 by READINFO.
%
%   See also: READINFO, DISPINFO, READECHO

% (c) GE Vingmed Ultrasound 1997-99. All rights reserved
% Written by: JK, 24.09.96
% Last update: 10.11.1997, JK

if nargin<2, error('Too few input parameters');end;
if nargin<3, display=1;end;

if ~isstr(parametername), 
    error('Parametername must be a string');
end;

name=lower(parametername);
value=0;

%% Isinfo:
isinfobool=0;
InfoCand=Info(:)';
M=length(Info);
S=0;
if M>S+13,
    status=InfoCand(1:17);
    S=S+17;
    if M>S+1,
        FilenameLength=InfoCand(S+1);
        S=S+1+FilenameLength;
        S=S+11;
        S=S+sum( (~(~status)).*[18 22 22 7 9 9 17 23 23 19 2 InfoCand(13) 0 0 0 0 InfoCand(17)] );
        if M>S+1,
            BlocksInFile=InfoCand(S+1);
            S=S+1+(4*BlocksInFile);
            if S==M,
                isinfobool=1;
            end;
        end;
    end;
end;

if strcmp(name,'isinfo'),
    value=isinfobool;
    return;
end;

if ~isinfobool,
    error('Info must be a valid Info vector from readinfo');
end;

stringflag=0; %true for strings
evalflag=0; %true for evaluated parameters
c=1540; %sound velocity

N=0;
P=0;

%% Read status field:
    Tissue    =Info(1) ;Flow      =Info(2) ;sectIQ    =Info(3);
    MTissue   =Info(4) ;MFlow     =Info(5) ;MIQ       =Info(6);
    LinTissue =Info(7) ;LinFlow   =Info(8) ;LinIQ     =Info(9);
    Spect     =Info(10);Sync      =Info(11);RFPar     =Info(12);
    RFlength  =Info(13);RGBdump   =Info(14);ScreenDump=Info(15);
    MovieInfo =Info(16);PatientInfo=Info(17);
    if strcmp(name,'tissue'), N=P+1;end;
    if strcmp(name,'flow'), N=P+2;end;
    if strcmp(name,'sectiq'), N=P+3;end;
    if strcmp(name,'mtissue'), N=P+4;end;
    if strcmp(name,'mflow'), N=P+5;end;
    if strcmp(name,'miq'), N=P+6;end;
    if strcmp(name,'lintissue'), N=P+7;end;
    if strcmp(name,'linflow'), N=P+8;end;
    if strcmp(name,'liniq'), N=P+9;end;
    if strcmp(name,'spect'), N=P+10;end;
    if strcmp(name,'sync'), N=P+11;end;
    if strcmp(name,'rfpar'), N=P+12;end;
    if strcmp(name,'rflength'), N=P+13;end;
    if strcmp(name,'rgbdump'), N=P+14;end;
    if strcmp(name,'screendump'), N=P+15;end;
    if strcmp(name,'movieinfo'), N=P+16;end;
    if strcmp(name,'patientinfo'), N=P+17;end;
    P=P+17;

%% Read filename
    FilenameLength=Info(P+1);
    P=P+1;
    if (strcmp(name,'filename')),N=[P+1:P+FilenameLength];stringflag=1;end;
    filename=setstr(Info([P+1:P+FilenameLength]));
    P=P+FilenameLength;

%% Check if the file is currently open, find its fid:
    if strcmp(name,'fid'),
        value=[];
        evalflag=1;
        openfids=fopen('all');
        if any(openfids),
            for n=1:length(openfids);
                [fidfilename,machine,permission]=fopen(openfids(n));
                if strcmp(lower(fidfilename),lower(filename)),
                    value=[value, openfids(n)];
                end;
            end;        
        end;
    end;

%% Read filelength
    if strcmp(name,'filelength'),N=P+1;end;
    P=P+1;

%% Date and time
    if( strcmp(name,'year')), N=P+1;end;
    if( strcmp(name,'month')), N=P+2;end;
    if( strcmp(name,'day')), N=P+3;end;
    if( strcmp(name,'date')),
        value=[];
        if (Info(P+1)<10),value=[value,'0'];end;
        value=[value,num2str(Info(P+1)),'/'];
        if (Info(P+2)<10),value=[value,'0'];end;
        value=[value,num2str(Info(P+2)),'/'];
        if (Info(P+3)<10),value=[value,'0'];end;
        value=[value,num2str(Info(P+3))];
        evalflag=1;
    end;
    if( strcmp(name,'hour')), N=P+4;end;
    if( strcmp(name,'minute')), N=P+5;end;
    if( strcmp(name,'min')), N=P+5;end;
    if( strcmp(name,'second')), N=P+6;end;
    if( strcmp(name,'sec')), N=P+5;end;
    if( strcmp(name,'time')),
        value=[];
        if (Info(P+4)<10),value=[value,'0'];end;
        value=[value,num2str(Info(P+4)),':'];
        if (Info(P+5)<10),value=[value,'0'];end;
        value=[value,num2str(Info(P+5)),':'];
        if (Info(P+6)<10),value=[value,'0'];end;
        value=[value,num2str(Info(P+6))];
        evalflag=1;
    end;

    P=P+6;

%%PatientInfo
    if PatientInfo,
        Date=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        PatientID=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        OperatorID=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        SiteID=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        ScanType=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        ScanVersion=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        TypeOfMeasurement=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        Application=Info(P+2:P+1+Info(P+1));P=P+Info(P+1)+1;
        
        if strcmp(name,'patient'),value=PatientID;evalflag=1;stringflag=1;end;
        if strcmp(name,'patientid'),value=PatientID;evalflag=1;stringflag=1;end;
        if strcmp(name,'operator'),value=OperatorID;evalflag=1;stringflag=1;end;
        if strcmp(name,'operatorid'),value=OperatorID;evalflag=1;stringflag=1;end;
        if strcmp(name,'site'),value=SiteID;evalflag=1;stringflag=1;end;
        if strcmp(name,'siteid'),value=SiteID;evalflag=1;stringflag=1;end;
        if strcmp(name,'scanner'),value=ScanType;evalflag=1;stringflag=1;end;
        if strcmp(name,'scantype'),value=ScanType;evalflag=1;stringflag=1;end;
        if strcmp(name,'version'),value=ScanVersion;evalflag=1;stringflag=1;end;
        if strcmp(name,'scanversion'),value=ScanVersion;evalflag=1;stringflag=1;end;
        if strcmp(name,'measurement'),value=TypeOfMeasurement;evalflag=1;stringflag=1;end;
        if strcmp(name,'typeofmeasurement'),value=TypeOfMeasurement;evalflag=1;stringflag=1;end;
        if strcmp(name,'application'),value=Application;evalflag=1;stringflag=1;end;
        if strcmp(name,'applicationname'),value=Application;evalflag=1;stringflag=1;end;
    end;

%% Timeslice
    Timeslice=Info(P+1);
    if( strcmp(name,'timeslice')),N=P+1;end;
    P=P+1;

%% Probe frequencies
    if(strcmp(name,'tpfrequency')),N=P+1;end;
    if(strcmp(name,'txfreq'     )),N=P+1;end;
    if(strcmp(name,'fpfrequency')),N=P+2;end;
    %if(strcmp(name,'txfreqf')),N=P+2;end;
    %if(strcmp(name,'txfreqiq')),N=P+2;end;
    if(strcmp(name,'spfrequency')),N=P+3;end;
    fpfreq=Info(P+2);
    P=P+3;

%% RF parameters
if RFPar>0,
    M=0;Q=0;
    if( strcmp(name,'probename')), M=[Q+2:Q+1+Info(P+Q+1)];stringflag=1;end;
    Q=Q+1+Info(P+Q+1);
    if( strcmp(name,'fprobe')), M=Q+1;end;
    if( strcmp(name,'fburst')), M=Q+2;end;
    fburst=Info(P+Q+2);
    if( strcmp(name,'tburst')), M=Q+3;end;
    if( strcmp(name,'nburst')), evalflag=1;value=round(Info(P+Q+2)*Info(P+Q+3)*2);end;
    if( strcmp(name,'xmitamplitude')), M=Q+4;end;
    if( length(findstr(name,'interleavefactor'))>0), M=Q+5;end;
    if( strcmp(name,'mlas')), M=Q+6;end;
    if( strcmp(name,'prf')), M=Q+7;end;
    if( strcmp(name,'spr')), M=Q+8;end;
    if( strcmp(name,'framerate')), M=Q+9;end;
    Q=Q+9;
    if( strcmp(name,'demodfrequency')), M=[Q+2:Q+1+Info(P+Q+1)];end;
    if( strcmp(name,'freq')), M=[Q+2:Q+1+Info(P+Q+1)];end;
    if( strcmp(name,'fdemod')), M=Q+2;end;
    if( strcmp(name,'fdemodiq')), M=Q+2;end;
    if( strcmp(name,'fdemodf')), M=Q+2;end;
    Q=Q+1+Info(P+Q+1);
    if( strcmp(name,'tgc')), M=[Q+2:Q+Info(P+Q+1)];end;
    Q=Q+1+Info(P+Q+1);
    if( strcmp(name,'atgc')), M=[Q+2:Q+Info(P+Q+1)];end;
    Q=Q+1+Info(P+Q+1);
    if( strcmp(name,'tgcdepth')), M=[Q+2:Q+Info(P+Q+1)];end;
    Q=Q+1+Info(P+Q+1);
    if( strcmp(name,'atgcdepth')), M=[Q+2:Q+Info(P+Q+1)];end;
    Q=Q+1+Info(P+Q+1);
    if( length(findstr(name,'inputdecimation'))>0), M=Q+1;end;
    if( length(findstr(name,'inputwritedecimation'))>0), M=Q+2;end;
    if( strcmp(name,'dynrange')), M=Q+3;end;
    if( strcmp(name,'feflowgain')), M=Q+4;end;
    if( strcmp(name,'roispan')), M=Q+5;end;
    if( strcmp(name,'roicenter')), M=Q+6;end;
    if( strcmp(name,'precompress')), M=Q+7;end;
    if( strcmp(name,'hp')), M=Q+7;end;
    if( strcmp(name,'hp_tis')), M=Q+7;end;
    if( strcmp(name,'flowtype')), M=Q+8;end;
    if( strcmp(name,'heartrate')), M=Q+9;end;
    
    if any(M),
        N=P+M;
    end;
    P=P+RFlength;
end;

if(strcmp(name,'txfreqf')|strcmp(name,'txfreqiq')),
    value=fpfreq;
        
    if ~fpfreq,
        eval('value=fburst;','value=0;');
    end;
    evalflag=1;
end;
        
if Tissue>0,
    M=0;
    if( strcmp(name,'startdepth')), M=1;end;
    if( strcmp(name,'depthincrement')), M=2;end;
    if( strcmp(name,'depthincr')), M=2;end;
    if( strcmp(name,'frs')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'fradsamp')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'startangle')), M=3;end;
    if( strcmp(name,'angleincrement')), M=4;end;
    if( strcmp(name,'angleincr')),M=4;end;
    if( strcmp(name,'acqtimeline')), M=5;end;
    if( strcmp(name,'samples')), M=6;end;
    if( strcmp(name,'beams')), M=7;end;
    if( strcmp(name,'datasize')), M=8;end;
    if( strcmp(name,'comprej')), M=9;end;
    if( strcmp(name,'gaintgc')), M=[10:17];end;
    
    if( strcmp(name,'frames')), M=18;end;
    if any(M),
        N=P+M;
    end;
    P=P+18;
end;

if Flow>0,
    M=0;
    if( strcmp(name,'startdepthf')), M=1;end;
    if( strcmp(name,'depthincrementf')), M=2;end;
    if( strcmp(name,'depthincrf')), M=2;end;
    if( strcmp(name,'frsf')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'fradsampf')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'startanglef')), M=3;end;
    if( strcmp(name,'angleincrementf')), M=4;end;
    if( strcmp(name,'angleincrf')), M=4;end;
    if( strcmp(name,'acqtimelinef')), M=5;end;
    if( length(findstr(name,'nyquistvelocityf'))>0), M=6;end;
    %if( strcmp(name,'prf')), evalflag=1; value=4*fpfreq*Info(P+6)/c;end;
    if( length(findstr(name,'rpbf'))>0), M=7;end;
    if( strcmp(name,'samplesf')), M=7;end;
    if( length(findstr(name,'bpff'))>0), M=8;end;
    if( strcmp(name,'beamsf')), M=8;end;
    if( strcmp(name,'datasizef')), M=9;end;
    if( strcmp(name,'mappingtypef')), M=10;end;
    if( strcmp(name,'intensityincrf')), M=11;end;
    if( strcmp(name,'compressionf')), M=12;end;
    if( strcmp(name,'rejectf')), M=13;end;
    if( strcmp(name,'overallgainf')), M=14;end;
    if( strcmp(name,'tgcf')), M=[15:20];end;
    
    if( strcmp(name,'framesf')), M=21;end;
    if( strcmp(name,'sprf')), M=22;end;
    if( length(findstr(name,'packetsize'))>0), M=22;end;
    if any(M),
        N=P+M;
    end;
    P=P+22;
end;

if sectIQ>0,
    M=0;
    if( strcmp(name,'startdepthf')), M=1;end;
    if( strcmp(name,'depthincrementf')), M=2;end;
    if( strcmp(name,'depthincrf')), M=2;end;
    if( strcmp(name,'frsf')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'fradsampf')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'startanglef')), M=3;end;
    if( strcmp(name,'angleincrementf')), M=4;end;
    if( strcmp(name,'angleincrf')), M=4;end;
    if( strcmp(name,'acqtimelinef')), M=5;end;
    if( length(findstr(name,'nyquistvelocityf'))>0), M=6;end;
    %if( strcmp(name,'prf')), evalflag=1; value=4*fpfreq*Info(P+6)/c;end;
    if( length(findstr(name,'rpbf'))>0), M=7;end;
    if( strcmp(name,'samplesf')), M=7;end;
    if( length(findstr(name,'bpff'))>0), M=8;end;
    if( strcmp(name,'beamsf')), M=8;end;
    if( strcmp(name,'datasizef')), M=9;end;
    if( strcmp(name,'mappingtypef')), M=10;end;
    if( strcmp(name,'intensityincrf')), M=11;end;
    if( strcmp(name,'compressionf')), M=12;end;
    if( strcmp(name,'rejectf')), M=13;end;
    if( strcmp(name,'overallgainf')), M=14;end;
    if( strcmp(name,'tgcf')), M=[15:20];end;

    if( strcmp(name,'framesf')), M=21;end;
    if( strcmp(name,'sprf')), M=22;end;
    if( length(findstr(name,'packetsize'))>0), M=22;end;

    if( strcmp(name,'startdepthiq')), M=1;end;
    if( strcmp(name,'depthincrementiq')), M=2;end;
    if( strcmp(name,'depthincriq')), M=2;end;
    if( strcmp(name,'frsiq')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'fradsampiq')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'startangleiq')), M=3;end;
    if( strcmp(name,'angleincrementiq')), M=4;end;
    if( strcmp(name,'angleincriq')), M=4;end;
    if( strcmp(name,'acqtimelineiq')), M=5;end;
    if( length(findstr(name,'nyquistvelocityiq'))>0), M=6;end;
    %if( strcmp(name,'prf')),evalflag=1; value=4*fpfreq*Info(P+6)/c; end;
    if( length(findstr(name,'rpbiq'))>0), M=7;end;
    if( strcmp(name,'samplesiq')), M=7;end;
    if( length(findstr(name,'bpfiq'))>0), M=8;end;
    if( strcmp(name,'beamsiq')), M=8;end;
    if( strcmp(name,'datasizeiq')), M=9;end;
    if( strcmp(name,'mappingtypeiq')), M=10;end;
    if( strcmp(name,'intensityincriq')), M=11;end;
    if( strcmp(name,'compressioniq')), M=12;end;
    if( strcmp(name,'rejectiq')), M=13;end;
    if( strcmp(name,'overallgainiq')), M=14;end;
    if( strcmp(name,'tgciq')), M=[15:20];end;
   
    if( strcmp(name,'framesiq')), M=21;end;
    if( length(findstr(name,'spriq'))>0), M=22;end;
    if( length(findstr(name,'packetsize'))>0), M=22;end;
    if any(M),
        N=P+M;
    end;
    P=P+22;
end;

if MTissue>0,
    M=0;
    if( strcmp(name,'mmstartdepth')), M=1;end;
    if( strcmp(name,'mmdepthincrement')), M=2;end;
    if( strcmp(name,'mmfrs')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'mmfradsamp')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'mmdepthincr')), M=2;end;
    if( strcmp(name,'mmbeamangle')), M=3;end;
    if( strcmp(name,'mmacqtimeline')), M=4;end;
    if( strcmp(name,'mmsamples')), M=5;end;
    if( strcmp(name,'mmframes')), M=6;end;
    if( strcmp(name,'mmbeams')), M=7;end;
    if M~=0,
        N=P+M;
    end;
    P=P+7;
end;

if MFlow>0,
    M=0;
    if( strcmp(name,'mmstartdepthf')), M=1;end;
    if( strcmp(name,'mmdepthincrementf')), M=2;end;
    if( strcmp(name,'mmfrsf')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'mmfradsampf')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'mmdepthincrf')), M=2;end;
    if( strcmp(name,'mmbeamanglef')), M=3;end;
    if( strcmp(name,'mmacqtimelinef')), M=4;end;
    if( length(findstr(name,'mmnyquistvelocityf'))>0), M=5;end;
    %if( strcmp(name,'prf')),evalflag=1; value=4*fpfreq*Info(P+5)/c;end;
    if( strcmp(name,'mmsamplesf')), M=6;end;
    if( strcmp(name,'mmrpbf')), M=6;end;
    if( strcmp(name,'mmrpb')), M=6;end;
    if( strcmp(name,'mmframesf')), M=7;end;
    if( strcmp(name,'mmbeamsf')), M=8;end;
    if( strcmp(name,'mmbpf')), M=8;end;
    if( strcmp(name,'mmsprf')), M=9;end;
    if( length(findstr(name,'mmpacketsize'))>0), M=9;end;
    if M~=0,
        N=P+M;
    end;
    P=P+9;
end;

if MIQ>0, %Nonexisting mode?
    M=0;
    if( strcmp(name,'mmstartdepthiq')), M=1;end;
    if( strcmp(name,'mmdepthincrementiq')), M=2;end;
    if( strcmp(name,'mmfrsiq')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'mmfradsampiq')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'mmdepthincriq')), M=2;end;
    if( strcmp(name,'mmbeamangleiq')), M=3;end;
    if( strcmp(name,'mmacqtimelineiq')), M=4;end;
    if( length(findstr(name,'mmnyquistvelocityiq'))>0), M=5;end;
    %if( strcmp(name,'prf')),evalflag=1; value=4*fpfreq*Info(P+5)/c;end;
    if( strcmp(name,'mmsamplesiq')), M=6;end;
    if( strcmp(name,'mmrpbiq')), M=6;end;
    if( strcmp(name,'mmrpb')), M=6;end;
    if( strcmp(name,'mmframesiq')), M=7;end;
    if( strcmp(name,'mmbeamsiq')), M=8;end;
    if( strcmp(name,'mmbpfiq')), M=8;end;
    if( length(findstr(name,'mmspriq'))>0), M=9;end;
    if( length(findstr(name,'mmpacketsize'))>0), M=9;end;
    if M~=0,
        N=P+M;
    end;
    P=P+9;
end;

if LinTissue>0,
    M=0;
    if( strcmp(name,'startdepth')), M=1;end;
    if( strcmp(name,'depthincrement')), M=2;end;
    if( strcmp(name,'frs')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'fradsamp')),evalflag=1;value=c/(2*Info(P+2));end;
    if( strcmp(name,'width')), M=3;end;
    if( strcmp(name,'angle')), M=4;end;
    if( strcmp(name,'acqtimeline')), M=5;end;
    if( strcmp(name,'samples')), M=6;end;
    if( strcmp(name,'beams')), M=7;end;
    %if( length(findstr(name,'frames'))>0), M=8;end;
    if( strcmp(name,'beams')), M=7;end;
    if( strcmp(name,'comprej')), M=8;end;
    if( strcmp(name,'gaintgc')), M=[9:16];end;
    if( strcmp(name,'frames')), M=17;end;
    if any(M),
        N=P+M;
    end;
    P=P+17;
end;

if LinFlow>0,
    M=0;
    if( strcmp(name,'startdepthf')), M=1;end;
    if( length(findstr(name,'beamlengthf'))>0), M=2;end;
    if( strcmp(name,'frsf')),evalflag=1;value=c/(2*(Info(P+2)/Info(P+8)));end;
    if( strcmp(name,'fradsampf')),evalflag=1;value=c/(2*(Info(P+2)/Info(P+8)));end;
    if( strcmp(name,'depthincrementf')), evalflag=1;value=Info(P+2)/Info(P+8);end;
    if( length(findstr(name,'relhorizontaloffset'))>0), M=3;end;
    if( strcmp(name,'anglef')), M=4;end;
    if( strcmp(name,'widthf')), M=5;end;
    if( strcmp(name,'acqtimelinef')), M=6;end;
    if( length(findstr(name,'nyquistvelocityf'))>0), M=7;end;
    %if( strcmp(name,'prf')),evalflag=1; value=4*fpfreq*Info(P+7)/c;end;
    if( length(findstr(name,'rpbf'))>0), M=8;end;
    if( strcmp(name,'samplesf')), M=8;end;
    if( length(findstr(name,'bpff'))>0), M=9;end;
    if( strcmp(name,'beamsf')), M=9;end;
    if( strcmp(name,'datasizef')), M=10;end;
    if( strcmp(name,'mappingtypef')), M=11;end;
    if( strcmp(name,'intensityincrf')), M=12;end;
    if( strcmp(name,'overallgainf')), M=13;end;
    if( strcmp(name,'comressf')), M=14;end;
    if( strcmp(name,'rejectf')), M=15;end;
    if( strcmp(name,'tgcf')), M=[16:21];end;
    if( strcmp(name,'framesf')),M=22;end;
    if( strcmp(name,'sprf')), M=23;end;
    if( length(findstr(name,'packetsize'))>0), M=23;end;
    if any(M),
        N=P+M;
    end;
    P=P+23;
end;

if LinIQ>0,
    M=0;
    if( strcmp(name,'startdepthiq')), M=1;end;
    if( length(findstr(name,'beamlengthiq'))>0), M=2;end;
    if( strcmp(name,'depthincrementiq')), evalflag=1;value=Info(P+2)/Info(P+8);end;
    if( strcmp(name,'frsiq'))>0,evalflag=1;value=c/( 2*(Info(P+2)/Info(P+8)) );end;
    if( strcmp(name,'fradsampiq'))>0,evalflag=1;value=c/( 2*(Info(P+2)/Info(P+8)) );end;
    if( length(findstr(name,'relhorizontaloffset'))>0), M=3;end;
    if( strcmp(name,'angleiq')), M=4;end;
    if( strcmp(name,'widthiq')), M=5;end;
    if( strcmp(name,'acqtimelineiq')), M=6;end;
    if( length(findstr(name,'nyquistvelocityiq'))>0), M=7;end;
    %if( strcmp(name,'prf')),evalflag=1; value=4*fpfreq*Info(P+7)/c;end;
    if( length(findstr(name,'rpbiq'))>0), M=8;end;
    if( strcmp(name,'samplesiq')), M=8;end;
    if( length(findstr(name,'bpfiq'))>0), M=9;end;
    if( strcmp(name,'beamsiq')), M=9;end;
    if( strcmp(name,'datasizeiq')), M=10;end;
    if( strcmp(name,'mappingtypeiq')), M=11;end;
    if( strcmp(name,'intensityincriq')), M=12;end;
    if( strcmp(name,'overallgainiq')), M=13;end;
    if( strcmp(name,'comressiq')), M=14;end;
    if( strcmp(name,'rejectiq')), M=15;end;
    if( strcmp(name,'tgciq')), M=[16:21];end;

    if( strcmp(name,'framesiq')),M=22;end;
    if( length(findstr(name,'spriq'))>0), M=23;end;
    if( length(findstr(name,'packetsize'))>0), M=23;end;

    if( strcmp(name,'startdepthf')), M=1;end;
    if( length(findstr(name,'beamlengthf'))>0), M=2;end;
    if( strcmp(name,'depthincrementf')), evalflag=1;value=Info(P+2)/Info(P+8);end;
    if( strcmp(name,'frsf')),evalflag=1;value=c/(2*(Info(P+2)/Info(P+8)));end;
    if( strcmp(name,'fradsampf')),evalflag=1;value=c/(2*(Info(P+2)/Info(P+8)));end;
    if( length(findstr(name,'relhorizontaloffset'))>0), M=3;end;
    if( strcmp(name,'anglef')), M=4;end;
    if( strcmp(name,'widthf')), M=5;end;
    if( strcmp(name,'acqtimelinef')), M=6;end;
    if( length(findstr(name,'nyquistvelocityf'))>0), M=7;end;
    %if( strcmp(name,'prf')),evalflag=1; value=4*fpfreq*Info(P+7)/c;end;
    if( length(findstr(name,'rpbf'))>0), M=8;end;
    if( strcmp(name,'samplesf')), M=8;end;
    if( length(findstr(name,'bpff'))>0), M=9;end;
    if( strcmp(name,'beamsf')), M=9;end;
    if( strcmp(name,'datasizef')), M=10;end;
    if( strcmp(name,'mappingtypef')), M=11;end;
    if( strcmp(name,'intensityincrf')), M=12;end;
    if( strcmp(name,'overallgainf')), M=13;end;
    if( strcmp(name,'comressf')), M=14;end;
    if( strcmp(name,'rejectf')), M=15;end;
    if( strcmp(name,'tgcf')), M=[16:21];end;

    if( strcmp(name,'framesf')),M=22;end;
    if( strcmp(name,'sprf')), M=23;end;

    if any(M),
        N=P+M;
    end;
    P=P+23;
end;

if Spect>0,
    M=0;
    if( strcmp(name,'samplevoldepth')), M=1;end;
    if( strcmp(name,'pulselength')), M=2;end;
    if( strcmp(name,'beamangle')), M=3;end;
    if( strcmp(name,'correctionangle')), M=4;end;
    if( strcmp(name,'acqtimeline')),M=5;end;
    if( strcmp(name,'fs2velocity')), M=6;end;
    if( strcmp(name,'lowvelocreject')), M=7;end;
    if( strcmp(name,'centerfrequency')), M=8;end;
    if( strcmp(name,'prf')), M=9;end;
    if( strcmp(name,'spectsamples')), M=10;end;
    if( strcmp(name,'datasize')), M=11;end;
    if( strcmp(name,'mode')), M=12;end;
    if( strcmp(name,'compression')), M=13;end;
    if( strcmp(name,'reject')),M=14;end;
    if( strcmp(name,'verticalsmooth')), M=15;end;
    if( strcmp(name,'temporalaverage')), M=16;end;
    if( strcmp(name,'gain')), M=17;end;
    if( strcmp(name,'baseline')), M=18;end;
    if( strcmp(name,'records')), M=19;end;
    if M~=0,
        N=P+M;
    end;
    P=P+19;
end;

%% Sync information
if Sync>0,
    M=0;
    if( strcmp(name,'syncblocks')), M=1;end;
    if( strcmp(name,'totalsyncrecs')), M=2;end;
    if( strcmp(name,'timespan')), evalflag=1; value=Timeslice*Info(P+2);end;
    if M~=0,
        N=P+M;
    end;
    P=P+2;
else
    if( strcmp(name,'timespan')), evalflag=1; value=0;end;
end;

%% Blockpos and blocktype
BlocksInFile=Info(P+1);
P=P+1;
if( strcmp(name,'blockpos')),N=[P+1:P+BlocksInFile];end;
P=P+BlocksInFile;
if( strcmp(name,'blocktype')),N=[P+1:P+BlocksInFile];end;
P=P+BlocksInFile;
if( strcmp(name,'recsize')),N=[P+1:P+BlocksInFile];end;
P=P+BlocksInFile;
if( strcmp(name,'numberrecs')),N=[P+1:P+BlocksInFile];end;
P=P+BlocksInFile;

if ~evalflag,
    if(N==0),
        if any(display),
            disp(['GETPARAM warning: Unknown parameter name or parameter not found in file.']);
            disp(['Returns: ',parametername,' = 0']);
        end;
        value=0;
    else
        value=Info(N);
    end;
end;

if (stringflag), 
    value=setstr(value);
    if isempty(value),
        value='n/a';
    end;
end;