From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/75958 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: \inputif(file)exist(s) Date: Thu, 3 May 2012 11:41:18 -0400 (EDT) Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-53305029-1336059679=:1834" X-Trace: dough.gmane.org 1336059691 29241 80.91.229.3 (3 May 2012 15:41:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 3 May 2012 15:41:31 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu May 03 17:41:28 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SPy9n-0003ft-Pz for gctc-ntg-context-518@m.gmane.org; Thu, 03 May 2012 17:41:27 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C7B05101E5; Thu, 3 May 2012 17:41:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TFWgYBRa-ITE; Thu, 3 May 2012 17:41:25 +0200 (CEST) Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 2C8D8101E1; Thu, 3 May 2012 17:41:25 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 14FED101E1 for ; Thu, 3 May 2012 17:41:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 859EhkuU2HjI for ; Thu, 3 May 2012 17:41:23 +0200 (CEST) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id 51650101CF for ; Thu, 3 May 2012 17:41:23 +0200 (CEST) Original-Received: from hellskitchen.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.14.82]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q43FfDOh007871 for ; Thu, 3 May 2012 17:41:14 +0200 Original-Received: FROM adi-netbook (bas3-montreal02-1096682554.dsl.bell.ca [65.94.12.58]) By hellskitchen.mr.itd.umich.edu ID 4FA2A71F.555AB.4753 ; Authuser adityam; 3 May 2012 11:41:19 EDT In-Reply-To: User-Agent: Alpine 2.02 (LNX 1266 2009-07-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=141.211.14.82; country=US; region=TX; city=Ladonia; postalcode=75449; latitude=33.4261; longitude=-95.9709; metrocode=623; areacode=903; http://maps.google.com/maps?q=33.4261,-95.9709&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0WH5rFdh7 - 3eafa0101470 - 20120503 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:75958 Archived-At: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-53305029-1336059679=:1834 Content-Type: TEXT/PLAIN; charset=iso-8859-2; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 3 May 2012, Proch=E1zka Luk=E1=B9 Ing. - Pontex s. r. o. wrote: > Hello, > > just a quick question - is there a command like "\inputif(file)exist(s)",= =20 > which will \input a file if it exists, i.e. with no error if it doesn't? \readfile. From=20file-res.mkvi %D \macros %D {readfile,ReadFile} %D %D One cannot be sure if a file exists. When no file can be %D found, the \type{\input} primitive gives an error message %D and switches to interactive mode. The macro \type{\readfile} %D takes care of non||existing files. This macro has two faces. %D %D \starttyping %D \ReadFile {filename} %D \readfile {filename} {before loading} {not found} %D \stoptyping %D %D Many \TEX\ implementations have laid out some strategy for %D locating files. This can lead to unexpected results, %D especially when one loads files that are not found in the %D current directory. Let's give an example of this. In %D \CONTEXT\ illustrations can be defined in an external file. %D The resizing macro first looks if an illustration is defined %D in the local definitions file. When no such file is found, %D it searches for a global file and when this file is not %D found either, the illustration itself is scanned for %D dimensions. One can imagine what happens if an adapted, %D localy stored illustration, is scaled according to %D dimensions stored somewhere else. %D %D When some \TEX\ implementation starts looking for a file, it %D normally first looks in the current directory. When no file %D is found, \TEX\ starts searching on the path where format %D and|/|or style files are stored. Depending on the implementation %D this can considerably slow down processing speed. %D %D In \CONTEXT, we support a project||wise ordening of files. %D In such an approach it seems feasible to store common files %D in a lower directory. When for instance searching for a %D general layout file, we therefore have to backtrack. %D %D These three considerations have lead to a more advanced %D approach for loading files. %D %D We first present an earlier implementation of %D \type{\readfile}. This command backtracks parent %D directories, upto a predefined level. Users can change this %D level (on the commandline using a directive); we default to~3. %D %D We use \type{\normalinput} instead of \type{\input} %D because we want to be able to redefine the original %D \type{\input} when needed, for instance when loading third %D party libraries. Aditya --8323328-53305029-1336059679=:1834 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --8323328-53305029-1336059679=:1834--