Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

COBOL F$EDIT

41 views
Skip to first unread message

Terry Marosites

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Hi all,

I want to an f$edit from COBOL if I call lib$do_command I don't come back
to my program
if I do a lib$spawn my symbol is set in the spawned process. does anyone
know an easy method of doing a f$edit from COBOL.

Thanks
Terry


JF Mezei

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Terry Marosites wrote:
> I want to an f$edit from COBOL if I call lib$do_command I don't come back
> to my program


I beleive that most of the functionality of F$edit is provided by the STR$ routines.

HELP RTL STR$ will give you a listing of the available routines.

From cobol, you can call these routines, and pass strings as arguments . It's
been a while, but you can do something such as

CALL "STR$UPCASE" USING destination-str by descriptor, source-str by descriptor.

David J. Dachtera

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Terry Marosites wrote:
>
> Hi all,

>
> I want to an f$edit from COBOL if I call lib$do_command I don't come back
> to my program
> if I do a lib$spawn my symbol is set in the spawned process. does anyone
> know an easy method of doing a f$edit from COBOL.

I have memories from long ago of being able to call the BAS$EDIT
function from BASIC run-time library from a non-BASIC 3GL. Perhaps
someone else will chime in with the specifics. I think I read it here
first a while back.

I don't have BASIC installed on my hobbyist Alpha just yet, and the
MicroVAX 3100 does not run just now. Otherwise I could compile the
following /MACHINE_CODE/LIST and post the machine code:

MAP (SAMPLE) &
STRING
TEST_STRING = 32%

A$ = EDIT$( TEST_STRING, 16% )

END PROGRAM

A MACRO coder could then divine the calling sequence to make BAS$EDIT
work in another language. Basically (no pun intended), you pass a string
by descriptor, a word integer by reference (I believe), and another
string by descriptor to receive the output of the function. The integer
is a bitmap of functions to perform: trim leading/trailing spaces,
upcase/locase/compress/collapse the string, string control characters,
etc. Trouble is, I don't have the doc.'s or a compiler available. I
don't know the sequence of arguments or the bits for the functions by
memory.

Now that I think about it, I think I saw that back in the 80's in a
DIBOL program. I may have the source on an old TK50, if I can spin up
the old MicroVAX (it has a TZ30)...

--
David J. Dachtera
dba DJE Systems
http://www.djesys.com/

Unofficial Affordable OpenVMS Home Page and Message Board:
http://www.djesys.com/vms/soho/

This *IS* an OpenVMS-related newsgroup. So, a certain bias in postings
is to be expected.

Feel free to exercise your rights of free speech and expression.

However, attacks against individual posters, or groups of posters, are
strongly discouraged.

Brian Schenkenberger, VAXman-

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to
In article <1137A4A23A51D311B2D6...@seantexch.unitedad.com>, Terry Marosites <TMaro...@unitedad.com> writes:
>Hi all,
>
> I want to an f$edit from COBOL if I call lib$do_command I don't come back
>to my program

LIB$DO_COMMAND will essentially queue the command and it will not be executed
until the image had rundown and terminated.

> if I do a lib$spawn my symbol is set in the spawned process. does anyone
>know an easy method of doing a f$edit from COBOL.

What do you want to do? Do you want to manipulate a DCL symbol within your
program or do you just want F$edit-like functions in your program?

There are STR$ RTLs which can do, quite easily too, some of the things that
the F$edit will/can do: STR$TRIM, STR$UPCASE; or with combinations of these
routines you can accomplish similar results.

David Dachtera suggests using the BASIC run-time support for the EDIT$ oper-
ator (VAX: BAS$EDIT, Alpha: DBASIC$EDIT). The format, at least for the Alpha
version, is DBASIC$EDIT(dest-string by descriptor, src-string by descriptor,
and an edit mask by value). You'd need to explore the BASIC EDIT$ operator
to learn the significance of the various mask bits. This would likely work
but I'm sure would be pooh-poohed by a number of folks hare as an unsupport-
ed hack.

I'd suggest you look into the STR$ routines. I don't do COBOL so I'm gues-
sing that it does not have very good string manipulation features itself if
you are asking for access to F$edit.


--
VAXman- OpenVMS APE certification number: AAA-0001 VAXman(at)TMESIS(dot)COM

city, n., 1. a place where trees are cut down and streets are named after them.

norm lastovica

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to
it is no problem at all to call bas$edit from other languages.
the first parameter is the character string to be edited (it
will be changed in place; if any of the edit "functions" that
you request could change the length of the string, I'd suggest
using a dynamic descriptor) and the second parameter is a bit
mask of the functions to perform. according to online help,
the valid functions are:

1% Trim parity bits
2% Discard all spaces and tabs
4% Discard characters: CR, LF, FF, ESC, RUBOUT, and NULL
8% Discard leading spaces and tabs
16% Reduce spaces and tabs to one space
32% Convert lowercase to uppercase
64% Convert [ to ( and ] to )
128% Discard trailing spaces and tabs
256% Do not alter characters inside quotes

and the bit definitions would then be:

trim_parity_bit = 0
disc_sp_tab_bit = 1
disc_junk_bit = 2
disc_lead_bit = 3
compact_bit = 4
upper_case_bit = 5
parens_bit = 6
disc_trail_bit = 7
ignor_quote_bit = 8


"David J. Dachtera" wrote:


>
> Terry Marosites wrote:
> >
> > Hi all,
> >
> > I want to an f$edit from COBOL if I call lib$do_command I don't come back
> > to my program

> > if I do a lib$spawn my symbol is set in the spawned process. does anyone
> > know an easy method of doing a f$edit from COBOL.
>

--
norman lastovica / oracle rdb engineering / usa / 610.696.4685

norm lastovica

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to
whoops - I lied - there are 3 parameters to bas$edit:

destination_string_descriptor - string descriptor by reference
source_string_descriptor - string descriptor by reference
edit_mask - word by value

So only the destination descriptor needs to be dynamic
if it has a different length than the source. Of course,
the same string descriptor can be used for both source
and destination.

Here's an example of how a call might look from C):

BAS$EDIT (&dststr, &srcstr, 16 + 32 + 4)

All of this stuff *used* to be documented back in VMS version
3 in the (as I recall) "language support routines" RTL book.
I regret the day just this past year when mine hit the dumpster.

fwiw

David J. Dachtera

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to
norm lastovica wrote:
>
> whoops - I lied - there are 3 parameters to bas$edit:
>
> destination_string_descriptor - string descriptor by reference
> source_string_descriptor - string descriptor by reference
> edit_mask - word by value
>
> So only the destination descriptor needs to be dynamic
> if it has a different length than the source. Of course,
> the same string descriptor can be used for both source
> and destination.

I never had a problem using a MAPped string as the target of EDIT$().



> Here's an example of how a call might look from C):
>
> BAS$EDIT (&dststr, &srcstr, 16 + 32 + 4)

In DIBOL I think it would have looked like this:

longword_vbl = BAS$EDIT( dest_str, src_str, word_mask )



> All of this stuff *used* to be documented back in VMS version
> 3 in the (as I recall) "language support routines" RTL book.
> I regret the day just this past year when mine hit the dumpster.

*SIGH* Hindsight *IS* *ALWAYS* 20/20, no?

JF Mezei

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to
The C run time library is designed to handle null terminated strings. So,
while you can technically call "strstr" from COBOL, you'd have a find time
building null terminated strings to pass to the routine.

What sort of string paradigm does the basic language use natively ? Isn't it a
counted string (first byte determines length of string) ? If so, wouldn't that
make using the basic RTL from COBOL rather difficult ?

The VMS RTL is based almost exclusively on desrcriptors which Cobol is capable
of supplying. So I woudl think that using the VMS STR$ routines would provide
the easiest and most trouble free interface. For one thing, you wouldn't have
to worry about having to link your cobol program with the basic RTL, since the
STR$ routines are available by default, right ?

Randy Park

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to

JF Mezei <jfmezei...@videotron.ca> wrote in message
news:3A0DBFC2...@videotron.ca...

DEC BASIC, VAX BASIC, BASIC-PLUS-2 all use string descriptors.
The first two use the standard VMS descriptor, while BP2
uses a simpler version.

The BASIC EDIT$(,) function works fine with both dynamic
strings and fixed strings.

While the BASIC RTL routine is callable from COBOL, I would
recommend using the STR$ RTL routine if there is one that
is suitable.

