// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) ???? - INRIA - Scilab // Copyright (C) 2002-2004 - INRIA - Vincent COUVERT // // This file must be used under the terms of the CeCILL. // This source file is licensed as described in the file COPYING, which // you should have received as part of this distribution. The terms // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt function r=isinstring(str,pos) // Finds if the character pointed by pos is in a string (return %T) or not (return %F) str=part(str,1:pos-1) quote="''" // If no quote in before pos if strindex(str,quote)==[] then r=%F return end ksym=0 strcnt=0 qcount=0 // Quote counter bcount=0 // Bracket counter pcount=0 // Paranthesis counter sym=" " while %T , while %T then // Looking for next non white character if ksym>=pos then r=strcnt<>0; return end ksym=ksym+1; psym=sym; // psym = previous symbol sym=part(str,ksym); if sym<>" " then break,end end if strcnt<>0 then // If in a string if sym==quote then qcount=1 while part(str,ksym+1)<>quote&ksym+1qcount then strcnt=0 sym=part(str,ksym) end end elseif sym==quote then // Check if transpose or beginning of a string if abs(_str2code(psym))>=36&psym<>")"&psym<>"]"&psym<>"."&psym<>quote then // Not a transpose strcnt=1 elseif bcount<>0 then // Inside a matrix definition if part(str,ksym-1)==" " then strcnt=1,end end elseif sym=="[" then bcount=bcount+1 elseif sym=="]" then bcount=bcount-1 end end endfunction