[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

187.0. "QUADWORDS in Basic ?" by FAITH::FALEK () Thu Jan 02 1986 23:37

Is there a neat way to use system timer and time conversion services
(like $BINTIM, $GETTIM, and $SETIMR) which deal with time in quadword
format entirely from within BASIC??  (yes, I know it is easy to write
callable MACRO routines to perform these functions -  but that's not
the question).

Is it possible to fake things by passing an array of longwords or some
such? I wasn't able to get that to work.

Another quadword question:
I'd like to use a quadword time as a key in an ISAM file. My impression
is that RMS supports this, but that BASIC doesn't. Is that correct? 

please, no comments like  "use a real language, etc." :)
T.RTitleUserPersonal
Name
DateLines
187.1MAASSG::RMURPHYFri Jan 03 1986 00:4410
You can do some of this by declaring the quadword time to be an 8-byte
STRING variable. Then, you can use $BINTIM, etc with it by passing it
as ...,FOO BY REFERENCE,...
Note that the string must be static for this to work - putting it in a MAP
is a simple way to do it.

This hack should also allow you to use the time values as a key in the file;
not sure about that, tho - basic may be smarter than I think, but I'm pretty
sure it only checks for key sizes, not type.
	-Rick
187.2SPRITE::MCVAYFri Jan 03 1986 12:1028
 You can fake BASIC into supporting quadwords by defining a two-word array
and then redefining it, such as

 MAP (TEMP) STRING QUAD=4%   ! Define four-word (quadword) placeholder
 MAP (TEMP) LONG TIME(2%)    ! Redefine the quadword as an array

 You can then dump the time result in the array by pointing to it by
descriptor.  The calling routine doesn't care what the value is, as long
as it has an address of its location.  (I haven't used the time system
services for quite a while, so the following may not be quite correct):

 CALL SYS$GETTIM(QUAD)

 The TIME(1%) buffer then holds the starting address of the time call.  The
service calls also ignore boundaries (that is they treat the two-part array
as a quadword), so other calls that require a quadword can use just the
starting address as the argument.  For example. to convert the above value
to an ASCII string and print it, the call is:

 CALL SYS$ASCTIM &
	(,		! Length of returned time string (not needed) &
	ASCII_Time$,	! Result of call (ASCII-time)		      &
	TIME(1%),	! Address of time value to convert	      &
	0)		! Conversion flag (0=return full date and time)
 PRINT ASCII_Time$

 This is dredging up some pretty cobwebby stuff: if anyone has had more recent
experience, please correct the code.
187.3SPRITE::MCVAYFri Jan 03 1986 12:122
 I should have read the replies first!  My answer is the same as .1, just
expanded a little.
187.4RICARD::HEINFri Jan 03 1986 15:0128
Re .2

	Hmmm...	I do not like doing this but this is the hackers file
	and maybe that means you are allowed to hack other replies...

> MAP (TEMP) STRING QUAD=4%   ! Define four-word (quadword) placeholder

 	This would result in a 4 (four) BYTE, not word placeholder

> MAP (TEMP) LONG TIME(2%)    ! Redefine the quadword as an array
 
	This would result in a 3 (three) longword array (time(0..2)) and
	more then likely a reserved word violation.

> CALL SYS$GETTIM(QUAD)
 
	This would generatea call by descriptor by default --> ACCVIO

>	TIME(1%),	! Address of time value to convert	      &

	[on weak grounds now... this would most likely, not very sure
	result in the address of a COPY of the contents of time(1) to
	be pushed on the stack and time(1) would never receive the result,
	but then again, that might only be true in basic-plus-2 on the 11s.

Other then that your right :-)

	Hein.
187.5MANANA::MEAGHERFri Jan 03 1986 16:318
You do not have to use static strings, as long as you pre-allocate the space.
For example:

	QUAD$ = STRING$(8,0)
	STS = SYS$BINTIM( INPUT_STRING$, QUAD$ BY REF )
	etc.

bob
187.6FAITH::FALEKSat Jan 04 1986 00:5324
I tried the method in .1, and it works very nicely !

The product of my labors will be made available in the toolshed
if it comes out well enough. I'm building an 'event scheduler'.
This is a little BASIC program that runs as a detached process.
It owns a multi-keyed ISAM database which stores VMS commands which
are executed according to some kind of schedule. The database
stores the last start time, completion time, completion status,
schedule interval, log file spec, user's UIC, success and failure
counters, next absolute time scheduled, type code (so you can list
the status of all "BACKUP" operations, for example,   PID of the
process executing the command (if currently running), and so on.
A library of subroutines with names like "INSERT_EVENT", "MODIFY_EVENT",
and SHOW_EVENT provides access to the data base from user programs.

The event scheduler reads through its database looking for work to do
and when it finds a command that is runnable, it does a create_process
and starts it running under the requestor's UIC. When there are no more
items to process immediately, it sets its alarm clock for when the next
thing will be runnable and goes into common event flag wait. The
routines which write the database also set that flag, and so the scheduler
wakes up and processes things if the database is changed.
When processes that got created by the scheduler complete, they write
their own status back to the database and wake it up.