David J. Dachtera

unread,
Nov 11, 2000, 3:00:00 AM11/11/00
to
JF Mezei wrote:
>
> The C run time library is designed to handle null terminated strings. So,
> while you can technically call "strstr" from COBOL, you'd have a find time
> building null terminated strings to pass to the routine.
>
> What sort of string paradigm does the basic language use natively ?

On VMS, it uses standard VMS constructs, unlike the C-library.

> Isn't it a
> counted string (first byte determines length of string) ?

It's a DEC 3GL. therefore, it uses string descriptors fully compliant
with VMS calling standards.

> If so, wouldn't that
> make using the basic RTL from COBOL rather difficult ?

See the above.



> The VMS RTL is based almost exclusively on desrcriptors which Cobol is capable
> of supplying. So I woudl think that using the VMS STR$ routines would provide
> the easiest and most trouble free interface. For one thing, you wouldn't have
> to worry about having to link your cobol program with the basic RTL, since the
> STR$ routines are available by default, right ?

True. However, if you look at Norm's list of available operations for he
EDIT$() function, you'll find some that have no STR$xxx() equivalent.

BAS$EDIT() or DBASIC$EDIT() should fully usable in any VMS 3GL using the
VMS calling standards. The BASIC RTL function which supports FORMAT$()
would be especially useful in most non-BASIC 3GLs on VMS, but may be
difficult to use in those languages which have limited support for
dynamic strings and dynamic string descriptors.

Bart Z. Lederman

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to

Path: dec.DISABLE-JUNK-EMAIL.com!lederman
Newsgroups: comp.os.vms
From: lede...@star.enet.dec.DISABLE-JUNK-EMAIL.com (Bart Z. Lederman)
Distribution: world
X-Newsreader: mxrn 6.18-32
References: <1137A4A23A51D311B2D6...@seantexch.unitedad.com> <3A0CBBF7...@earthlink.net>
Reply-To: lede...@eisner.decus.DISABLE-JUNK-EMAIL.org
Organization: Personal Opinions Only
Subject: Re: COBOL F$EDIT

Path: dec.DISABLE-JUNK-EMAIL.com!lederman
Newsgroups: comp.os.vms
From: lede...@star.enet.dec.DISABLE-JUNK-EMAIL.com (Bart Z. Lederman)
Distribution: world
X-Newsreader: mxrn 6.18-32
References: <1137A4A23A51D311B2D6...@seantexch.unitedad.com> <3A0CBBF7...@earthlink.net>
Reply-To: lede...@eisner.decus.DISABLE-JUNK-EMAIL.org
Organization: Personal Opinions Only
Subject: Re: COBOL F$EDIT

In article <3A0CBBF7...@earthlink.net>, "David J. Dachtera" <djesys...@earthlink.net> writes:
>
>Terry Marosites wrote:
>>
>> Hi all,
>>
>> I want to an f$edit from COBOL if I call lib$do_command I don't come back

>I have memories from long ago of being able to call the BAS$EDIT


>function from BASIC run-time library from a non-BASIC 3GL. Perhaps
>someone else will chime in with the specifics. I think I read it here
>first a while back.

It is possible to call BAS$EDIT from any VMS language. Some years
ago I wrote a routine to allow it to be called from Datatrieve.

I am appending the original article here. It shows how to
call the routine from C and Datatrieve. Hopefully this will
be enough for someone to call it from COBOL (or someone else
can show how to do it).

Note that I wrote this years ago, long before I started
working for Compaq. It is totally unofficial, and internal
RTL routines that aren't documenented in one of the manuals
are not officially supported. However, it is unlikely that
this RTL routine would change, because it would require
changing a lot of other software.

===========================


