Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Kiss your keyboard goodbye!


computers / comp.os.vms / Re: Redimensioning formal parameter arrays in OpenVMS BASIC

SubjectAuthor
o Re: Redimensioning formal parameter arrays in OpenVMS BASICT. Kurt Bond

1
Re: Redimensioning formal parameter arrays in OpenVMS BASIC

<127a497c-c705-401b-b807-e733cf882dd6n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=20684&group=comp.os.vms#20684

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:a05:622a:4cb:: with SMTP id q11mr3489224qtx.597.1644094585835;
Sat, 05 Feb 2022 12:56:25 -0800 (PST)
X-Received: by 2002:ac8:4e89:: with SMTP id 9mr3673975qtp.484.1644094585648;
Sat, 05 Feb 2022 12:56:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.vms
Date: Sat, 5 Feb 2022 12:56:25 -0800 (PST)
In-Reply-To: <a3db6b24.0305081211.6f867ad0@posting.google.com>
Injection-Info: google-groups.googlegroups.com; posting-host=184.13.240.130; posting-account=VfaA3goAAACAzsQ2BCBCq7hV84VieZFr
NNTP-Posting-Host: 184.13.240.130
References: <a3db6b24.0305081211.6f867ad0@posting.google.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <127a497c-c705-401b-b807-e733cf882dd6n@googlegroups.com>
Subject: Re: Redimensioning formal parameter arrays in OpenVMS BASIC
From: tkurtb...@gmail.com (T. Kurt Bond)
Injection-Date: Sat, 05 Feb 2022 20:56:25 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 80
 by: T. Kurt Bond - Sat, 5 Feb 2022 20:56 UTC

On Thursday, May 8, 2003 at 4:11:28 PM UTC-4, T. Kurt Bond wrote:
> The BASIC for OpenVMS Reference Manual says, in the fifth item of the
> Remarks section:
> The executable DIM statement cannot be used to dimension virtual arrays,
> arrays received as formal parameters, or arrays declared in COMMON, MAP,
> or nonexecutable DIM statements.
> http://h71000.www7.hp.com/doc/73final/cobol/bas_ref_013.htm#noisn
> The "no formal parameters" rule is inconvienent. It means that you
> can't pass an array to a function, redimension it, fill it with values,
> and then use LBOUND and UBOUND in the caller to find out its new size.
> Presumably it is illegal because there is no way at compile time to
> know if the function will be called with a dynamic array created with
> the executable DIM statement or a static array created with a
> non-executable DIM statement.
> However, the programmer *can* know, so it ought to be safe to
> redimension the array directly when the programmer knows it was
> created by an executable DIM statement.
> Using Alpha BASIC V1.4-000 under OpenVMS V7.2 and looking at the
> listing of some code with some executable dimension statements
> compiled with /LIST/MACHINE revealed the existance of DBASIC$RT_DIM
> and after a little experimentation lead to a program that used
> DBASIC$RT_DIM directly to redimension dynamically dimensioned arrays
> in functions[.]

> (Interestingly, a slightly different approach was necessary using VAX
> BASIC V3.5 under VMS V5.5-2: using BY VALUE in function
> definition statements is not allowed by this version of VAX BASIC,
> and BAS$RT_DIM had to be used instead of DBASIC$RT_DIM, of course.)
> --
> T. Kurt Bond, t...@tkb.mpl.com

I needed this again for a program I was writing on a VAX. (The VAX is running VMS V5.5-2; It's like I am in 1992 all over again!)

Anyway, I ended up figuring out how to pass the lower bound (call BAS$RT_DIM_BOUNDS instead) and how to use the same redim procedure with different types, plus simplified things a little. Here's my new version:

program vax_redim_best
option type = explicit, constant type = integer, &
size = integer long, size = real double
record rec
string s = 13
long i
end record rec

! Don't declare the parameters, and everything works, even passing
! different types.
external sub redim

declare long stat, i
i = 1
dim rec rec(1 to i)
print "lbound (rec) at start: "; lbound (rec)
print "ubound (rec) at start: "; ubound (rec)
call redim (rec(), 3, 10)
print "lbound (rec) after redim: "; lbound (rec)
print "ubound (rec) after redim: "; ubound (rec)

dim string s(1 to i)
print "lbound (s) at start: "; lbound (s)
print "ubound (s) at start: "; ubound (s)
call redim (s(), 3, 10)
print "lbound (s) after redim: "; lbound (s)
print "ubound (s) after redim: "; ubound (s)

dim long l(1 to i)
print "lbound (l) at start: "; lbound (l)
print "ubound (l) at start: "; ubound (l)
call redim (l(), 3, 10)
print "lbound (l) after redim: "; lbound (l)
print "ubound (l) after redim: "; ubound (l)

end program ! vax_redim_best

function long redim (long s, long low, long high)
option type = explicit, constant type = integer, &
size = integer long, size = real double
external long function bas$rt_dim_bounds (long by value, long by value, long by value)
declare long r
r = bas$rt_dim_bounds (loc (s), low, high)
end function r ! redim

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor