| 
      
      
      From: Carlos G. <cg...@ya...> - 2005-07-06 19:25:10
       | 
| I am getting a invalid result when use STRING verb. The sample above has 3 similar STRINGs,  using DELIMITED BY SPACES the result is strange!!
 
Can anybody help me?
 
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PROG.
       AUTHOR. S.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           DECIMAL-POINT IS COMMA.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WRESULT     PIC X(100) VALUE SPACES.
       01  WTEXT     PIC X(100) VALUE SPACES.
       01  WTEXT1    PIC X(10) VALUE "12345     ".
       01  W9        PIC 999 VALUE 999.
       PROCEDURE DIVISION.
       PARAG.
           STRING "INSERT INTO TEST ",
           ",",W9,
           ",","'",
           WTEXT1 DELIMITED BY SPACES, "'",
          ");" INTO WRESULT.
         DISPLAY WRESULT.
          MOVE SPACES TO WRESULT.
           STRING "INSERT INTO TEST ",
           ",",W9,
           ",","'",
           WTEXT1 DELIMITED BY SIZE, "'",
          ");" INTO WRESULT.
         DISPLAY WRESULT.
          MOVE SPACES TO WRESULT.
           STRING "INSERT INTO TEST ",
           ",",W9,
           ",","'",
           WTEXT1 , "'",
          ");" INTO WRESULT.
         DISPLAY WRESULT.
         STOP RUN.
 
Result in:
 
 
DISPLAY 1--> INSERT,999,'12345');
DISPLAY 2--> INSERT INTO TEST ,999,'12345     ');
DISPLAY 3--> INSERT INTO TEST ,999,'12345     ');
		
---------------------------------
Yahoo! Acesso Grátis: Internet rápida e grátis. Instale o discador agora! | 
| 
      
      
      From: David E. <de...@us...> - 2005-07-07 06:05:15
       | 
| Yes, there are several problems here.
First the TC grammar does not conform to the COBOL85 standard.
Syntax:
STRING {
{identifier-1 | literal-1}...
DELIMITED [BY]
{identifier-2 | literal-2 | SIZE }
}...
INTO identifier-3
So the following grammar is invalid,
STRING ...
WTEXT1 DELIMITED BY SIZE,
"'", ");"
INTO WRESULT.
STRING ...
");"
INTO WRESULT.
and should be as follows;
STRING ...
WTEXT1 DELIMITED BY SIZE,
"'" ");" DELIMITED BY SIZE,
INTO WRESULT.
STRING ...
");" DELIMITED ...
INTO WRESULT.
The second problem is invalid output, may be (or not) related to the 
grammar problem.
So further investigation will be required.
Carlos Gomes wrote:
 > I am getting a invalid result when use STRING verb.
 > The sample above has 3 similar STRINGs, using DELIMITED
 > BY SPACES the result is strange!!
 > ...
 > WORKING-STORAGE SECTION.
 > 01  WRESULT     PIC X(100) VALUE SPACES.
 > 01  WTEXT     PIC X(100) VALUE SPACES.
 > 01  WTEXT1    PIC X(10) VALUE "12345     ".
 > 01  W9        PIC 999 VALUE 999.
 > PROCEDURE DIVISION.
 > PARAG.
 > STRING "INSERT INTO TEST ",
 >  ",",W9,
 >  ",","'",
 >  WTEXT1 DELIMITED BY SPACES, "'",
 >  ");" INTO WRESULT.
 > DISPLAY WRESULT.
 > MOVE SPACES TO WRESULT.
 > STRING "INSERT INTO TEST ",
 >  ",",W9,
 >  ",","'",
 >  WTEXT1 DELIMITED BY SIZE, "'",
 >  ");" INTO WRESULT.
 > DISPLAY WRESULT.
 > MOVE SPACES TO WRESULT.
 > STRING "INSERT INTO TEST ",
 >  ",",W9,
 >  ",","'",
 >  WTEXT1 , "'",
 >  ");" INTO WRESULT.
 > DISPLAY WRESULT.
 > STOP RUN.
 >
 > Result in:
 >
 > DISPLAY 1--> INSERT,999,'12345');
 > DISPLAY 2--> INSERT INTO TEST ,999,'12345     ');
 > DISPLAY 3--> INSERT INTO TEST ,999,'12345     ');
 | 