A Multi-Purpose String Editing Function
(Similar to DCL's F$EDIT)
which can be Added to 3GLs
or DATATRIEVE.

Bart Z. Lederman
[former employer's name removed]


I have often wanted to process a line of text in a program or
DATATRIEVE procedure. In DCL, there is a useful lexical function
F$EDIT which can convert a string to upper case, remove trailing
blanks, convert multiple blank spaces and tabs to a single blank
space, and other functions: and it can do all of those functions
simultaneously. It was frustrating that there wasn't an equivalent
LIB$ or STR$ function.

Since I don't normally use VAX BASIC, it was only by accident (while
looking through someone else's program) that I discovered that such
a function is provided in VAX BASIC. What is even better is that it
is in the BASIC Run-Time Library BASRTL.EXE, which is supplied with
the VAX/VMS operating system. This means that everyone has it: you
don't have to buy VAX BASIC to use the function.

Since I don't use VAX BASIC, I wanted to make the function available
in VAX C. The following file which I call BAS$EDIT.H provides the
necessary definitions.


#ifndef __BAS$EDIT_LOADED
#define __BAS$EDIT_LOADED 1
#endif

/*
Define a prototype and values for the VAX/BASIC EDIT$ function.

The EDIT$ function performs one or more string editing functions,
depending on the value of its integer argument.

Example (in BASIC)

New_string$ = EDIT$(Old_string$, 48%)

Example (in C)

(void) BAS$EDIT (&New_String, &Old_String, Edit-Exp);

New_String and Old_String are string descriptors passed by address
(reference).

Edit-Exp is an integer value specifying one or more edit actions
from the set listed below, which can be ANDed together.

There does not appear to be a return status to check.

All of the definitions here are my own and NOT Digital's.

Bart Z. Lederman 15-Jun-1992
*/

void BAS$EDIT ();

/* Values Effect */

#define BAS$M_NOPARITY 1 /* Trim parity bits */
#define BAS$M_COLLAPSE 2 /* Discard all spaces and tabs */
#define BAS$M_DISFORM 4 /* Discard characters: CR, LF, FF, ESC, */
/* RUBOUT, and NULL */
#define BAS$M_DISLEAD 8 /* Discard leading spaces and tabs */
#define BAS$M_COMPRESS 16 /* Reduce spaces and tabs to one space */
#define BAS$M_UPCASE 32 /* Convert lowercase to uppercase */
#define BAS$M_BRACKET 64 /* Convert [ to ( and ] to ) */
#define BAS$M_DISTRAIL 128 /* Discard trailing spaces and tabs */
#define BAS$M_KEEPQUOTE 256 /* Do not alter characters inside */
/* quotes */

Any or all of the qualifiers can be "ORed" together.

To demonstrate what this function can do, I wrote the following
simple demonstration program.


#module TEST_EDIT "V1.03"

/*
This is a very simple program to demonstrate calling BAS$EDIT from a
C language program.

B. Z. Lederman
*/

#include DESCRIP

#include "BAS$EDIT.H" /* use local definitions */

/*
In the original, the word "it" starts with an eight-bit character
(an "i" with two dots over it) and there are embedded tabs.
*/

$DESCRIPTOR (instr, "This string has stuff ïn it");

/* ^ space and tab here */

struct dsc$descriptor_s outstr = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0};

unsigned long int status;

test_edit ()
MAIN_PROGRAM
{
status = LIB$PUT_OUTPUT (&instr);

BAS$EDIT (&outstr, &instr, (BAS$M_COMPRESS | BAS$M_UPCASE) );

status = LIB$PUT_OUTPUT (&outstr);
/*
Watch what happens to the eight bit character when parity is
stripped off.
*/
BAS$EDIT (&outstr, &instr, (BAS$M_COLLAPSE | BAS$M_NOPARITY) );

status = LIB$PUT_OUTPUT (&outstr);

exit (status);
}


When you run this program, you should see this:


This string has stuff ïn it
THIS STRING HAS STUFF ÏN IT
Thisstringhasstuffonit


I also wrote the following program which runs through all of the
possible permutations of editing functions.


#module TEST_BAS_EDIT "V2.00"

/*
This is a very simple program to demonstrate calling BAS$EDIT from a
C language program.

B. Z. Lederman
*/

#include DESCRIP

#include "BAS$EDIT.H" /* use local definitions */

$DESCRIPTOR (instr, " This string [has]
stuff ïn it ");

/* There is an embedded Line-Feed here ^ */

struct dsc$descriptor_s outstr = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0};

unsigned long int status;

test_bas_edit ()
MAIN_PROGRAM
{
int i;

status = LIB$PUT_OUTPUT (&instr);

for (i = 0; i < 512; i++)
{
BAS$EDIT (&outstr, &instr, i);
printf ("%d\n", i);
status = LIB$PUT_OUTPUT (&outstr);
};

exit (status);
}


All this is very well and good for 3GL programmers, but what about
DATATRIEVE? Anyone who has seen my articles in the past knows that
it's very easy to add RTL functions to DATATRIEVE. I added the
following to my DTRFNDnnn.MAR file:


; FN$BAS_EDIT - process a character string with BAS$EDIT
; B. Z. Lederman
; output is a one character string
; input is an unsigned byte ASCII code
;
.LINK "SYS$SHARE:BASRTL.EXE"/SHAREABLE

$DTR$FUN_DEF FN$BAS_EDIT, BAS$EDIT, 3
$DTR$FUN_NOOPTIMIZE
$DTR$FUN_HEADER HDR = <"Edited">
$DTR$FUN_EDIT_STRING ^\T(80)\
$DTR$FUN_OUT_ARG TYPE = FUN$K_STATUS
$DTR$FUN_IN_ARG TYPE = FUN$K_TEXT, OUT_PUT = TRUE, ALL_LEN = 255
$DTR$FUN_IN_ARG TYPE = FUN$K_DESC, DTYPE = DSC$K_DTYPE_T, ORDER = 1, ALL_LEN = 255
$DTR$FUN_IN_ARG TYPE = FUN$K_VALUE, DTYPE = DSC$K_DTYPE_L, ORDER = 2
$DTR$FUN_END_DEF


To use this you have to do what BASIC programmers do, and put in the
numeric value of the editing function. This is because you can't add
new keywords to DATATRIEVE to give symbolic values for the editing
functions. You can, however, DECLARE a local variable and give it the
value of the editing function you want.

An example of how this function works is:


PROCEDURE TEST_BAS_EDIT
!
DECLARE EDIT_VALUE USAGE LONG.
!
EDIT_VALUE = 0
!
! embedded Line Feed V V eight-bit character
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 0) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 1) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 2) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 4) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 8) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 16) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 32) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 64) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 128) | "<"
PRINT FN$BAS_EDIT (" This string [has]
stuff ïn it ", 256) | "<"
!
PRINT SKIP
!
WHILE EDIT_VALUE LE 512 BEGIN
PRINT EDIT_VALUE, SPACE 1,
FN$BAS_EDIT (" This string [has]
stuff ïn it ", EDIT_VALUE) | "<"
EDIT_VALUE = EDIT_VALUE + 1
END
!
END_PROCEDURE


Part of what this looks like when you run it follows (I'm not going
to print all 512 possible variations here):


:test_bas_edit
This string [has]
stuff ïn <
This string [has]
stuff on <
Thisstring[has]
stuffïnit<
This string [has] stuff ïn i<
This string [has]
stuff ïn i<
This string [has]
stuff ïn i<
THIS STRING [HAS]
STUFF ÏN <
This string (has)
stuff ïn <
This string [has]
stuff ïn <
This string [has]
stuff ïn <

EDIT
VALUE

0 This string [has]
stuff ïn <
1 This string [has]
stuff on <
2 Thisstring[has]
stuffïnit<
3 Thisstring[has]
stuffonit<
4 This string [has] stuff ïn i<
5 This string [has] stuff on i<
6 Thisstring[has]stuffïnit<
7 Thisstring[has]stuffonit<


and so on.

I belive this function will be most useful in two areas. The first
is when data is read in from a text or "free-format" file and has to
be processed to be stored into a domain. The other is when the user
is prompted for input: the function can be used to "normalize" input
(uniform case, no extra spaces or tabs, etc.) to make it easier to
look for words or commands within the input string.

--
B. Z. Lederman Personal Opinions Only

Posting to a News group does NOT give anyone permission
to send me advertising by E-mail or put me on a mailing
list of any kind.

Please remove the "DISABLE-JUNK-EMAIL" if you have a
legitimate reason to E-mail a response to this post.


Terry Marosites

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to
Thanks all ,

The purpose of my endeavor to use f$edit from Cobol was to do a trim and
compress. With the help of John Nogueira and Hein Vandenheuvel
I was able to get just what I needed using the DBASIC$EDIT. I noticed that
there are no DBASIC$ or bas$ in the help under RTL. Is there a list of all
the run times routines in help other than the RTL section.

Thanks Again
Terry

0 new messages