Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!hplabs!hpfcdc!hpfclp!fritz From: fritz@hpfclp.SDE.HP.COM (Gary Fritz) Newsgroups: comp.sys.hp Subject: Re: HP9836 BASIC -- HELP !! Message-ID: <7540017@hpfclp.SDE.HP.COM> Date: 4 Jan 89 02:05:10 GMT References: <281@vmsa.technion.ac.il> Organization: HP SESD, Fort Collins, CO Lines: 41 I would guess that the @Gpib device is assigned to be format-ON, though (if I remember correctly, and if @Gpib points to a device and not a file) it won't make any difference in this case. The end result of the code is that it outputs the 16-bit data in the array with the top and bottom bytes of each integer swapped. (Rotating a 16-bit integer by 8 bits swaps the bytes.) The output is unformatted, since the "W" specifier in OUTPUT USING says to output a 16-bit Word without formatting. It would be roughly equivalent to: (void) Out_word(Gpib_fd, Xbuf, N) int Gpib_fd; /* File Descriptor of GPID device */ short Xbuf[]; /* Assumes 16-bit short */ int N; { int i, ret; short Odata; for (i=0; i> 8 & 0xff) | (Xbuf[i] << 8 & 0xff00); /* swap bytes */ ret = write(Gpib_fd, &Odata, 2); if (ret < 2) { /* handle error */ } } } The 9836 (and standalone BASIC on all Series 200 & 300 computers) would actually output the bytes 2 at a time like this. It's a single-tasking system tuned for I/O performance, and can spit out bytes faster than it could if it had to worry about buffering. Presumably this won't make any difference to your application, unless your GPIO device depends on getting its data in small, evenly-spaced chunks. (If you wanted a more exact duplication of the BASIC code you gave, you would replace the "write" above with a "printf" [== OUTPUT USING] that printed only an unformatted 16-bit quantity, and immediately flushed its buffers. I never claimed your BASIC code was efficient. :-) Standard disclaimer: I haven't written any BASIC for about 6 years, and make no guarantees. This is not an official statement of HP, etc. etc. Gary Fritz