The reason this is an error is because the computer does not know if
the user meant

  foo 'it isn''t'
  foo 'it isnt'
  foo 'it isn' 't'
or whatever else...

Of course in that last example is guaranteed to be syntactically
invalid, but it could be made into something that could be
syntactically valid:

   0 foo 'it isn' 't'

and this gets into the reason that spelling errors and syntax errors
are different errors -- they represent likely [ambiguous] mistakes at
different stages of processing.

Anyways, if I was writing a user interface that had to deal with this
issue, I would not mutate the user's text -- instead, I would let the
user know as early as possible that they are not done yet.  I would
probably grey out the submit button and either colorize the text where
that seems to be causing the problem or I would include some kind of
textual warning (unbalanced quotes) or whatever else.  (Much like J
shades a string reddish when quotes are not balanced.)

If the user did not need the full power of J, I might give them
another out:  dock-able named string entry boxes.

In other words, instead of a single text entry box like this:

+--------------+
|foo 'it isn't'|
+--------------+

support something like this (needs fixed width font to make sense):

+--------+         +--------+
|foo STR1|  STR1 = |it isn't|
+--------+         +--------+


Your csv entry proposal sounds like a variation on this theme and
might be more appropriate for your users?  (If so, I imagine that
there are a lot of relevant things going on, which are not described
in this thread.)