| 
      
      
      From: David E. <de...@us...> - 2005-07-07 18:17:55
       | 
| David Essex wrote:
> Yes, there are several problems here. 
> First the TC grammar does not conform to the COBOL85 standard.
> 
> Syntax:
> STRING {
> {identifier-1 | literal-1}...
> DELIMITED [BY]
> {identifier-2 | literal-2 | SIZE }
> }...
> INTO identifier-3
> ...
OK, I was wrong, and the two books I consulted were wrong.
I'm not sure if this was part of the original COBOL 1985 standard, or a 
later modification, but according to the COBOL 1989 (draft) standard:
STRING ...
The DELIMITED phrase may be omitted only immediately preceding the INTO 
phrase. If it is omitted, DELIMITED BY SIZE is implied.
> Carlos Gomes wrote:
> 
>> I am getting a invalid result when use STRING verb.
>> The sample above has 3 similar STRINGs, using DELIMITED
>> BY SPACES the result is strange!!
>> ...
>> Result in:
>>
>> DISPLAY 1--> INSERT,999,'12345');
>> DISPLAY 2--> INSERT INTO TEST ,999,'12345     ');
>> DISPLAY 3--> INSERT INTO TEST ,999,'12345     ');
I don't see what the problem is.
Exactly what output did you expect ?
 | 
| 
      
      
      From: Carlos G. <cg...@ya...> - 2005-07-09 10:32:35
       | 
| David
 
In the test program above, the second display (results of String verb using DELIMITED BY SPACES) generate a strange output. DEMILITED BY SPACES in the fourth string causes a truncation in the first string (by default DEMILITED BY SIZE). 
 
DISPLAY 3, including DELIMITED BY SIZE explicity in the first string, generates the expected output.
 
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWPROG.
       AUTHOR. SW.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           DECIMAL-POINT IS COMMA.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  W1.
           03 A1  PIC 9(01).
           03 A2  PIC 9(02).
           03 A3  PIC 9(03).
           03 A4  PIC 9(04).
       01  W2.
           03 B1  PIC 9(01).
           03 B2  PIC 9(02).
           03 B3  PIC 9(03).
       01  WRESULT     PIC X(100) VALUE SPACES.
       01  WTEXT     PIC X(100) VALUE SPACES.
       01  WTEXT1    PIC X(10) VALUE "12345     ".
       01  W9        PIC 999 VALUE 999.
       PROCEDURE DIVISION.
       PARAG.
         MOVE SPACES TO WRESULT.
         STRING "INSERT INTO TEST ",
             ",",
             W9,
             ",",
      *       WTEXT1 DELIMITED BY SPACES,
             ");" INTO WRESULT.
         DISPLAY "1-" WRESULT.
         MOVE SPACES TO WRESULT.
         STRING "INSERT INTO TEST " ,
             ",",
             W9,
             ",",
             WTEXT1 DELIMITED BY SPACES,
             ");" INTO WRESULT.
         DISPLAY "2-" WRESULT.
         MOVE SPACES TO WRESULT.
         STRING "INSERT INTO TEST " DELIMITED BY SIZE,
             ",",
             W9,
             ",",
             WTEXT1 DELIMITED BY SPACES,
             ");" INTO WRESULT.
         DISPLAY "3-" WRESULT.
         MOVE SPACES TO WRESULT.
         STRING "INSERT INTO TEST ",
             ",",
             W9,
             ",",
             WTEXT1 ,
            ");" INTO WRESULT.
         DISPLAY "4-" WRESULT.
         STOP RUN.
 
 
