Two questions in pascal (graphics and files)

Hi,

I have two questions:
The first, I built a program that read information from a text file (txt) . My question is how can I know where the user install (or save) the program. I mean that I need a function that will return to me the complete path of the file (the program or the primary file) that are running now.

The second is related to graphics programming (Using the graph unit), as you propably know in the graphics mode we cannot use write or writeln rather we use Outtextxy that have three parameters position X and position Y and String.
my question is how can I send to this procedure a number?
I think about convert the number to string but this is a primitive way so if anybody have another way please post here...

Bye Bye and thanx!!!

Comments

  • Hi there!.

    About the path, you can use FExpand() in unit DOS. It returns a String with the path of the parameter file (which name is also a String). Uh!, I think my English is very bad, sorry. Try this:

    [code]
    uses dos;
    begin
    writeln(FExpand('.'));
    end.
    [/code]

    About the graphical question, there's no better way to do using outtextxy that using a String :(. If 'ptos' is an integer, and 'cad' a String, the fastest way is:

    [code]
    str(ptos, cad);
    outtextxy(314, 159, cad);
    [/code]
  • : Hi there!.
    :
    : About the path, you can use FExpand() in unit DOS. It returns a String with the path of the parameter file (which name is also a String). Uh!, I think my English is very bad, sorry. Try this:
    :
    : [code]
    : uses dos;
    : begin
    : writeln(FExpand('.'));
    : end.
    : [/code]
    :
    : About the graphical question, there's no better way to do using outtextxy that using a String :(. If 'ptos' is an integer, and 'cad' a String, the fastest way is:
    :
    : [code]
    : str(ptos, cad);
    : outtextxy(314, 159, cad);
    : [/code]
    :
    An alternate solution to the first question is:
    [code]
    PathPlusFilename := ParamStr(0);
    [/code]
    I'm not sure if the FExpand('.') always returns the executable's path. It could also return the current directory, which might be changed by the user. But I could be wrong here.
  • : : Hi there!.
    : :
    : : About the path, you can use FExpand() in unit DOS. It returns a String with the path of the parameter file (which name is also a String). Uh!, I think my English is very bad, sorry. Try this:
    : :
    : : [code]
    : : uses dos;
    : : begin
    : : writeln(FExpand('.'));
    : : end.
    : : [/code]
    : :
    : : About the graphical question, there's no better way to do using outtextxy that using a String :(. If 'ptos' is an integer, and 'cad' a String, the fastest way is:
    : :
    : : [code]
    : : str(ptos, cad);
    : : outtextxy(314, 159, cad);
    : : [/code]
    : :
    : An alternate solution to the first question is:
    : [code]
    : PathPlusFilename := ParamStr(0);
    : [/code]
    : I'm not sure if the FExpand('.') always returns the executable's path. It could also return the current directory, which might be changed by the user. But I could be wrong here.

    I haven't tried, but I'll be you're right in that it returns the current directory, which is not necessarily the directory the .EXE is in. Using FSplit() on ParamStr(0) is the way I usually use to get the .EXE directory (unless the compiler has ExtractFilePath() which is simpler to use than FSplit(), just not portable to TP)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories