Lazarus
Programming => General => Topic started by: wytwyt02 on November 14, 2019, 09:44:49 pm
-
I i have a txt file wanna to be generated to the project1.lrs file, and load it from my program.
But If I change the txt file and then regenerate project1.lrs, and compile my project, the project1.lrs file will back to before.
There is only way That remove lib and restart IDE can fix that problem
-
Please read this..
https://wiki.freepascal.org/Lazarus_Resources (https://wiki.freepascal.org/Lazarus_Resources)
-
regenerate project1.lrs, and compile my project, the project1.lrs file will back to before.
Try "Run" > "Build" (or "Clean up and Build") instead of "Run" > "Run" or "Run" > "Compile".
-
Please read this..
https://wiki.freepascal.org/Lazarus_Resources (https://wiki.freepascal.org/Lazarus_Resources)
I have read this topic, but nothing about that problem, this might a bug
-
regenerate project1.lrs, and compile my project, the project1.lrs file will back to before.
Try "Run" > "Build" (or "Clean up and Build") instead of "Run" > "Run" or "Run" > "Compile".
I have tried, not work
-
Hi!
Delete or rename the old lrs file.
Create a new lrs file.
Build (and NOT compile) you project.
Should work.
Winni
-
I assume you created a RC file with the contents of this for example..
TagNameToTheStringData RT_RAWDATA TextFilename.txt
and in your code, somewhere..
{$R MYRCFILE.RC}
The MYRCFILE.RC is just a text file of the contents as an example above..
The compiler will compile the RES version of the file..
-
I assume you created a RC file with the contents of this for example..
TagNameToTheStringData RT_RAWDATA TextFilename.txt
and in your code, somewhere..
{$R MYRCFILE.RC}
The MYRCFILE.RC is just a text file of the contents as an example above..
The compiler will compile the RES version of the file..
I am not use rc file , i am use lrs
-
part of your problem.
-
Hi!
If you project name is "Project1" you should never give a resource that name: It is used by the IDE for the managment of this project!!! Call it "MyText" or whatever.
I don't know if this is solved: I remember situations when the IDE and/or the compiler did not recognize, that the resource changed. So while you are developing give your resource a new name with every change: MyText1, MyText2, MyText3 ....
Winni
-
I've found that the project will not detect changes to files unless they are in the project list.
For file sources that need to be forced as a recompile making changes in the file while open usually triggers a full rebuild of that file..
But getting back to resources, I've never done what the poster is attempting in that way, I've always used the precompiled name.res from the resource compiler or use the name.rc and let the compiler add it to the resource.
-
The more the IDE knows about the resources the more things can be done automatically.
The attached demo links a text file "resource-text.txt" as a resource to the binary. The resource file is not created as a separate lrs or res file, but by adding the "resource-text.txt" as a Resource to the project options ("Project" > "Project options" > "Resources" > "Add" > select the file; resource type is RCDATA; the string given in box "Resource" is the name under which the resource is found by the application). Additionally the "resource-text.txt" is added to the project files ("Project" > "Project options" > "Add" > "Add files from file system" > Select resource-text.txt). This way the IDE know that a paricular file is to be linked as a resource, and it can keep track of changes within the file.
Run the demo. Click the button - the contents of "resource-text.txt" are read from the application's resources and displayed in the memo.
End the program. Change the contents of "resource-text.txt". Press F9 to compile and run. When you click the button you will see the new contents.
If "resource-text.txt" would not be included in the project, the IDE would miss that the file content has been changed and the button click will show the unchanged file. In this case you'd have to "Build" the project, then "Run".
-
The more the IDE knows about the resources the more things can be done automatically.
The attached demo links a text file "resource-text.txt" as a resource to the binary. The resource file is not created as a separate lrs or res file, but by adding the "resource-text.txt" as a Resource to the project options ("Project" > "Project options" > "Resources" > "Add" > select the file; resource type is RCDATA; the string given in box "Resource" is the name under which the resource is found by the application). Additionally the "resource-text.txt" is added to the project files ("Project" > "Project options" > "Add" > "Add files from file system" > Select resource-text.txt). This way the IDE know that a paricular file is to be linked as a resource, and it can keep track of changes within the file.
Run the demo. Click the button - the contents of "resource-text.txt" are read from the application's resources and displayed in the memo.
End the program. Change the contents of "resource-text.txt". Press F9 to compile and run. When you click the button you will see the new contents.
If "resource-text.txt" would not be included in the project, the IDE would miss that the file content has been changed and the button click will show the unchanged file. In this case you'd have to "Build" the project, then "Run".
Thanks! it is better way to manage resource, This shoule be documented in wiki, https://wiki.freepascal.org/Lazarus_Resources
and seems rc resource is better than lrs resource, because rc resource is ide support in lazarus
-
The more the IDE knows about the resources the more things can be done automatically.
The attached demo links a text file "resource-text.txt" as a resource to the binary. The resource file is not created as a separate lrs or res file, but by adding the "resource-text.txt" as a Resource to the project options ("Project" > "Project options" > "Resources" > "Add" > select the file; resource type is RCDATA; the string given in box "Resource" is the name under which the resource is found by the application). Additionally the "resource-text.txt" is added to the project files ("Project" > "Project options" > "Add" > "Add files from file system" > Select resource-text.txt). This way the IDE know that a paricular file is to be linked as a resource, and it can keep track of changes within the file.
Run the demo. Click the button - the contents of "resource-text.txt" are read from the application's resources and displayed in the memo.
End the program. Change the contents of "resource-text.txt". Press F9 to compile and run. When you click the button you will see the new contents.
If "resource-text.txt" would not be included in the project, the IDE would miss that the file content has been changed and the button click will show the unchanged file. In this case you'd have to "Build" the project, then "Run".
In the Project Option -> Resource, What is different between the resouce types?(ICON, CURSOR, HTML, RCDATA)?
-
the difference is how they are stored and what the resource compile expects to find in the information you give it.
These data fields are not directly stored as plain ole text, except maybe for the String types
but even those have a header etc in the file for it to keep track of.
in your case you need to use the STRING type because that is what you are giving it, one long string.
I've never used the Project options to do this because I didn't know it existed however, I still like the in code method because I can see it and that is how it was done in the Delphi days... well at least the days I came from ;)