* \inputif(file)exist(s) @ 2012-05-03 15:37 Procházka Lukáš Ing. - Pontex s. r. o. 2012-05-03 15:41 ` \inputif(file)exist(s) Aditya Mahajan 2012-05-03 15:43 ` \inputif(file)exist(s) Wolfgang Schuster 0 siblings, 2 replies; 4+ messages in thread From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-05-03 15:37 UTC (permalink / raw) To: ConTeXt 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? TIA. Lukas -- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 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 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: \inputif(file)exist(s) 2012-05-03 15:37 \inputif(file)exist(s) Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-05-03 15:41 ` Aditya Mahajan 2012-05-04 5:52 ` \inputif(file)exist(s) Procházka Lukáš Ing. - Pontex s. r. o. 2012-05-03 15:43 ` \inputif(file)exist(s) Wolfgang Schuster 1 sibling, 1 reply; 4+ messages in thread From: Aditya Mahajan @ 2012-05-03 15:41 UTC (permalink / raw) To: mailing list for ConTeXt users [-- Attachment #1: Type: TEXT/PLAIN, Size: 2500 bytes --] On Thu, 3 May 2012, Procházka Lukáš 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 [-- Attachment #2: Type: text/plain, Size: 485 bytes --] ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: \inputif(file)exist(s) 2012-05-03 15:41 ` \inputif(file)exist(s) Aditya Mahajan @ 2012-05-04 5:52 ` Procházka Lukáš Ing. - Pontex s. r. o. 0 siblings, 0 replies; 4+ messages in thread From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2012-05-04 5:52 UTC (permalink / raw) To: mailing list for ConTeXt users ... Great, thank you. Lukas On Thu, 03 May 2012 17:41:18 +0200, Aditya Mahajan <adityam@umich.edu> wrote: > On Thu, 3 May 2012, Procházka Lukáš 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áš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 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 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: \inputif(file)exist(s) 2012-05-03 15:37 \inputif(file)exist(s) Procházka Lukáš Ing. - Pontex s. r. o. 2012-05-03 15:41 ` \inputif(file)exist(s) Aditya Mahajan @ 2012-05-03 15:43 ` Wolfgang Schuster 1 sibling, 0 replies; 4+ messages in thread From: Wolfgang Schuster @ 2012-05-03 15:43 UTC (permalink / raw) To: mailing list for ConTeXt users Am 03.05.2012 um 17:37 schrieb Procházka Lukáš Ing. - Pontex s. r. o.: > 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{…} Wolfgang ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-04 5:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-05-03 15:37 \inputif(file)exist(s) Procházka Lukáš Ing. - Pontex s. r. o. 2012-05-03 15:41 ` \inputif(file)exist(s) Aditya Mahajan 2012-05-04 5:52 ` \inputif(file)exist(s) Procházka Lukáš Ing. - Pontex s. r. o. 2012-05-03 15:43 ` \inputif(file)exist(s) Wolfgang Schuster
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).