Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Script Error: Cannot use add on string! value

 [1/4] from: richard::coffre::francetelecom::com at: 10-Apr-2002 16:34


Hi, I got the following error : ** Script Error: Cannot use add on string! value ** Near: output: output + ".sty" In the code : file: to-file ask "Filename? " parse file [ copy output to "." ] output: output + ".sty" TIA Richard Coffre France Telecom Orbiscom T=E9l. : 01 47 61 46 28

 [2/4] from: tomc:darkwing:uoregon at: 10-Apr-2002 9:28


On Wed, 10 Apr 2002, COFFRE Richard FTO wrote:
> Hi, > I got the following error :
<<quoted lines omitted: 4>>
> parse file [ copy output to "." ] > output: output + ".sty"
output: join output [".sty"] output: rejoin [output ".sty"] append output ".sty" ...

 [3/4] from: greggirwin:mindspring at: 10-Apr-2002 10:53


Hi Richard, << file: to-file ask "Filename? " parse file [ copy output to "." ] output: output + ".sty" >> The + operator in REBOL is not a string concatenation operator. If you do help + in the console you'll see all the datatypes it supports. Use JOIN or APPEND instead of + to concatenate strings. You want to be careful searching for the first dot, as you are, because long filenames can contain embedded dots and the last one is what you want. Here's another approach, changing the value in place and using FIND/LAST.
>> file: "dummy.txt"
== "dummy.txt"
>> head change find/last file "." ".sty"
== "dummy.sty"
>> file: "dummy.2.txt"
== "dummy.2.txt"
>> head change find/last file "." ".sty"
== "dummy.2.sty" --Gregg

 [4/4] from: richard:coffre:francetelecom at: 11-Apr-2002 8:55


Thanks Gregg for this detail, I thought about this but because I'm new in Rebol I walk through step by step but your explanation will allow me to speed up. -----Message d'origine----- De : Gregg Irwin [mailto:[greggirwin--mindspring--com]] Envoy=E9 : mercredi 10 avril 2002 18:53 =C0 : [rebol-list--rebol--com] Objet : [REBOL] Re: Script Error: Cannot use add on string! value Hi Richard, << file: to-file ask "Filename? " parse file [ copy output to "." ] output: output + ".sty" >> The + operator in REBOL is not a string concatenation operator. If you do help + in the console you'll see all the datatypes it supports. Use JOIN or APPEND instead of + to concatenate strings. You want to be careful searching for the first dot, as you are, because long filenames can contain embedded dots and the last one is what you want. Here's another approach, changing the value in place and using FIND/LAST.
>> file: "dummy.txt"
== "dummy.txt"
>> head change find/last file "." ".sty"
== "dummy.sty"
>> file: "dummy.2.txt"
== "dummy.2.txt"
>> head change find/last file "." ".sty"
== "dummy.2.sty" --Gregg

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted