Should i manually remove " " from first buffer, then combine them, and then again add " at begining and " at end of final buffer ? Is there any better way ? Ready to use example preffered of course. Thanks.
@Chris Yep, that mean removing manually " characters, then contain, and need to add them back to full string. Is there arexx function which mean "add character at begining and at end of string" ? I currently do it like this:
@Gazelle Yep thanks, that one works and looks better :)
@all Its in general about arexx script for sketchblock to save in os4 native icon format: It use netpbm and pngicon2amiga for conversion, checking the size of image (if it bigger than 256x256 it says that 256x256 max and need to rescale), as well as if you typed anything for save without ending it with ".info", then ".info" adds automatically to the filename (and if .info was added, then it skips).
Not only that it seems like you never heard of the logical or operator | nor of the keyword else, you obviously don't even consider reading (or understanding?) the docs about the functions you use.
I only read your script up to the part with .info, then I could not stop laughing.
verify(a,b) checks if the string a contains only letters also contained in the string b. If not, it returns the position of the character in a which is not contained in b.
So what your verify(".info",filename) does is, it verifies that ".info" only consists of characters also contained in filename. For example verify(".info","mainpart.four") will return 0 because all letters of .info are also contained in mainpart.four, but verify(".info","mainpart.six") will return 4 because f is the first letter in .info which is not contained in mainpart.six. In neither case your program will add ".info" to the file name because the result of verify is not 1.
@Thomas: After you finished laughing, perhaps it would have been useful to suggest an alternative solution.
@kas1e: As far as I can see, the main problem (about the .info suffix) is the misunderstanding about verify.
So if simply this line:
if verify('.info',outfile) = 1 then do
was changed to e.g.:
if lastpos('.info', outfile) < length(outfile) - 4 then do
- then that part should be working as intended, I believe. The new line checks that there is the string ".info" at the very end of the filename; lastpos makes sure it won't bother about an earlier ".info" (if anyone should be so weird as to suggest the filename "abc.infodef.info" ), and length minus 4 is where we would expect the .info to start for a correct icon filename. If it is not found at all, lastpos returns 0, which wil also be less than the length - 4, so that's covered too.
One missing check would be to ensure the filename is longer than 4 characters in the first place; if not, we will have a problem. But that is left as an exercise .
BTW, I can recommend having ARexxGuide available when coding ARexx. Although it's old, it is really useful and easy to find your way around, and it's not like ARexx has changed since then. It is/was originally shareware; does anyone know if the original author is still around somewhere?
@thomas Are you programmer ? I could not stop laughing when i tryed your suggestions, as they didn't works, while NBache's one works at least (through add .info all the time because of -4, but with -5 is ok)
Also after reading a script briefly, i see that if .info was here initially, then " " symbols are strips, and so, output will be not "RAM DISK:aaa.info", but without " ", and conversion will not works because of space. So i add some stuff here:
if upper(right(outfile,5)) ~= '.INFO' then do
say ".info is NOT here!, so add"
outfile = '"' || outfile || ".info" || '"'
end
else do
outfile = '"' || outfile || '"'
end
Also seems that part:
if outfile = "" | right(outfile,1) = ':' | right(outfile,1) = '/' then do
say "requester cancelled or no file name given"
exit
end
Works only when no file name was given, but it didn't triggers when i press "chancel" in asl requester.
Quote:
One thing left, though: in the beginning you make big effort to create unique file names and in the end you just use ram:tmpfile and ram:mask.
It is need it (to save mask separately from file, and to have in end normal png with transparency, which in end can be normally converted to icon)
Edited by kas1e on 2013/1/3 11:26:42 Edited by kas1e on 2013/1/3 11:31:10
An ADDRESS SKETCHBLOCK is missing in front of it. I changed the global address to COMMAND because there are many commands sent to COMMAND but only two commands sent to SKETCHBLOCK. Forgot to change the second one.
Quote:
Also after reading a script briefly, i see that if .info was here initially, then " " symbols are strips, and so, output will be not "RAM DISK:aaa.info", but without " ", and conversion will not works because of space. So i add some stuff here:
That's right. I forgot this because usually I don't put quotation marks into the variable which holds the file name but into the command line. This script is different.
Quote:
Also seems that part:
Works only when no file name was given, but it didn't triggers when i press "chancel" in asl requester.
What does outfile contain if cancel is pressed?
Quote:
It is need it (to save mask separately from file, and to have in end normal png with transparency, which in end can be normally converted to icon)
I know how the process works. My criticism was about using fixed global file names in one place but trying to use process-dependent unique file names in another place. If you use hard-coded ram:xyz in one place you can skip the effort to create unique names in the other places, too.
@Thomas Modified script with all your suggestions, there is
Only that i can't detect when "chancel" is pressed in asl-requester (i put before error: label, "say outfile" and when i press chancel in asl req it says OUTFILE), like its empty or kind.
Maybe the following snippet can give you inspiration?
/* TestSavereq.rexx */
options results
address command 'requestfile savemode pattern #?.info to RAM:xyz'
if RC > 0 then say 'Cancelled'
else do
if open('tmpf', 'RAM:xyz', 'r') then do
ofn = strip(readln('tmpf'), 'B', '"')
call close('tmpf')
say ofn
end
end