Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


GetNextLine.m

Go to the documentation of this file.
00001 function [err, snl, Nlines, strt, stp] = GetNextLine (s,n)
00002 %
00003 %   [err, snl, Nlines, strt, stp] = GetNextLine (s,n)
00004 %
00005 %Purpose:
00006 %   reads the nth line of a string
00007 %   lines are separated by a new line character, of course
00008 %   
00009 %Input Parameters:
00010 %   s
00011 %   
00012 %   
00013 %Output Parameters:
00014 %   err : 0 No Problem
00015 %       : 1 Mucho Problems
00016 %   
00017 %   snl the nth string
00018 %   if you exceed the number of lines in the string, an empty string is returned
00019 %   Nlines is the total number of lines in s  
00020 %   strt, stp are such that snl = s(strt:stp)  
00021 %Key Terms:
00022 %   
00023 %More Info :
00024 %   good for parins ls lists e.g:
00025 %   [tm,v] = unix('ls -C1');
00026 %   [err,sn] = GetNextLine(v,1)
00027 %   [err,sn] = GetNextLine(v,4) etc
00028 %   
00029 %
00030 %     Author : Ziad Saad
00031 %     Date : Mon Oct 11 13:15:13 CDT 1999 
00032 
00033 
00034 %Define the function name for easy referencing
00035 FuncName = 'GetNextLine';
00036 
00037 %Debug Flag
00038 DBG = 1;
00039 
00040 %initailize return variables
00041 err = 1;
00042 strt = 0; stp = 0;
00043 
00044 inl = find(setstr(s) == 10);
00045 
00046 Nlines = length(inl);
00047 if (n <= Nlines),
00048         if (n == 1), 
00049                         strt = 1;
00050                 else
00051                 strt = inl(n-1)+1;
00052         end
00053         stp = inl(n) -1;
00054         snl=s(strt:stp);
00055 else
00056                 snl = '';
00057 end
00058 
00059 err = 0;
00060 return;
00061 
 

Powered by Plone

This site conforms to the following standards: