Home > Archive > Smalltalk > October 2004 > "withCRs" problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Michael Bielser 2004-10-27, 8:57 am |
| Hi
In VW 7.2, I'm trying to create a Dialog like this:
str := 'compilation error(s); see\' , lst , '\for details.\' withCRs.
Dialog warn: str.
"lst" is the name of a file. However, VW does not replace ALL
backslashes with CRs; in my case it leaves the first backslash (the one
after "see") as backslash. Why? What am I doing wrong? Or is it a bug?
Thanks for your help
Mike
| |
| Michael Bielser 2004-10-27, 8:57 am |
| I just found out (trial and error) a solution:
str := ('compilation error(s); see\',lst,'\for details.\') withCRs.
Dialog warn: str
However, it escapes me why I need parenthesis here; can anybody please
explain this?
| |
| Denis Johnson 2004-10-27, 8:57 am |
| You are only sending withCRs to the last string in your line of code. In
short I think you need a set of brackets so that withCRs is sent to the
final concatenated string i.e.
str := ('compilation error(s); see' , lst , '\for details.') withCRs
hth, Denis
Michael Bielser wrote:
> Hi
> In VW 7.2, I'm trying to create a Dialog like this:
>
> str := 'compilation error(s); see' , lst , '\for details.' withCRs.
> Dialog warn: str.
>
> "lst" is the name of a file. However, VW does not replace ALL
> backslashes with CRs; in my case it leaves the first backslash (the one
> after "see") as backslash. Why? What am I doing wrong? Or is it a bug?
>
> Thanks for your help
> Mike
>
| |
| Michael Voss 2004-10-27, 8:57 am |
| Hi!
Michael Bielser wrote:
> str := ('compilation error(s); see',lst,'\for details.') withCRs.
> Dialog warn: str
>
> However, it escapes me why I need parenthesis here; can anybody please
> explain this?
The unary message "withCRs" will be evaluated before the binary message ",",
so your statement
str := 'compilation error(s); see',lst,'\for details.' withCRs.
would be evaluated as follows:
1.) '\for details.' withCRs.
2.) 'compilation error(s); see',lst "no withCRs here"
3.) (result of 2) , (result of 1) "no withCRs here either"
4.) str := (result of 3)
So withCRs is a message sent to '\for details.' only...
| |
| Chris Uppal 2004-10-27, 8:57 am |
| Denis Johnson wrote:
> str := ('compilation error(s); see' , lst , '\for details.') withCRs
But note that this will behave oddly if the filename contains back-slashes (as
is common under Windows and legal, if rare, under Unix).
-- chris
| |
| Can Altinbay 2004-10-27, 3:59 pm |
| "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> wrote in message
news:1pednTslOr8P6eLcRVn-uw@nildram.net...
> Denis Johnson wrote:
>
>
> But note that this will behave oddly if the filename contains back-slashes
(as
> is common under Windows and legal, if rare, under Unix).
>
> -- chris
>
>
I would rather put something like this together using a stream woth nextPut:
and nextPutAll:.
Also, instead of having it in the body of the message that uses it, I would
have a method called something like compilationExceptionString which answers
it. Placing these in a protocol would make it easy to modify one or more
later, especially after those pesky Tech Writers get through with them. :-)
| |
| Vassili Bykov 2004-10-27, 3:59 pm |
| Michael Bielser wrote:
> Hi
> In VW 7.2, I'm trying to create a Dialog like this:
>
> str := 'compilation error(s); see' , lst , '\for details.' withCRs.
> Dialog warn: str.
>
> "lst" is the name of a file. However, VW does not replace ALL
> backslashes with CRs; in my case it leaves the first backslash (the one
> after "see") as backslash. Why? What am I doing wrong? Or is it a bug?
>
> Thanks for your help
> Mike
>
Apart from the precedence issue others explained, in VW there is a
better way to do this:
Dialog warn: ('Compilation error(s); see<n><1s><n>for details.<n>'
expandMacrosWith: fileName)
See the comment to class StringParameterSubstitution for details on what
<...> thingies are allowed. This version does not have the problem with
backslashes in file names Chris Uppal pointed out.
And as a style point, if you catch yourself explaining that 'lst' is a
the name of a file, that means 'lst' is not a good name.
--
Vassili Bykov
Tools Technical Lead, VisualWorks Engineering
v b y k o v A T c i n c o m D O T c o m
http://www.cincomsmalltalk.com/userblogs/vbykov
|
|
|
|
|