The file is inside the directory where the software is. I am trying to add the text file to the memo box.
procedure TForm4.FormCreate(Sender: TObject);
var
dir : string;
begin
Form4.Caption:='Abateri instrumente';
dir := GetCurrentDir;
Memo1.Lines.LoadFromFile(dir+'\abateri.txt');
end;
In your specific situation, you should load the file with the code
Memo1.Lines.LoadFromFile(dir+'\abateri.txt.txt');
This is because in the below screenshot that you provided, the extension of the Project3 file is hidden, which loads to the conclusion that the option to hide known file extensions is enabled. Yet the one for the abateri.txt file is shown, which can only lead to the often seen double extension mistake.
Either rename your file and remove the redundant part (the first .txt, which is preferred) or use the double extension in your code.
I would also suggest disabling that option in Windows Explorer:
Tools > Folder Options > View > Uncheck the "Hide extensions of known file types"
In addition to the above, you should always build up paths with the TPath.Combine function call to ensure that they are correct.
You can see the documentation of it here
The file is inside the directory where the software is.
In that case, looking in the working directory is the wrong approach. There's no reason why the working directory should be directory where your executable resides. You need to use:
Dir := ExtractFilePath(ParamStr(0)); // the directory where the executable resides
TPath.Combine(Dir, FileName); // TPath is from the System.IOUtils unit
Of course, your other problem is that you got your file name wrong. The file is actually named abateri.txt.txt.
Related
I'm getting the following error:
"The file isn’t compatible with QuickTime Player."
When using this script:
tell application "Finder"
set random_file to some file of entire contents of folder "Movies" of home
open result
end tell
However, I am able to open the file from the finder manually and once I do the script works on just that file. The problem is I have thousands of files and don't want to open each one manually for the script to work again. Have not had this problem with the script in the past.
There are two ways I can think of to approach modifying your script:
Stick with Finder's open command but invoke it fully with its using parameter, which accepts an application file that informs Finder of the application that will be used to open the file. It may sound superfluous given it already tries to open it in QuickTime, and we're not trying to change that, but it's not unwise to see if it does confer a difference in behaviour:
tell application id "com.apple.finder"
tell the folder (path to movies folder) to tell (the ¬
a reference to entire contents) to tell (the ¬
some document file as alias) to set f to it
open f using application file id "com.apple.QuickTimePlayerX"
end tell
Grab the file as you like (really, you ought to be using System Events for this, not Finder, but I'll go with what you had), but then use the open handler of the specific application to open the file:
tell application id "com.apple.finder" to tell the folder (path to movies folder) ¬
to tell (a reference to the entire contents) to tell (some document file) ¬
as alias to set f to it
tell application id "com.apple.QuickTimePlayerX"
activate
open f
end tell
NB. I'm using Monterey, in which both of these two above propositions work appropriately. This doesn't necessarily infer that it will do so in Big Sur, but if they do not, it's worth checking the various app permissions under the different Security & Privacy headings of System Preferences.
I'm trying to load files into MAGMA and am running into some trouble. Ostensibly, the command load "filename";should be sufficient. I've attempted, but keep getting the same result:
>> load "filename";
^
User error: Could not open file "filename" (No such file or directory)
The file is saved in my documents folder, so I'm not sure what the issue is. Do I have to specify the path? Save the file in a particular place?
I've tried reformatting, using both txt and rtf files, so I don't think that's the issue.
For loading file in MAGMA you can place your file in installed place folder. For example: C:\Program Files (x86)\Magma
Also if your file have an special format you should mention it.
Suppose You want loading a txt file with name a. with load"a"; you face with error. You must type load"a.txt";.
Try using GetCurrentDirectory() command to find your current directory location. And then you can use SetPath() to change where MAGMA has to be to search for your file. This will fix it.
So i'm trying to make a configuration for my app, although it doesn't seem to load or save anything from/in it.
Here's the code upon creation:
ini_open(working_directory + "\properties.ini");
global.width = ini_read_real('screen','width',640);
global.height = ini_read_real('screen','height',480);
ini_close();
Here's the ini file:
[screen]
width = 1280
height = 1024
when i return global.width and global.height values they're still 640;480 but not as stated in the ini file, which means it doesn't even load values from the file. I was wondering, maybe I need to compile the executable and then run it as administrator, but I doubt that there could be a problem with permissions. I also added properties.ini file to "Included Files" folder so it would come with compiled exe.
This seems weird, but now it works. Actually the *.ini file isn't saved the same place where exe is. I just found out that it saves everything in %localappdata%// . Also it looks to be working better without dir shortcut "working_directory". So thanks, anyway
I am trying to use a MEL script to load ANIMATION.MA file that references CHARACTER_RIG.MA. The CHARACTER_RIG.MA and ANIMATION.MA files are produced by someone else and supplied to me. The ANIMATION.MA is looking for N:/Project/Maya//char/character/CHARACTER_RIG.MA
If I open ANIMATION.MA from Maya, or use the equivalent MEL command I always get prompted with:
"Reference File Not Found"
Reference File Not Found: N:/Project/Maya//char/character/CHARACTER_RIG.MA.
[Abort File Read] [Skip] [Browse...] [Retry]
If I tap browse, and select the CHARACTER_RIG.MA then it opens perfectly. I can see it created a reference in the Reference Editor that has the Unresolved Path (N:/...) , the Resolved Path (/my/path) and the namespace and the namespaceRN.
My question is, how do I do the equivalent of the "Browse..." from MEL? I tried pre-creating a reference, but it doesn't let me set the unresolved path, so when I load the ANIMATION.MA it keeps prompting in MAYA.
file -f -options "v=0" -typ "mayaAscii" -o "/Source/project/assets/anims/ANIMATION.MA"
If you know the directory where the file is, then you can use the dirmap command. The command dirmap allows you to remap directory structures if your disk configuration changes. So in this case it would look like:
dirmap -en true;
dirmap -m "N:/Project/Maya//char/character" "/my/path";
Possibly more manageable if you have lots of mappings to do especially when moving form a windows machine to a *nix one. However it is much more useful to define your project structure because then things just work when you move, tough this may not be the best of choice for shared assets.
I ended up finding several solutions:
Rename the RIG.MA file to match the filename in ANIM.MA (they were different in my case) and put it in one of the search or project folders that MAYA uses and it will automatically find it.
or
Programatically through code (or manually) edit the ANIM.MA file to remap the file/folder of the RIG.MA to where you want to load it from. Note: You
also need to remap any other files, such as textures. I did this with
perl -pi -e 's/\Qold-path\E/\Qnew-path\E/g' ANIMATION.MA
HTH someone else.
Quick and easy, File, Project, Set and select the folder where meshes or whatever it is.
File open with fopen() fails when I provide a relative path. I am running this code on a windows machine with Visual Studio 2010.
const char* OUTPUT_FILE = "output/PERFORMANCE.txt";
FILE* f = fopen(OUTPUT_FILE, "w");
Is this way of specifying relative path incorrect? Should I be using "\" separator?
Specifying the absolute path using the same format works fine. (e.g "C:/output/PERFORMANCE.txt")
Check what directory you are currently in. With Windows there are at least two ways:
_getcwd
GetCurrentDirectory
Make sure you are in the directory you think you are, and make sure that the directory output exists in the directory, otherwise you'll need to create it. With Windows, there are at least two ways:
_mkdir
CreateDirectory
The file will fail to open (even for writing) if any intermediate directories are not present. The file may also fail to open if you do not have permissions to the target directory.
Does the output subdirectory exist? Opening a file for write will create the file if it doesn't exist, but not the path to it.