As well as editing .ini files (which is very easy, with the Edit INI File command), I need to edit .txt files.
My installer is being written to replace an existing InstallShield one. This uses commands such as FileDeleteLine, FileInsertLine, FileGrep.
All I can find in the InstallAware manual for editing .txt files is Write to Text File, which only lets me prepend or append a line to a file. I need to do things like -- search for a line containing a path with 'Program Files' and replace this with the correct location, which I already have in $PROGRAMFILES$
Basically, these .txt files are simple configuration files containing paths I need to fix up.
Am I missing any commands or is InstallAware less powerful than InstallShield for editing of text files?
If that's the case, are there any existing examples of how to do this sort of thing via other means, e.g. using Run Program please?
Editing .txt files
Re: Editing .txt files
Dear NickDay,
What you are trying to achieve is actually indeed possible - please note that the Read from Text File command reads a single line at a time. I have built a sample project that does exactly what you are trying to do. Please let me know if it works for you.
What you are trying to achieve is actually indeed possible - please note that the Read from Text File command reads a single line at a time. I have built a sample project that does exactly what you are trying to do. Please let me know if it works for you.
- Attachments
-
- EditTextFile.zip
- (2.87 KiB) Downloaded 795 times
Aviv Giladi
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Editing .txt files
Very many thanks, Aviv; I'll try something similar in my project.
Nick
Nick
Re: Editing .txt files
Absolutely, Nick. Let me know if there is anything else I can help you with.
Aviv Giladi
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Editing .txt files
Hi Aviv,
I need to edit each .txt file 'in place', not write to a new one as in your excellent example.
I guess I would not get away with reading and writing the same file (or can I?), so instead I suppose I should write to a new temporary file and afterwards, rename it, overwriting the existing file. I don't yet know whether that's possible so if you have any helpful comments, they'd be most welcome.
Nick
I need to edit each .txt file 'in place', not write to a new one as in your excellent example.
I guess I would not get away with reading and writing the same file (or can I?), so instead I suppose I should write to a new temporary file and afterwards, rename it, overwriting the existing file. I don't yet know whether that's possible so if you have any helpful comments, they'd be most welcome.
Nick
Re: Editing .txt files
I'm going to try Copy/Move Local Files...
Re: Editing .txt files
Dear Nick,
In order to avoid any synchronization problems, I would just write to a new file, delete the old one and rename the new one to the old one's name.
In order to avoid any synchronization problems, I would just write to a new file, delete the old one and rename the new one to the old one's name.
Aviv Giladi
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Editing .txt files
Thanks Aviv.
Some text here is just to help anyone else doing the same thing.
And I have asked a couple of new questions you might prefer to be in their own thread. If so, let me know and I'll ask them separately.
Do you mean there's a 'rename' command? I could not find one.
For the record, When I just used Copy/Move Local Files to overwrite the existing file my newly-written temporary file, the installer asked the user whether they wanted to overwrite. I don't really want the user to be prompted. There is not a setting to 'overwrite without prompting'.
However I was able to Delete File and then Copy/Move Local Files to avoid the user being prompted. Maybe that's all you meant by avoiding 'synchronization problems'?
For the record, something I read on the forum gave me the idea that I would have to do this file manipulation only after the 'Apply Install'. However I found the opposite to be true -- try and do it after Apply Install, and nothing happens; I had to do it before.
So, thanks to your help I now have a block of working MSI code here in the UK which I wish to copy into a similar installer on a remote PC in the States.
It would be nice if I could export (serialize) my block of code out to a file, and then import it into the middle of the MSI code on the remote PC. If something like that is possible, I would really welcome it. Otherwise I have to just construct the same block of code again, on the remote PC. I can select a block of code and 'copy as text', and save it to text file. But is this complete, and can I import it on the other PC?
Incidentally, while I'm working, I often turn some unwanted lines of code into comment (in case I need them later). If I copy/paste a block of code elsewhere, the commented-out lines become uncommented. Is this behaviour intentional? It happens silently and has caused me problems sometimes.
Some text here is just to help anyone else doing the same thing.
And I have asked a couple of new questions you might prefer to be in their own thread. If so, let me know and I'll ask them separately.
Do you mean there's a 'rename' command? I could not find one.
For the record, When I just used Copy/Move Local Files to overwrite the existing file my newly-written temporary file, the installer asked the user whether they wanted to overwrite. I don't really want the user to be prompted. There is not a setting to 'overwrite without prompting'.
However I was able to Delete File and then Copy/Move Local Files to avoid the user being prompted. Maybe that's all you meant by avoiding 'synchronization problems'?
For the record, something I read on the forum gave me the idea that I would have to do this file manipulation only after the 'Apply Install'. However I found the opposite to be true -- try and do it after Apply Install, and nothing happens; I had to do it before.
So, thanks to your help I now have a block of working MSI code here in the UK which I wish to copy into a similar installer on a remote PC in the States.
It would be nice if I could export (serialize) my block of code out to a file, and then import it into the middle of the MSI code on the remote PC. If something like that is possible, I would really welcome it. Otherwise I have to just construct the same block of code again, on the remote PC. I can select a block of code and 'copy as text', and save it to text file. But is this complete, and can I import it on the other PC?
Incidentally, while I'm working, I often turn some unwanted lines of code into comment (in case I need them later). If I copy/paste a block of code elsewhere, the commented-out lines become uncommented. Is this behaviour intentional? It happens silently and has caused me problems sometimes.
Re: Editing .txt files
Dear Nick,
Like in Window's shell, there is no rename command - there is Delete and Rename, and that is what I meant
If you are using MSTSC to access your remote computer (are you?) you could simply copy the code you want (CTRL + C) and paste it inside your remote machine. I actually do it quite frequently. Otherwise, you will need to copy, paste in a text file, send the text file, copy its content, and paste in InstallAware. Comments should remain as they were - they do for me!
Like in Window's shell, there is no rename command - there is Delete and Rename, and that is what I meant
If you are using MSTSC to access your remote computer (are you?) you could simply copy the code you want (CTRL + C) and paste it inside your remote machine. I actually do it quite frequently. Otherwise, you will need to copy, paste in a text file, send the text file, copy its content, and paste in InstallAware. Comments should remain as they were - they do for me!
Aviv Giladi
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Editing .txt files
giaviv wrote:...Comments should remain as they were - they do for me!
Aviv, I can replicate Nick's problem very easily. Create a new basic setup project and unfold all code regions. Select one of the "If" blocks at the top of the MSIcode script and use Toggle Comment to convert it into comments. Select the commented block and paste it elsewhere in the MSIcode script. Voila! The script uncomments the code! I don't think that's necessarily the correct thing for it to do?
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
InstallAware MVP
Re: Editing .txt files
Dear Peter,
Thanks for the comment. I will look into this.
Thanks for the comment. I will look into this.
Aviv Giladi
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Editing .txt files
Aviv,
I just tried it again to make sure I wasn't having a "psychodelic experience" Attached screenshot shows the effect.
I just tried it again to make sure I wasn't having a "psychodelic experience" Attached screenshot shows the effect.
- Attachments
-
- Paste problem.jpg (219.8 KiB) Viewed 14629 times
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
InstallAware MVP
Re: Editing .txt files
Peter,
Thank you again.
Thank you again.
Aviv Giladi
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
InstallAware Software
White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Re: Editing .txt files
I hadn't looked at this thread for a while, so pardon the delayed responses.
Bokkie, yes, that's exactly the (incorrect?) behaviour I'm seeing.
Aviv, I'm not using MSTSC, I'm using RDC. I thought I'd tried exactly what you suggested, and failed to be able to paste text into MSICode. Just like, I can't type text in verbatim; I have to use the various dialogs to set the various parameters even though they are displayed as if they're stored as ASCII text.
I'll try again...
Nick
Bokkie, yes, that's exactly the (incorrect?) behaviour I'm seeing.
Aviv, I'm not using MSTSC, I'm using RDC. I thought I'd tried exactly what you suggested, and failed to be able to paste text into MSICode. Just like, I can't type text in verbatim; I have to use the various dialogs to set the various parameters even though they are displayed as if they're stored as ASCII text.
I'll try again...
Nick
Re: Editing .txt files
No, it didn't work, Aviv.
Try this. In the MSIcode view, select a few lines of code. 'Copy as text'.
Now click elsewhere the the MSIcode in the same script, for convenience, and 'Paste'.
Nothing is pasted.
Am I doing something wrong; should I be pasting in some other way?
I am using InstallAware 10.
Try this. In the MSIcode view, select a few lines of code. 'Copy as text'.
Now click elsewhere the the MSIcode in the same script, for convenience, and 'Paste'.
Nothing is pasted.
Am I doing something wrong; should I be pasting in some other way?
I am using InstallAware 10.
Who is online
Users browsing this forum: No registered users and 83 guests