sebastian |
07/23/2009 03:43AM (Read 2596 times)
|
|
|
Status: offline
Registered: 03/20/2007
Posts: 45
|
Hi, I'm having troubles writing a script. The aim is to read a file with numbers
to be added as parameters via hedit on a list of images.
e.gPart of the code:
[code:1:2da6262d5f]
list="input" #file with numbers
while (fscan(list,s1) !=EOF){
hedit(imlist,'Field',s1,add+,up+,ver-) #imlist: list with images
}
[/code:1:2da6262d5f]
As it seems, at the end, this will only write the last entry on 'Field' in every image.
It's more difficult that what I thought
Thanks
seba
|
|
|
|
fitz |
07/23/2009 03:43AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
I'm not sure what you're trying to do exactly, the fragment shows that HEDIT is called to process the entire list of images using the value read from the 'input' list. It overwrites the 'FIELD' keyword each time so only the last value in the file is retained. If what you want is for each line of the numbers to be added to the corresponding image, you can use the JOIN task to match the two lists into a single file with two columns (check the lists so they don't have blank lines, etc), then the code would look something like[code:1:7ec9b2ff90]
join (imlist, "input", "merged.txt")
list = "merged.txt"
while (fscan (list, s1, s2) != EOF) {
hedit (s1, "field", s2, add+, up+, ver-)
}
[/code:1:7ec9b2ff90]In this case, each line of the 'merged.txt' is the name and number, and you update a single image with a single number. Is this what you wanted?-Mike
|
|
|
|
sebastian |
07/23/2009 03:43AM
|
|
|
Status: offline
Registered: 03/20/2007
Posts: 45
|
Yes! That was exactly what I was trying to do.
Now, the only thing is that running your code it seems that s1 is the actual file "merged.txt", so hedit complains that it cannot open the image merged.txt, endlessly.
[code:1:c2a34287e7]
oinlines ("imlist", "input", >& "merged.txt")
list = "merged.txt"
while (fscan (list, s1, s2) != EOF) {
hedit (s1, "UPS", s2, add+, up+, ver-)
}
[/code:1:c2a34287e7]list was defined as string, s1 and s2 already consider as strings.
Should list be defined as struct?
seba
|
|
|
|
fitz |
07/23/2009 03:43AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
JOIN takes as input two filenames, in my posting 'imlist' was not quoted because it referred to a script variable (I assume so since that's how it was used in your original post), but 'input' WAS quoted because it was a literal filename (again, the way it was used originally). The unix equivalent command is 'paste', in either case you should check the list produced, chances are this stage doesn't need to be in the script since the merged file can be produced beforehand.
|
|
|
|
sebastian |
07/23/2009 03:43AM
|
|
|
Status: offline
Registered: 03/20/2007
Posts: 45
|
Thanks fitz.
It works now!
It was part of a script that I needed.
The problem came because the input file wasn't defined as struct.
Also, with hedit, only the last parameter can be used as struct.
So s1 must be string and s2 as struct.
I will post it, mentioning your suggestions, of course!
Thank you once again!
|
|
|
|
| |
|