Skip to content

Checking if a file exists #240

@tueda

Description

@tueda

It would be nice to have a functionality to check if a file exists in the path. One possibility of the syntax is

#if fileexists(foo.h)

#endif

The implementation should be easy, just opening and then closing the file. In this syntax, file names with ( and ) can't be handled properly, but I think this is the FORM way to discourage such crazy file names. Introducing some escapes for special characters in file names would be also easy.

There will be many way to use this file check. I'm considering usage as follows. Suppose I make a some library that have some table files. Table files can be in ASCII, which is the most portable way. But it will be faster if I use binary files (tablebase or *.sav storing expressions). Unfortunately they are most likely version-dependent. So I don't like to put the binary file in the library. Instead, I would prepare a way such that one can make them with his/her version of FORM. The library first tries to load a binary table and when impossible reads the corresponding ASCII table as a fallback. This is the way used in a Mathematica package MT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions