----------------------------------------- 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: - The new JFT needs memory, that means that you have to decrease the size if the current programs Heap! - Ab extended JFT will not be passed to a Childprogram with SHELL/ EXECUTE! The 15 Files Border still exists for the Childprogram. 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 --- CrossPoint v3.11 R * Origin: PBSOUND, PBFILES (27MB), PBFAQ, PBRULES, PBHIVGA at: 2:2410/330.1) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: EBC00009 Date: 07/01/97 From: THOMAS GOHEL Time: 12:00am \/To: ALLE (Read 1 times) Subj: FAQ: PowerBASIC 09/16 (Assembler Part 1)00:00:0007/01/97 ================================================ 5. Hints in connection with the InLine-Assembler ================================================ Shortindex: 5.1. Principles of the function of the InLine-Assembler 5.2. Assembler Syntax Error 5.3. Faulty passing of Variables in the InLine-Assembler 5.4. Problems with LDS/LES 5.5. Crash after calling own INT-Functions 5.6. Fixup Overflow 5.7. Dividing Variables from WORD to BYTE 5.8. Dividing Variables from DWORD to WORD 5.9. Access to Arrays / Structures with the InLine-Assembler 5.10. Parameter return with the InLine-Assembler 5.11. Parameter return in Interrupt-Procedures 5.12. Creating 32bit-Pointers 5.13. Converting from REG to InLine-ASM 5.14. Converting from A86 to InLine-ASM The tips shown here are not a tutorial in InLine-Assembler, but may help solve many beginner mistakes. A more detailes description of the interactions will not be written here, if it does not belong to the problem itself. 5.1. Principles of the function of the InLine-Assembler ------------------------------------------------------- The PowerBASIC InLine-Assembler contains the functions of the Intel 8086 CPU. This means that you may have to adapt the InLine-Assembler- Code of other High-Language-Compilers or true Assembler-Code to the PowerBASIC InLine-Assembler, because they quite often contain 80286 commands. Usually the following commands have to be converted: Source - > PowerBASIC shr ax, 2 ! shr ax, 1 ! shr ax, 1 or like this: ----------------------------------------------------------- shl ax, 3 ! push cx ! mov cl, 3 ! shl ax, cl ! pop cx ----------------------------------------------------------- pusha ! push ax ! push bx and so on until all registers are saved ----------------------------------------------------------- popa analog, only restore registers 5.2. Assembler Syntax Error --------------------------- When we forget the 'true' Syntax Errors, which usually occurs when you are not quite used to Assemblercommands, there still is an 'obvious' Syntax Error which can be marked by the InLine-Assembler of PowerBASIC. This is the case when the Compiler can't use a Variable in the InLine-Assembler because it isn't defined in any way. PowerBASIC usually creates used Variables within true BASIC-Source by itself and allocates memory for it. You have to do that yourself within the InLine-Assembler. Example: ! mov ax, Demo% This causes a Syntax Error because the Compiler can't do anything with the Variable 'Demo%'. You should first set the Variable to a value: Demo% = 1 ! mov ax, Demo% Now the Compiler accepts the Assemblerline. You don't have to assign a value to a Variable every time, a simple DIM or SHARED, PUBLIC, LOCAL etc. is enough and initialises 'Demo%'. 5.3. Faulty passing of Variables in the InLine-Assembler