HOME  NEWS  FORUM  DOWNLOAD  LINK
OpenCOBOL - an open-source COBOL compiler
Main Menu
Download
Documentation
Development
Who's Online
11 user(s) are online (7 user(s) are browsing Forum)

Members: 0
Guests: 11

more...
Powered by
SourceForge

Xoops

Creative Commons

OpenCOBOL Forum Index
   OpenCOBOL
     select fname clause, Variable value as filename
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
shaj
Posted on: 2010/2/3 16:30
Just popping in
Joined: 2010/2/3
From:
Posts: 4
select fname clause, Variable value as filename
Does OpenCOBOL supports this usage ?
SELECT FILE fname ....
USING WS-FILE-NAME
WS-FILE-NAME is a working storage variable that can be populated at runtime.
jgt
Posted on: 2010/2/3 16:45
Not too shy to talk
Joined: 2010/1/18
From: 44.21.48N 80.50.15W
Posts: 26
Re: select fname clause, Variable value as filename
Yes it does.
You can do:

SELECT PRINT-FILE ASSIGN TO "$SPOOL/PRINTFILE"
where SPOOL is an environment name:
SPOOL=./spool/$LOGNAME; export SPOOL

then the print file will be ./spool/user/PRINTFILE

also

SELECT CUST ASSIGN TO WS-FILE-NAME

01 WS-FILE-NAME.
03 FILLER PIC X(4) VALUE 'CUST'.
03 WS-COMPANY-NUMBER PIC XX.
03 WS-FILLER PIC X(4) VALUE '.DAT'.

MOVE '01' TO WS-COMPANY-NUMBER
OPEN CUST


Jack
wmklein
Posted on: 2010/2/3 22:59
Home away from home
Joined: 2008/12/27
From:
Posts: 239
Re: select fname clause, Variable value as filename
The last reply was (sort-of) non-responsive. The reply tells you how you can use a "dynamic file name" but it does NOT answer the asked quesion of whether OC does or does not support the current ANSI/ISO Standard

  Select xxx USING data-name


syntax.

I am not certain whether OC does or doesn't support this (standard) syntax, but I think that is the question in this thread.
rkeane
Posted on: 2010/2/4 1:16
Just popping in
Joined: 2006/3/26
From: St Petersburg, FL
Posts: 9
Re: select fname clause, Variable value as filename
I've just tried a "Select xxx USING data-name" and received:Error: syntax error, unexpected USING, expecting SEQUENTIAL
human
Posted on: 2010/2/4 7:30
Home away from home
Joined: 2007/5/15
From:
Posts: 958
Re: select fname clause, Variable value as filename
If I understood it right the current draft says that these are the different possibilities with SELECT USING:
SELECT xxx ASSIGN USING data-name
SELECT xxx ASSIGN TO device-name USING data-name
SELECT xxx ASSIGN TO literal USING data-name

Do I read this right?

All rules for USING seem to be "Implementor-definied" and I found nothing about SELECT xxx ASSIGN [yyy] USING data-name in MF docs...

BTW: It's interesting that the commonly used version
SELECT xxx ASSIGN TO data-name
seems to be not according to the next standard.

I see this as a FR to support SELECT xxx ASSIGN [yyy] USING.

human
wmklein
Posted on: 2010/2/4 23:23
Home away from home
Joined: 2008/12/27
From:
Posts: 239
Re: select fname clause, Variable value as filename
You are correct that the reserverd word "ASSING" is required before USING data-name. (I had forgotten that).

As for the "commoon" ASSIGN data-name extension, it actually is NOT identically implemented by all vendors that have this extension.

In some cases, if you have ASSIGN xyz, the compiler and ruh-time will look for "xyz" as a data name first. In other cases they will look for an "environment variable" xyz first, and in still other cases they will look first for "external stuff" like JCL.

That is why the Standard explictly added ASSIGN USING so that the compiler would ALWAYS look for a data-name with the value of the file name.
human
Posted on: 2010/2/5 7:41
Home away from home
Joined: 2007/5/15
From:
Posts: 958
Re: select fname clause, Variable value as filename
Quote:

wmklein wrote:
That is why the Standard explictly added ASSIGN USING so that the compiler would ALWAYS look for a data-name with the value of the file name.


What does the following usage mean?
SELECT xxx ASSIGN TO literal USING data-name
I guess to use the literal and store the full path to data-name?


Here is a patch for the usage
SELECT xxx ASSIGN USING data-name

--- cobc/parser.y.old	Wed Feb 04 18:56:18 2009
+++ cobc/parser.y	Fri Feb 05 08:06:26 2010
@@ -1610,6 +1610,10 @@
   {
 	current_file->assign = cb_build_assignment_name (current_file, $5);
   }
+| ASSIGN USING assignment_data_name
+  {
+	current_file->assign = cb_build_assignment_name (current_file, $3);
+  }
 | ASSIGN _to _ext_clause DISK
   {
 	current_file->fileid_assign = 1;
@@ -1641,6 +1645,10 @@
 | qualified_word
 ;
 
+assignment_data_name:
+  qualified_word
+;
+
 
 /* ACCESS MODE clause */

This works like a charm, enabling
ASSIGN USING TEST-FILE-NAME
with both
       78  TEST-FILE-NAME            value 'TESTDAT'.
       77  TEST-FILE-NAME  pic X(20) value 'TESTDATVAR'.


I thought to patch the usage
SELECT xxx ASSIGN TO device-name USING data-name

it would suffice to add
| ASSIGN _to _device USING assignment_data_name
  {
	current_file->assign = cb_build_assignment_name (current_file, $5);
  }
to the same place in parser.y, but this leads to Quote:
conflicts: 121 shift/reduce; expected 118 shift/reduce conflicts
anybody knows how to add this proper to the parser?

human
btiffin
Posted on: 2010/2/6 13:50
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 755
Re: select fname clause, Variable value as filename
I've not thought through the implications of your parser change, and it's always deep thinking, even trivial changes, but the first meaningful line of parser.y will be %expect 118. change that to %expect 121 to test your changes.

Shift/Reduce issues in the cobc parser need careful examination. Is it a harmless s/r? Harmless being a state where either a shift OR a reduce would still provide a valid and acceptable semantically correct compile

http://dinosaur.compilertools.net/bison/bison_8.html#SEC70 has a pretty good explanation of the s/r issue using the famous 'dangling else' example.

Cheers,
Brian
human
Posted on: 2010/2/7 15:24
Home away from home
Joined: 2007/5/15
From:
Posts: 958
Re: select fname clause, Variable value as filename
Let Roger decide if we increase the expected shift/reduce issues or if he find a better way of implementation.

human
shaj
Posted on: 2010/2/26 14:26
Just popping in
Joined: 2010/2/3
From:
Posts: 4
Re: select fname clause, Variable value as filename
We use following syntax on IBM HOST
1. SELECT xxx ASSIGN TO HOSTFNAME

HOSTFNAME is set by JCL


Following syntax required for IBM COBOL compiler on WINDOWS

2. SELECT xxx ASSIGN [TO]
USING PC-VAR
here PC-VAR is a variable name which is set with in the program.

Following syntax is required for OPEN-COBOL on PC.

3. SELECT xxx ASSING TO PC-VAR

And default configuration file-mapping=yes needs to be changed to enable this.



Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 
Copyright (C) 2005 The OpenCOBOL Project. All rights reserved.
Powered by Xoops2 | PHP | MySQL | Apache
ocean-net