Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageI 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?
Post Follow-up to this messageYou 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
>
Post Follow-up to this messageHi!
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...
Post Follow-up to this messageDenis 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
Post Follow-up to this message"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. :-)
Post Follow-up to this messageMichael 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.