08-25-2018, 12:02 AM (This post was last modified: 08-25-2018, 12:31 AM by win.)
Hello everyone , I often use a text editor to modify the .psl file. Can I achieve my purpose using the QM function? I hope someone can provide some help, thanks in advance.
Example:
The following command is in the abc.psl file, I want to change it to the bottom code.
str s.getfile("$desktop$\abc.psl\abc.psl");; load the file into a string so you can work with it
s.findreplace("select partition 0""select partition 1") ;the first set of quotes in findreplace are what to find the second are what to replace with ;s.findreplace("" "");;;uncomment and make changes to findreplace ;s.findreplace("" "");;;uncomment and make changes to findreplace out s ;when done editing ;s.setfile("$desktop$\abc.psl\abc.psl");; uncomment when you want to save
str s.getfile("$desktop$\abc.psl");; load the file into a string so you can work with it
s.findreplace("select partition 0""select partition 1") ;the first set of quotes in findreplace are what to find the second are what to replace with
s.findreplace("pwde = "c"""pwde = "d"");;;uncomment and make changes to findreplace
s.findreplace("/path = "C:/"""/path = "e:/"");;;uncomment and make changes to findreplace
s.findreplace("/name = "c"""/name = "f"");;;uncomment and make changes to findreplace out s ;when done editing
s.setfile("$desktop$\abc.psl");; uncomment when you want to save
str s.getfile("$desktop$\abc.psl");; load the file into a string so you can work with it int pt=2 str pt2=F"select partition {pt}"
s.findreplace(F"select partition 0"''{pt2}'') out s ;s.setfile("$desktop$\abc.psl");; uncomment when you want to save
str pt inp pt str s.getfile("$desktop$\abc.psl");; load the file into a string so you can work with it str pt2=F"select partition {pt}" out pt2
s.findreplace(F"select partition 0""{pt2}") ;out s
s.setfile("$desktop$\abca.psl");; uncomment when you want to save
str pt inp pt str s.getfile("$desktop$\abc.psl");; load the file into a string so you can work with it str pt2=F"select partition {pt}" ;out pt2
s.findreplace("select partition 0"F"{pt2}") out s
s.setfile("$desktop$\abca.psl");; uncomment when you want to save
str s1 ifOpenSaveDialog(0 s1 "psl files[]*.psl") ,;out s1 ,str pt ,inp pt ,str s.getfile(s1);; load the file into a string so you can work with it , ,s.findreplace("select partition"F"select partition {pt}") ,;out s ,;s.setfile("$desktop$\abca.psl") ,OpenSaveDialog(1 s1 "psl files[]*.psl")
the OpenSaveDialog function doesn't actually open or save a file. It's just a gui that allows a choice and returns that choice as a string. You still need to use getfile to open and setfile to save it.
str s1 ifOpenSaveDialog(0 s1 "psl files[]*.psl") ,;out s1 ,str pt ,inp pt ,str s.getfile(s1);; load the file into a string so you can work with it , ,s.findreplace("select partition"F"select partition {pt}") ,out s ,OpenSaveDialog(1 s1 "psl files[]*.psl") ,s.setfile(s1)
If there are multiple .psl files on my computer desktop, what should I do with the following code? Note: Add _edit after the modified file name. Can you help me anymore? Thank you
08-25-2018, 10:24 PM (This post was last modified: 08-25-2018, 10:43 PM by Kevin.)
not sure what your trying to do but this is all wrong s.setfile(F"$desktop$\abc_edit.psl")
there is no need for F parameter there
i think your asking how to edit more than 1 file at a time if so
str s1 ARRAY(str) a;int i ifOpenSaveDialog(00""""0""0 a);;use array so can select multiple files to make changes to ,for(i 0 a.len) ,,s1.getfile(a[i])l;; loads each file selected ,,s1.findreplace("select partition 0""select partition 1") ,,out s1;; use this first to make sure your code is correct ,,;s.setfile(a[i])then uncomment this to save change made
i just noticed that there was an error in previous code you were trying str s1 ifOpenSaveDialog(0 s1 "psl files[]*.psl") ,;out s1 ,str pt ,inp pt ,str s.getfile(s1);; load the file into a string so you can work with it , ,s.findreplace("select partition"F"select partition {pt}")<--------------------- this line is incorrect first part of findreplace should be "select partition 0" ,out s ,OpenSaveDialog(1 s1 "psl files[]*.psl") ,s.setfile(s1)
otherwise your would end up with this
select partition 1 0 being saved
The above code error, I just found out, thank you for your reminder
I need to process all *.psl files on the desktop, and finally add the suffix _edit after their respective file names. I don't want to overwrite the original file, because sometimes the original file is needed.
need to enumerate the desktop then using dir
keeps original files untouched makes new file with appended name for example changes abc.psl to abc_edit.psl
08-25-2018, 11:40 PM (This post was last modified: 08-25-2018, 11:45 PM by Kevin.)
That basically finds all .psl on the desktop or in any subfolder on the desktop loads each files modifies the 1 line then saves the file with the new name leaving original files untouched
wait need to update that
08-26-2018, 12:15 AM (This post was last modified: 08-26-2018, 12:21 AM by Kevin.)
here is corrected posts from above that got accidently deleted
will prevent renaming of files that already have the _edit.psl suffix
if you dont file name will keep changing for example from abc.psl to abc_edit.psl to abc_edit_edit.psl ect. ect..
08-26-2018, 01:02 AM (This post was last modified: 08-26-2018, 01:12 AM by Kevin.)
Sorry i should explain differently renaming original file names after editing is fine. So abc.psl remains and new file abc_edit.psl is created. I meant don't rename before editing.
As far as the other 4 things have a look at
Intgetfile or other functions to download the file search forum for examples
Zip
Need to unzip after downloading
You already should know how to process and edit them. After editing zip will be used again
Then email all can be found lots of examples on the forum and in qm help
08-26-2018, 05:30 AM (This post was last modified: 08-26-2018, 06:11 AM by win.)
Thank you very much, the code runs successfully.
But there is a problem. If I re-upload 4files.zip, I can't download the file. Can I download it by retrieving the elements in the webpage?
How to hide the download link? As shown below
08-26-2018, 06:13 AM (This post was last modified: 08-26-2018, 06:14 AM by Kevin.)
don't remove the attachment if you change it. Click the choose file button select the new file then click update attachment button.THat way file attachment number remains the same the file will be the new file but can still be downloaded using the same link.
I want to know what function can be used to retrieve the link field, so that the download link will remain in effect as long as the file name is unchanged.