Re: far string access

 BBS: Inland Empire Archive
Date: 12-12-92 (12:12)             Number: 340
From: DIK COATES                   Refer#: NONE
  To: HUGH MARTIN                   Recvd: NO  
Subj: Re: far string access          Conf: (2) Quik_Bas
>>>> QUOTING Hugh Martin to Dik Coates <<<<

Thanks for posting... I've included final(?) edition... for
this function...  Had a 'bum steer' on the descriptor being
a DWORD and not WORD... That's what allowed the function to
work when compiled to EXE and not within environment...
Putting together finishing touches on library, and will post
when completed...



; BASIC FILE FUNCTION to Create a FILE using FAR STRING filename.
; returns File Handle if successful, and DOS Critical Error if fails.
; Declare as follows:
;
; DECLARE FUNCTION CREATEFF% (filename$, BYVAL attribute%)
;
; ARGS: filename$ - name of file to create
;       attribute%- attribute of file as follows:
;                       0 - normal
;                       1 - read only
;                       2 - hidden
;                       4 - system
; LIB:  BAFILF.LIB
;
; REV:  92-12-04
;       92-12-07  StringLength:Proc removed
;       92-12-11  BUG fix
;
CREATEFF    proc  Uses bx cx dx ds es ss si di, desrptr:word, attrib:word
            pushf               ;save flags
            mov   ax, desrptr
            push  ax
            call  StringAddress

;this has now been revised
            push  ax             ;save offset
            push  dx             ;save segment
            pop   ds             ;retrieve segment in ds
            pop   dx             ;retrieve offset in dx

            mov   cx, attrib     ;attribute in cx
            mov   ah, 3ch        ;DOS create file
            int   21h
            jnc   @f             ;carry flag clear, ret handle in ax
            neg   ax             ;carry flag not clear, ret -ve crit err in ax
@@:         popf                ;restore flags
            ret
CREATEFF    Endp



Have renamed it to CREATEFF for create far file... library already has
CREATEFN for near files... Thanks for help and effort...  Caught the
original mov and pushing address.  No point in loading address of
something that was passed as an address.  Missed the push and pop...
it was a carry over from when string length was required.

You mention that you do the ASCIZ thing in the function... I had
originally written the function by creating a temporary buffer
of 0's (automatically Nul terminated) and needed the string length.
It was kind of clunky... Is there an easier way of doing this than
creating the buffer and writing to it?

Also, is there a way to handle near and far strings from the same
function?  Will check to see if StringAddress hangs the machine from
near string... if not, maybe by checking lengths...

Will be in touch in the New Year to pick up a copy of your library.

Regards Dik, Oshawa, Canada

... Dik, remember last week in the Austin Mini?  See a doctor! - Heather
___ Blue Wave/QWK v2.10

--- Maximus 2.00
 * Origin: Durham Systems (ONLINE!) (1:229/110)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET