4. Standardproblems (Part 2)

Deutsch


Standardproblems (Part 1)

4.7. Error 502/514 when using C-OBJ-Files

When using C-OBJ-Files you should take care that there not multiple Statements for the Datasegment in it, because PowerBASIC only supports one Datasegment per OBJ-File.
Since there is no solution known to me and there seems to be none from PowerBASIC, it seems that it is your only choice to adapt your C- Source.

4.8. Preventing a Warmboot with CTRL-ALT-DEL

The following Source prevents a possible Warmboot:
    Example:
            KEY 15, CHR$(&h0C, &h53, &h73)
            ON KEY(15) GOSUB NoBoot
            KEY(15) ON

            DO
               IF INKEY$ <> "" THEN EXIT LOOP
            LOOP
            PRINT "Done!"
            END
            NoBoot:
            PRINT "Warmboot not wanted!!"
            RETURN

4.9. Opening more than 15 Files with PowerBASIC and/or DOS

You often seem to come to the limits of PowerBASIC when you want to open more than 15 Files. But this is not a problem of the Compiler, but a genetic birth error of MS-DOS.
I'll have to bring up some of the dark sides of DOS in order to describe this effect, baecause this is where we find the answer. Many of you know that when a file is opened, a handle is returned from DOS. Now where does DOS save this handle an the information belonging to that handle?

To many of you PSP (Program Segment Prefix) is a well known statement (already described shortly in the finding of the filename). If not, you shoud better not read the following explanations and just test the source.
This PSP also contains a table, which was declared reserved by Microsoft, but its use is widely known. This table is called 'Job File Table' (short JFT) and is located at Offset 18Hex from DOS 2.0 on and is a 20 fields long BYTE-Array. When you now subtract the used handles for: NUL, $CLOCK, CON, AUX and PRN, what is left over are the magic 15 usable handles.
But it is only job of the JFT to manage a pointer to the 'System File Table', short SFT.
The SFT on the other hand is a structure similar to a MCB (Memory Control Block), which manages important data like Startclusters and Sharingattributes. A SFT of this kind can only hold a limited amount of handles, to raise this you have to include a higher amount with FILES in your CONFIG.SYS. After a restart of the system MS-DOS reserves more MCBs marked as SFT. Now you can theoretically open more than 20 Files, because the default numbe of FILES is '8'. Unluckily we come to another limited number of entries in the JFT within the PSP. There is a solution from MS-DOS 3.3 on, because the Interrupt &h21, function &h67 enables you to raise the amount of usable handles. But how is this done when the space in the PSP is limited??
Therefore we remember some of the undocumented fields within the PSP. Offset &h32 has become interresting, because this holds the new size of the JFT in WORD. After that there is the new pointer to the Extended JFT. Interrestinf is, that the new array is an array of WORD. Theoretically 65535 handles can be managed like that, but that is hypothetically, because the SFT can only handle 255 entries.
Actually there are two important things when creating a new JFT:

Ok, but now here is the Source:
    '***********************************************************************     '
    '  Set the Amount of uasable Handles in PowerBASIC 3.2
    '
    '    developed by Th.Gohel  Fido:      2:2410/301.12
    '                           InterNet:  support@pbsound.snafu.de
    '                           Homepage:  http://www.snafu.de/~pbsound/
    '
    '***********************************************************************

    MaxFiles% = 30                       ' Same as FILES = 30
    PBFiles MaxFiles%                    ' Set the amount of usable Files

    FOR i% = 1 TO MaxFiles%              ' Test all usable Files
        PRINT "Opening File:  PBFILES." + STR$(i%)
        OPEN "PBFILES." + STR$(i%) FOR BINARY AS i%
        PUT$ i%, "Testfile" + STR$(i%) + " for PBFILES, please delete!"
    NEXT i%
    FOR i% = 1 TO MaxFiles%              ' and close again
        CLOSE i%
    NEXT i%

    SUB PBFiles(BYVAL MoreFiles%)
        x& = SETMEM(-255)                ' Should be enough for all cases
        ! mov ah, &h67                   ; Set amount of usable Handles
        ! mov bx, MoreFiles%             ;
        ! add bx, 6                      ; The Standard-Handles for PB
        ! int &h21
        ! jnc PBFiles_Ok
        PRINT "Error while creating the usable Handles!!"
        PBFiles_Ok:
    END SUB

4.10. HEX$-DWORD Routine for PowerBASIC 3.1/3.2

The following routine should make HEX$-Support possible for variables of type DWORD, which is missing for some reason.
    Example:
            d??? = &h1234ABCD

            PRINT DHex$(d???)

            FUNCTION DHex(HexDWord???) AS STRING
                    DIM Lo AS WORD
                    DIM Hi AS WORD
                    ! les  bx, [bp+6]
                    ! mov  ax, es:[bx+0]
                    ! mov  Lo??, ax
                    ! mov  ax, es:[bx+2]
                    ! mov  Hi??, ax
                    DHex = RIGHT$("000" + HEX$(Hi??), 4) + RIGHT$("000" + _
                    HEX$(Lo??), 4)
            END FUNCTION


Standardproblems (Part 1)


(c) 1996/2007 by Thomas Gohel, All rights and bugs reserved
(c) 1996/1997 by Thomas Geiger, english version