Results:
 
 
1-INSERT INTO TEST ,999,);
2-INSERT,999,12345);
3-INSERT INTO TEST ,999,12345);
4-INSERT INTO TEST ,999,12345     );
David Essex <de...@us...> escreveu:
David Essex wrote:
> Yes, there are several problems here. 
> First the TC grammar does not conform to the COBOL85 standard.
> 
> Syntax:
> STRING {
> {identifier-1 | literal-1}...
> DELIMITED [BY]
> {identifier-2 | literal-2 | SIZE }
> }...
> INTO identifier-3
> ...
OK, I was wrong, and the two books I consulted were wrong.
I'm not sure if this was part of the original COBOL 1985 standard, or a 
later modification, but according to the COBOL 1989 (draft) standard:
STRING ...
The DELIMITED phrase may be omitted only immediately preceding the INTO 
phrase. If it is omitted, DELIMITED BY SIZE is implied.
> Carlos Gomes wrote:
> 
>> I am getting a invalid result when use STRING verb.
>> The sample above has 3 similar STRINGs, using DELIMITED
>> BY SPACES the result is strange!!
>> ...
>> Result in:
>>
>> DISPLAY 1--> INSERT,999,'12345');
>> DISPLAY 2--> INSERT INTO TEST ,999,'12345 ');
>> DISPLAY 3--> INSERT INTO TEST ,999,'12345 ');
I don't see what the problem is.
Exactly what output did you expect ?
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Tin...@li...
https://lists.sourceforge.net/lists/listinfo/tiny-cobol-users
__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/  | 
| 
      
      
      From: David E. <de...@us...> - 2005-07-09 18:31:53
       | 
| Carlos Gomes wrote:
 > In the test program above, the second display (results of String verb
 > using DELIMITED BY SPACES) generate a strange output. DEMILITED BY
 > SPACES in the fourth string causes a truncation in the first string
 > (by default DEMILITED BY SIZE).
 > DISPLAY 3, including DELIMITED BY SIZE explicity in the first string,
 > generates the expected output.
If I understand you correctly, the second display is generating this output,
2-INSERT,999,12345);
and should be generating this output,
2-INSERT INTO TEST ,999,12345);
correct ?
I've looked at the COBOL 1989 (draft) standard, and I think TC is
generating the correct output '2-INSERT,999,12345);', for the following
reasons.
The figurative constant SPACES (literal) is equivalent to " " (single
space).
Thus the phrase 'DELIMITED BY SPACES' is equivalent to
'DELIMITED BY " "'.
And the literal 'INSERT INTO TEST ' gets truncated to 'INSERT'.
BTW, what are other commercial compilers generating ?
Syntax:
STRING {
{identifier-1 | literal-1}...
DELIMITED [BY]
{identifier-2 | literal-2 | SIZE }
}...
INTO identifier-3
COBOL standard:
14.10.39 STRING statement
...
14.10.39.3 General rules
...
3) When a figurative constant is specified as literal-1 or literal-2, it
refers to an implicit one character data item whose usage shall be the
same as the usage of identifier-3, either display or national.
 | 
| 
      
      
      From: Fred M. <fr...@mo...> - 2005-07-09 20:39:00
       | 
| David Essex wrote: > > Carlos Gomes wrote: > > > In the test program above, the second display (results of String verb > > using DELIMITED BY SPACES) generate a strange output. DEMILITED BY > > SPACES in the fourth string causes a truncation in the first string > > (by default DEMILITED BY SIZE). > > DISPLAY 3, including DELIMITED BY SIZE explicity in the first string, > > generates the expected output. > > If I understand you correctly, the second display is generating this output, > > 2-INSERT,999,12345); > > and should be generating this output, > > 2-INSERT INTO TEST ,999,12345); > > correct ? > > I've looked at the COBOL 1989 (draft) standard, and I think TC is > generating the correct output '2-INSERT,999,12345);', for the following > reasons. > > The figurative constant SPACES (literal) is equivalent to " " (single > space). > Thus the phrase 'DELIMITED BY SPACES' is equivalent to > 'DELIMITED BY " "'. > And the literal 'INSERT INTO TEST ' gets truncated to 'INSERT'. David, you are correct. I cannot read the original message from Carlos Gomes because of the message format but I often used DELIMITED BY SIZE or DELIMITED BY " " (two space characters between quotes). The latter works just fine in COBOL in case intermediate spaces are present in a sending field. -- Fred Mobach - fr...@mo... - pos...@mo... Systemhouse Mobach bv - The Netherlands - since 1976 website : http://fred.mobach.nl Q: servos ad pileum vocare ? A: servos fenestrae ad pileum rubrem vocare ! | 
| 
      
      
      From: Carlos G. <cg...@ya...> - 2005-07-10 22:04:26
       | 
