How to do this ? Sugestion ? Advice ? :crying:
Running .txt file from same place where is located .exe
Started by delphiproblematic, Mar 13 2010 12:16 PM
3 replies to this topic
#1
Posted 13 March 2010 - 12:16 PM
|
|
|
#2
Posted 13 March 2010 - 05:01 PM
What are you trying to do? You can't "run" a text file, just open it, display it, etc.
#3
Posted 13 March 2010 - 07:41 PM
Get it with googling, if you find any problem, we will discuss later
#4
Posted 18 March 2010 - 08:41 AM
To get the name of the file, no metter where the exe is:
If your EXE is 'C:\Dev\LoadAppText\MyAppTextLoader.exe' then a call to ExePathFileName('MyText.txt') will return 'C:\Dev\LoadAppText\MyText.txt'.
Now that yourt app knows where it's at, you can "run" it:
Add a form.
Add a Memo to the form
Name the Memo "TextMemo"
Add a button. Set caption to "Load text".
Double-click the button.
Type:
This will display your text. If you want to "run" text, this text must be source code. This source code must be accompanied by a compiler or interpreter. You must then instruct the appropriate compiler or interpreter to either compile or interpret it using the appropriate controls and or commands available in such a compiler or interpreter according to the manual that comes with it, or the online documentation, or the newsgroups that provide such information. Please be advised that the langauge used in the txt file must match the language used by the compiler or interpreter. (Much like you need to be able to understand English to understand this post).
To fire up notepad, use ShellExecute. Type "ShellExecute" in your delphi code editor and hit F1. If any terms seem unfamiliar in the manual/help, click on the underlined words (these are hyperlinks). Hope this helps.
function ExePathFileName(FileName:String):String; begin result:=ExtractFilePath(Application.ExeName)+FileName; end;
If your EXE is 'C:\Dev\LoadAppText\MyAppTextLoader.exe' then a call to ExePathFileName('MyText.txt') will return 'C:\Dev\LoadAppText\MyText.txt'.
Now that yourt app knows where it's at, you can "run" it:
Add a form.
Add a Memo to the form
Name the Memo "TextMemo"
Add a button. Set caption to "Load text".
Double-click the button.
Type:
TextMemo.Lines.LoadFromFile(ExePathFileName('MyText.txt'));
This will display your text. If you want to "run" text, this text must be source code. This source code must be accompanied by a compiler or interpreter. You must then instruct the appropriate compiler or interpreter to either compile or interpret it using the appropriate controls and or commands available in such a compiler or interpreter according to the manual that comes with it, or the online documentation, or the newsgroups that provide such information. Please be advised that the langauge used in the txt file must match the language used by the compiler or interpreter. (Much like you need to be able to understand English to understand this post).
To fire up notepad, use ShellExecute. Type "ShellExecute" in your delphi code editor and hit F1. If any terms seem unfamiliar in the manual/help, click on the underlined words (these are hyperlinks). Hope this helps.


Sign In
Create Account


Back to top