On Sun, Feb 12, 2012 at 10:54 AM, R.E. Boss <r.e.b...@planet.nl> wrote:
> My point is that if my verb foo is presented to my user, then I must be able
> to handle within foo that she can do something like
>
>       foo 'it isn't'
> |open quote
> |          foo 'it isn't'
> |                       ^
>
> I want  'it isn't'  to be modified to  'it isn''t' , after which the
> processing can begin.
>
>
> R.E. Boss
>
>
>> -----Oorspronkelijk bericht-----
>> Van: programming-boun...@jsoftware.com [mailto:programming-
>> boun...@jsoftware.com] Namens Henry Rich
>> Verzonden: zondag 12 februari 2012 16:28
>> Aan: Programming forum
>> Onderwerp: Re: [Jprogramming] quote problem
>>
>> Dan's solution
>>
>>     ''''&([,(>:@:= # ]),[) 'old''string'
>> 'old''string'
>>
>> seems to fill the bill, except for the part about leaving the string as
>> is if it starts & ends with a quote.  If you do that, how do you handle
>>
>>    'it isn't'
>>
>> and
>>
>>    'it isn''t'
>>
>> where the user first did, and second did not, properly double quotes?
>>
>> Henry Rich
>>
>>
>> On 2/12/2012 9:40 AM, R.E. Boss wrote:
>> > The (input) string should be considered as one group (of chars).
>> > Quoting is needed if the first or the last (or both) is not a quote, all
>> > inside quotes should be doubled if they are not.
>> >
>> >
>> > R.E. Boss
>> >
>> >
>> >> -----Oorspronkelijk bericht-----
>> >> Van: programming-boun...@jsoftware.com [mailto:programming-
>> >> boun...@jsoftware.com] Namens Don Guinn
>> >> Verzonden: zondag 12 februari 2012 14:03
>> >> Aan: Programming forum
>> >> Onderwerp: Re: [Jprogramming] quote problem
>> >>
>> >> Given the string contains several groups of non-blanks, would each
> group
>> >> need to be surrounded with quotes and quotes within it doubled if not a
>> >> number, or only if it contained one or more quotes? Or should the
> string
>> > be
>> >> considered as one group? Again, when would quoting be needed?
>> >>
>> >> On Sun, Feb 12, 2012 at 1:17 AM, R.E. Boss<r.e.b...@planet.nl>  wrote:
>> >>
>> >>> The problem boils down to the fact that J requires a string (of chars)
>> > to
>> >>> be
>> >>> enclosed in (single) quotes and the inside quotes have to be doubled.
>> >>> (Contrary to a spreadsheet (e.g.) where a cell is of type char if it
> is
>> > not
>> >>> a number.)
>> >>> But what if I don't want bother a user with these requirements, she
>> > enters
>> >>> a
>> >>> string  and my verb does the enclosing and doubling, if necessary?
>> >>>
>> >>>
>> >>> R.E. Boss
>> >>>
>> >>>
>> >>>> -----Oorspronkelijk bericht-----
>> >>>> Van: programming-boun...@jsoftware.com [mailto:programming-
>> >>>> boun...@jsoftware.com] Namens Dan Bron
>> >>>> Verzonden: zaterdag 11 februari 2012 20:35
>> >>>> Aan: J Programming
>> >>>> Onderwerp: Re: [Jprogramming] quote problem
>> >>>>
>> >>>> Oh, just saw Henry's response and he interpreted your question
>> >>> differently.
>> >>>>
>> >>>> If you're not typing these strings in, then what is the source?  And
>> > what
>> >>> is
>> >>>> processing them (is it ;: ? if it's ". there's more to worry about
>> > than
>> >>> proper
>> >>>> quoting).
>> >>>>
>> >>>> Anyway, if the strings are coming from e.g. a file and the trouble is
>> >>> with
>> >>>> parsing them using ;: (instead of evaluating them in the immex
>> > session),
>> >>> then
>> >>>> you could try something along the lines of  (#~ 2 * '''' = ]) y
> (i.e.
>> >>> double
>> >>>> singleton quotes).
>> >>>>
>> >>>> -Dan
>> >>>>
>> >>>> Please excuse typos; composed on a handheld device.
>> >>>>
>> >>>> -----Original Message-----
>> >>>> From: Dan Bron<j...@bron.us>
>> >>>> Sender: programming-boun...@jsoftware.com
>> >>>> Date: Sat, 11 Feb 2012 14:05:16
>> >>>> To: Programming forum<programming@jsoftware.com>
>> >>>> Reply-To: Programming forum<programming@jsoftware.com>
>> >>>> Subject: Re: [Jprogramming] quote problem
>> >>>>
>> >>>> Unlike C, where \ introduces an escape sequence within string
>> > liberals,
>> >>> in
>> >>> J,
>> >>>> the only special character in a literal is ' (single quote).
>> >>>>
>> >>>> So, to embed quotes in strings, double them up:   a. i. '(`''3'   .
>> > Of
>> >>> course,
>> >>>> recursively embedded quotes need quadrupling, octupling, etc (eg 'he
>> >> said
>> >>>> ''she said ''''yes'''', but she lied'', if you can believe that').
>> >>>>
>> >>>> The syntax error in your first example is due to the juxtaposition of
>> > two
>> >>>> nouns, the string  '(`'  and the number 3 .
>> >>>>
>> >>>> -Dan
>> >>>>
>> >>>>
>> >>>> On Feb 11, 2012, at 1:04 PM, "R.E. Boss"<r.e.b...@planet.nl>  wrote:
>> >>>>
>> >>>>> If I want to process an arbitrary string, I may encounter a string
>> >>> which
>> >>>>> might give a "syntax error" or an "open quote" message.
>> >>>>>
>> >>>>> How can I detect such a situation and how can I repair the given
>> >>> string?
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>    a. i. '(`'3
>> >>>>>
>> >>>>> |syntax error
>> >>>>>
>> >>>>> |   a.    i.'(`'3
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>    a. i. '(`'3'
>> >>>>>
>> >>>>> |open quote
>> >>>>>
>> >>>>> |      a.i.'(`'3'
>> >>>>>
>> >>>>> |               ^
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> R.E. Boss
>> >>>>>
>> >>>>>
>> > ----------------------------------------------------------------------
>> >>>>> For information about J forums see
>> >>>> http://www.jsoftware.com/forums.htm
>> >>>>
> ----------------------------------------------------------------------
>> >>>> For information about J forums see
>> >> http://www.jsoftware.com/forums.htm
>> >>>>
> ----------------------------------------------------------------------
>> >>>> For information about J forums see
>> >> http://www.jsoftware.com/forums.htm
>> >>>
>> >>> ----------------------------------------------------------------------
>> >>> For information about J forums see
>> >> http://www.jsoftware.com/forums.htm
>> >>>
>> >> ----------------------------------------------------------------------
>> >> For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> >
>> > ----------------------------------------------------------------------
>> > For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> >
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to