| David
 
String verb that has strage output has no DELIMITED in  first token (by default DELIMITED BY SIZE). DELIMITED BY SPACES is used only in WTEXT1 token (with a value of "12345     ") . It seems that using DELIMITED BY SPACES only in one token does the compiler to use this option in every token of the command.
 
 
         STRING "INSERT INTO TEST " ,  <<<--- No DELIMITED (Default BY SIZE)
             ",",
             W9,
             ",",
             WTEXT1 DELIMITED BY SPACES,
             ");" INTO WRESULT.
Result:
 
INSERT,999,12345);
 
Using DELIMITED BY SIZE in first token gives the correct result. 
 
         STRING "INSERT INTO TEST " DELIMITED BY SIZE,
             ",",
             W9,
             ",",
             WTEXT1 DELIMITED BY SPACES,
             ");" INTO WRESULT.
Result:
 
INSERT INTO TEST ,999,12345);
 
It looks like default DELIMITED BY SIZE doesn´t be use by TC in this case.
 
David Essex <de...@us...> escreveu:
Carlos Gomes wrote:
> In the test program above, the second display (results of String verb
> using DELIMITED BY SPACES) generate a strange output. DEMILITED BY
> SPACES in the fourth string causes a truncation in the first string
> (by default DEMILITED BY SIZE).
> DISPLAY 3, including DELIMITED BY SIZE explicity in the first string,
> generates the expected output.
If I understand you correctly, the second display is generating this output,
2-INSERT,999,12345);
and should be generating this output,
2-INSERT INTO TEST ,999,12345);
correct ?
I've looked at the COBOL 1989 (draft) standard, and I think TC is
generating the correct output '2-INSERT,999,12345);', for the following
reasons.
The figurative constant SPACES (literal) is equivalent to " " (single
space).
Thus the phrase 'DELIMITED BY SPACES' is equivalent to
'DELIMITED BY " "'.
And the literal 'INSERT INTO TEST ' gets truncated to 'INSERT'.
BTW, what are other commercial compilers generating ?
Syntax:
STRING {
{identifier-1 | literal-1}...
DELIMITED [BY]
{identifier-2 | literal-2 | SIZE }
}...
INTO identifier-3
COBOL standard:
14.10.39 STRING statement
...
14.10.39.3 General rules
...
3) When a figurative constant is specified as literal-1 or literal-2, it
refers to an implicit one character data item whose usage shall be the
same as the usage of identifier-3, either display or national.
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Tin...@li...
https://lists.sourceforge.net/lists/listinfo/tiny-cobol-users
		
---------------------------------
Yahoo! Acesso Grátis: Internet rápida e grátis. Instale o discador agora! | 
| 
      
      
      From: David E. <de...@us...> - 2005-07-11 00:22:49
       | 
