From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/75963 Path: news.gmane.org!not-for-mail From: =?iso-8859-2?B?UHJvY2jhemthIEx1a+G5IEluZy4gLSBQb250ZXggcy4gci4gby4=?= Newsgroups: gmane.comp.tex.context Subject: Re: \inputif(file)exist(s) Date: Fri, 04 May 2012 07:52:06 +0200 Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1336110745 28746 80.91.229.3 (4 May 2012 05:52:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 4 May 2012 05:52:25 +0000 (UTC) To: "mailing list for ConTeXt users" Original-X-From: ntg-context-bounces@ntg.nl Fri May 04 07:52:25 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 1SQBRF-0002LW-LV for gctc-ntg-context-518@m.gmane.org; Fri, 04 May 2012 07:52:21 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 4058B101EA; Fri, 4 May 2012 07:52:20 +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 6OiVFCLL02qM; Fri, 4 May 2012 07:52:18 +0200 (CEST) Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id B8D6A101E0; Fri, 4 May 2012 07:52:18 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0ADAC101E0 for ; Fri, 4 May 2012 07:52:18 +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 tyoSeL9Kw1Ta for ; Fri, 4 May 2012 07:52:16 +0200 (CEST) Original-Received: from filter1-ams.mf.surf.net (filter1-ams.mf.surf.net [192.87.102.69]) by balder.ntg.nl (Postfix) with ESMTP id B4AF7101CF for ; Fri, 4 May 2012 07:52:15 +0200 (CEST) Original-Received: from mail.pontex.cz (mail.pontex.cz [89.233.168.98]) by filter1-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q445qDYn012820 for ; Fri, 4 May 2012 07:52:15 +0200 Original-Received: from localhost ([127.0.0.1]) by mail.pontex.cz (Kerio MailServer 6.6.2) for ntg-context@ntg.nl; Fri, 4 May 2012 07:52:10 +0200 In-Reply-To: User-Agent: Opera Mail/11.62 (Win32) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=89.233.168.98; country=CZ; latitude=49.7500; longitude=15.5000; http://maps.google.com/maps?q=49.7500,15.5000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0NH5FQd93 - 85f6214961b2 - 20120504 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.69 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:75963 Archived-At: ... Great, thank you. Lukas On Thu, 03 May 2012 17:41:18 +0200, Aditya Mahajan wrot= e: > 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)", >> which will \input a file if it exists, i.e. with no error if it doesn't? > > \readfile. > > From file-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 -- = Ing. Luk=E1=B9 Proch=E1zka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezov=E1 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________