| Carlos Gomes wrote:
 > String verb that has strage output has no
 > DELIMITED in first token (by default DELIMITED
 > BY SIZE). DELIMITED BY SPACES is used only
 > in WTEXT1 token (with a value of "12345     ").
 > It seems that using DELIMITED BY SPACES
 > only in one token does the compiler to use
 > this option in every token of the command.
 >
 > STRING
 > "INSERT INTO TEST " , <<<--- No DELIMITED (Default BY SIZE)
 > ",",
 > W9,
 > ",",
 > WTEXT1 DELIMITED BY SPACES,
 > ");"
 > INTO WRESULT.
 >
 > Result:
 > INSERT,999,12345);
 >
 > Using DELIMITED BY SIZE in first token gives the correct result.
 >
 > STRING
 > "INSERT INTO TEST " DELIMITED BY SIZE,
 > ",",
 > W9,
 > ",",
 > WTEXT1 DELIMITED BY SPACES,
 > ");"
 > INTO WRESULT.
 >
 > Result:
 > INSERT INTO TEST ,999,12345);
 >
 > It looks like default DELIMITED BY SIZE doesn´t
 > be use by TC in this case.
I do not agree.
If you look at the syntax below, the 'DELIMITED' phrase of the 'STRING' 
statement can have more than one argument (ie. {identifier-1 | 
literal-1}...).
Thus the "INSERT INTO TEST " literal is part of the 'DELIMITED BY 
SPACES' phrase.
The COBOL 89 draft standard (not in COBOL 85) states that if (and only 
if) the last token before the INTO phrase, does not have a 'DELIMITED' 
clause, then that token(s) defaults to a 'DELIMITED BY SIZE'
Thus in the above examples the '");" INTO WRESULT' is equivalent to 
'");" DELIMITED BY SIZE INTO WRESULT'.
I've also compiled and run the sample program provided, using an old 
commercial COBOL compiler. It's output is identical to TC.
So unless some one can produce proof to the contrary, using a commercial 
grade COBOL compiler, I think we can put this matter to rest.
The COBOL 89 draft standard:
14.10.39  STRING statement
...
14.10.39.1 General format
...
 | 
| 
      
      
      From: David E. <de...@us...> - 2005-07-11 00:38:58
       | 
| Sorry the first messege got truncated.
Carlos Gomes wrote:
 > String verb that has strage output has no
 > DELIMITED in first token (by default DELIMITED
 > BY SIZE). DELIMITED BY SPACES is used only
 > in WTEXT1 token (with a value of "12345     ").
 > It seems that using DELIMITED BY SPACES
 > only in one token does the compiler to use
 > this option in every token of the command.
 >
 > STRING
 > "INSERT INTO TEST " , <<<--- No DELIMITED (Default BY SIZE)
 > ",",
 > W9,
 > ",",
 > WTEXT1 DELIMITED BY SPACES,
 > ");"
 > INTO WRESULT.
 >
 > Result:
 > INSERT,999,12345);
 >
 > Using DELIMITED BY SIZE in first token gives the correct result.
 >
 > STRING
 > "INSERT INTO TEST " DELIMITED BY SIZE,
 > ",",
 > W9,
 > ",",
 > WTEXT1 DELIMITED BY SPACES,
 > ");"
 > INTO WRESULT.
 >
 > Result:
 > INSERT INTO TEST ,999,12345);
 >
 > It looks like default DELIMITED BY SIZE doesn´t
 > be use by TC in this case.
I do not agree.
If you look at the syntax below, the 'DELIMITED' phrase of the 'STRING'
statement can have more than one argument (ie. {identifier-1 |
literal-1}...).
Thus the "INSERT INTO TEST " literal is part of the 'DELIMITED BY
SPACES' phrase.
The COBOL 89 draft standard (not in COBOL 85) states that if (and only
if) the last token before the INTO phrase, does not have a 'DELIMITED'
clause, then that token(s) defaults to a 'DELIMITED BY SIZE'
Thus in the above examples the '");" INTO WRESULT' is equivalent to
'");" DELIMITED BY SIZE INTO WRESULT'.
I've also compiled and run the sample program provided, using an old
commercial COBOL compiler. It's output is identical to TC.
So unless some one can produce proof to the contrary, using a commercial
grade COBOL compiler, I think we can put this matter to rest.
The COBOL 89 draft standard:
14.10.39  STRING statement
...
14.10.39.1 General format
...
Syntax:
STRING {
{identifier-1 | literal-1}...
DELIMITED [BY]
{identifier-2 | literal-2 | SIZE }
}...
INTO identifier-3
...
4.10.39.2 Syntax rules
...
8) The DELIMITED phrase may be omitted only immediately preceding the 
INTO phrase. If it is omitted, DELIMITED BY SIZE is implied.
...
 | 
| 
      
      
      From: Jim M. <ro...@vi...> - 2005-07-11 15:14:41
       | 
| My 2 cents worth...
David is 100% correct.
In the string statement, the delimitter is defined by the "next"=20
DELIMITED BY" statement that is encountered.  This is the normal usage=20
of STRING...
STRING VAR1 VAR2 VAR3 DELIMITED BY SPACES
                VAR2 VAR3 VAR4 DELIMITED BY SIZE
                 VAR5 VAR6 DELIMITED BY SPACES
                 VAR 7 VAR8 DELIMITED BY "#"
                                INTO WHATEVER.
Jim Morcombe
David Essex wrote:
> Sorry the first messege got truncated.
>
> Carlos Gomes wrote:
>
> > String verb that has strage output has no
> > DELIMITED in first token (by default DELIMITED
> > BY SIZE). DELIMITED BY SPACES is used only
> > in WTEXT1 token (with a value of "12345     ").
> > It seems that using DELIMITED BY SPACES
> > only in one token does the compiler to use
> > this option in every token of the command.
> >
> > STRING
> > "INSERT INTO TEST " , <<<--- No DELIMITED (Default BY SIZE)
> > ",",
> > W9,
> > ",",
> > WTEXT1 DELIMITED BY SPACES,
> > ");"
> > INTO WRESULT.
> >
> > Result:
> > INSERT,999,12345);
> >
> > Using DELIMITED BY SIZE in first token gives the correct result.
> >
> > STRING
> > "INSERT INTO TEST " DELIMITED BY SIZE,
> > ",",
> > W9,
> > ",",
> > WTEXT1 DELIMITED BY SPACES,
> > ");"
> > INTO WRESULT.
> >
> > Result:
> > INSERT INTO TEST ,999,12345);
> >
> > It looks like default DELIMITED BY SIZE doesn=B4t
> > be use by TC in this case.
>
> I do not agree.
>
> If you look at the syntax below, the 'DELIMITED' phrase of the 'STRING'
> statement can have more than one argument (ie. {identifier-1 |
> literal-1}...).
> Thus the "INSERT INTO TEST " literal is part of the 'DELIMITED BY
> SPACES' phrase.
>
> The COBOL 89 draft standard (not in COBOL 85) states that if (and only
> if) the last token before the INTO phrase, does not have a 'DELIMITED'
> clause, then that token(s) defaults to a 'DELIMITED BY SIZE'
>
> Thus in the above examples the '");" INTO WRESULT' is equivalent to
> '");" DELIMITED BY SIZE INTO WRESULT'.
>
> I've also compiled and run the sample program provided, using an old
> commercial COBOL compiler. It's output is identical to TC.
>
> So unless some one can produce proof to the contrary, using a commercia=
l
> grade COBOL compiler, I think we can put this matter to rest.
>
>
> The COBOL 89 draft standard:
>
> 14.10.39  STRING statement
> ...
> 14.10.39.1 General format
> ...
> Syntax:
> STRING {
> {identifier-1 | literal-1}...
> DELIMITED [BY]
> {identifier-2 | literal-2 | SIZE }
> }...
> INTO identifier-3
> ...
>
> 4.10.39.2 Syntax rules
> ...
> 8) The DELIMITED phrase may be omitted only immediately preceding the=20
> INTO phrase. If it is omitted, DELIMITED BY SIZE is implied.
> ...
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar=20
> happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dua=
l
> core and dual graphics technology at this free one hour event hosted=20
> by HP, AMD, and NVIDIA.  To register visit=20
> http://www.hp.com/go/dualwebinar
> _______________________________________________
> Tin...@li...
> https://lists.sourceforge.net/lists/listinfo/tiny-cobol-users
>
>
 |