Using QB4.5 Quick Libraries

General FreeBASIC programming questions.
DonW
Posts: 40
Joined: Feb 16, 2013 0:56
Location: Longview, WA

Re: Using QB4.5 Quick Libraries

Postby DonW » Mar 02, 2013 0:02

I'm glad this discussion has morphed into addressing BLOAD techniques, which is a major stumbling block to converting my QB application to freeBASIC. My application makes extensive use of "screen" files (with .SCR extension) that I created using a development utility called "Softcode 4" from BottleWorks Development Corp (now a defunct company).

Softcode 4 allowed one to design application I/O screens in text format (80x25). Then Softcode 4 "BASVE'ed the designed screens with an .SCR extension and generated QB screen management code that could be plugged into one's application code. The application .SCR screen files are then BLOAD'ed individually at run time depending upon where they are needed in the application. Each .SCR file is a byte-by-byte capture of what was on the 80x25 screen when I saved it. I use QB's SCREEN 0 mode when they are loaded. I have 47 of these .SCR files that are used through out my application.

So far, the ongoing discussion regarding using BLOAD seems to be centered around loading BSAVE'ed "graphic" screens...for example, pixel-by-pixel captures. However, the freeBASIC documentation on BLOAD indicates that it supports loading
Old QB-like data files, saved with BSAVE from QB code, containing "raw" data preceded by a 7-byte header, beginning with &HFD, up to 64 KiB in size
I was hoping that this meant I could use FB's BLOAD to load my .SCR files. However, the three code examples in the documentation are for loading .BMP files, which I take to be "graphic" files, because they don't work with my .SCR files.

Regards, Don
RockTheSchock
Posts: 232
Joined: Mar 12, 2006 16:25

Re: Using QB4.5 Quick Libraries

Postby RockTheSchock » Mar 02, 2013 21:42

The BSAVE file format is described here in german:
http://www.freebasic-portal.de/befehlsr ... ad-59.html

An example with fb loading a bsave 'd file to memory and printing it to screen.

Code: Select all

Type CharType field = 1
   code As UByte
   col As UByte
End Type

Type Screen0_80x25
   char(1 To 2000) As CharType
   length As Integer
End Type

Sub BLoad80x25(filename As String, sdata As Screen0_80x25)
   Dim fhandle As Integer
   Dim signature As UByte
   Dim segment As Short
   Dim offset As Short
   Dim length As Short
   
   fhandle = FreeFile   
   Open filename For Binary As #fhandle
   Get #fhandle, , signature
   Get #fhandle, , segment
   Get #fhandle, , offset
   Get #fhandle, , length
   
   Get #fhandle, , sdata
   Close #fhandle
   
   Print "signature: 0x";Hex(signature),"segment: 0x";Hex(segment),"offset: 0x";Hex(offset)
   Print "Length(Bytes):";length
   
   sdata.length = length
End Sub

Sub Print80x25(sdata As Screen0_80x25)
Dim row As Integer
Dim col As Integer
Dim charnum As Integer

Dim fgcolor As Integer
Dim bgcolor As Integer


For row = 1 To 25
   For col = 1 To 80
      charnum = charnum+1
      Locate row,col
      bgcolor = sdata.char(charnum).col Shr 4
      fgcolor = (sdata.char(charnum).col Shl 4) Shr 4
      
      Color fgcolor,bgcolor
      Print Chr(sdata.char(charnum).code);
      If charnum= sdata.length Exit Sub
   Next
Next
   
End Sub


'--------------------------------------------------------
Dim screendata As Screen0_80x25
Screen 0
Width 80,25

BLoad80x25("1.BSV",screendata)
sleep
Print80x25(screendata)
Sleep



Here is a QB programm printing a testscreen and BSAVE it :

Code: Select all

CLS
SCREEN 0
WIDTH 80, 25
LOCATE 1, 1
FOR j% = 1 TO 25
   COLOR (j% - 1) MOD 16, (j% + 8) MOD 16
   LOCATE j%, 1
   FOR i% = 0 TO 77
      LOCATE j%, i% + 1
      PRINT CHR$((i% MOD 26) + 65);
   NEXT
   row$ = LTRIM$(STR$(j%))
   row$ = SPACE$(2 - LEN(row$)) + row$
   PRINT row$;
NEXT

DEF SEG = &HB800
BSAVE "1.BSV", 0, 4000
CLS

SLEEP 3
BLOAD "1.BSV"
SLEEP
Last edited by RockTheSchock on Mar 02, 2013 23:37, edited 2 times in total.
DonW
Posts: 40
Joined: Feb 16, 2013 0:56
Location: Longview, WA

Re: Using QB4.5 Quick Libraries

Postby DonW » Mar 02, 2013 22:39

Rock The Shock...

You da man! I tried your FB code with one of my BSAVE'ed .SCR files and it looks displays perfectly with one exception...the last row (line 25) starts with a bunch of random colored blocks (with various characters in them) up to half way across the row, and the last half of the row is black. With my QB code, the last row displays black all of the way across. Probably with a little tweaking of your code, the last row will display correctly.

I haven't yet figured out how to include screen print images from my PC in my posts, otherwise I could show you how the screen file displayed with your FB code versus how it displays in QB.

Thanks, Don
RockTheSchock
Posts: 232
Joined: Mar 12, 2006 16:25

Re: Using QB4.5 Quick Libraries

Postby RockTheSchock » Mar 02, 2013 23:36

I have changed the BLoad80x25 function, so prints now:

signature,segment,offset and length saved in the bsave'd file. please tell me theese values.

i have also tweaked the print function.

haven't yet figured out how to include screen print images

you can upload it there and than make here a link
http://www.file-upload.net/
DonW
Posts: 40
Joined: Feb 16, 2013 0:56
Location: Longview, WA

Re: Using QB4.5 Quick Libraries

Postby DonW » Mar 03, 2013 0:10

Rock the Shock...

I found that if I changed your code in the Print80x25 subroutine to "For row = 1 To 24", then the resulting screen is displayed in the console window with the 25th row all black (no weird stuff). I need to keep line 25 "clear" because on certain of my data entry screens, I use that line to display error messages. Again many thanks for your help!

Regards, Don
DonW
Posts: 40
Joined: Feb 16, 2013 0:56
Location: Longview, WA

Re: Using QB4.5 Quick Libraries

Postby DonW » Mar 03, 2013 0:12

Opps...I just submitted my last post before I saw your latest post. Thanks for the tip for uploading screen print files...I'll give that a try.

Don
DonW
Posts: 40
Joined: Feb 16, 2013 0:56
Location: Longview, WA

Re: Using QB4.5 Quick Libraries

Postby DonW » Mar 03, 2013 0:35

Rock The Shock,

I posted a screen print of my BLOAD'ed file after I changed the subroutine to "For 1 To 24" to the link that you provided. It in return gave me the following link for my file...http://en.file-upload.net/download-7278034/FBTestBLOAD.jpg.html.

However, when I went to that link, it took me a while to sort through all of the "download" buttons to find the one that would actually let you view my file. That site appears to want to snooker you into inadvertently downloading all sorts of software instead of the item you want to look at. I guess that you have to know what you're doing when you are on this site.

Don
DonW
Posts: 40
Joined: Feb 16, 2013 0:56
Location: Longview, WA

Re: Using QB4.5 Quick Libraries

Postby DonW » Mar 03, 2013 9:32

RockTheSchock wrote:I have changed the BLoad80x25 function, so prints now:

signature,segment,offset and length saved in the bsave'd file. please tell me theese values.


I can't provide those values...the BSAVE'ed files were created "behind the scenes" by an application generator called "Soft Code 4" distributed back in the '80's by Bottleworks Development Corp (now defunct). However, here's a short snippet of QB code that will BLOAD the same file if it helps...

Code: Select all

CLEAR , , 4096
DEFINT A-Z

'FOR COLOR DISPLAY

  COLOR 7, 0, 0
  CLS
    OUT 984, 1' Turn off screen display
    DEF SEG = -18432
    BLOAD "UTLMNU01.SCR", 0
    DEF SEG = 64
    OUT 984, 41      ' Turn on screen display with orig BIOS attrib
    DEF SEG

  WHILE KeyInput$ = "": KeyInput$ = INKEY$: WEND


Don
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Using QB4.5 Quick Libraries

Postby MichaelW » Mar 03, 2013 13:47

Using a Windows API message box with the qb dialect is not difficult, but due to the limitations of the dialect as you try to do more complex things with the API it becomes increasingly more difficult and messy.

Code: Select all

''=============================================================================
''
'' Compile as a console app.
''
''=============================================================================

#lang "qb"
option explicit

''=============================================================================

''--------------------------------------------------------------------------
'' Since fbgfx.bi, windows.bi, and crt.bi are not compatible with -lang qb,
'' the necessary definitions and declarations must be included in this
'' source file, and in a compatible form.
''
'' And as an example of what "a compatible form" means, the normal type
'' declaration for the Windows type UINT (in windef.bi) is:
''    type UINT as uinteger
'' But for -lang qb it must be:
''    type UINT as __uinteger
'' See the FreeBASIC UInteger documentation for more information.
''
'' Note that only the MessageBox-related definitions and declarations are
'' included.
''--------------------------------------------------------------------------

#define MB_USERICON 128
#define MB_ICONASTERISK 64
#define MB_ICONEXCLAMATION &h30
#define MB_ICONWARNING &h30
#define MB_ICONERROR 16
#define MB_ICONHAND 16
#define MB_ICONQUESTION 32
#define MB_OK 0
#define MB_ABORTRETRYIGNORE 2
#define MB_APPLMODAL 0
#define MB_DEFAULT_DESKTOP_ONLY &h20000
#define MB_HELP &h4000
#define MB_RIGHT &h80000
#define MB_RTLREADING &h100000
#define MB_TOPMOST &h40000
#define MB_DEFBUTTON1 0
#define MB_DEFBUTTON2 256
#define MB_DEFBUTTON3 512
#define MB_DEFBUTTON4 &h300
#define MB_ICONINFORMATION 64
#define MB_ICONSTOP 16
#define MB_OKCANCEL 1
#define MB_RETRYCANCEL 5
#define MB_SERVICE_NOTIFICATION &h00200000
#define MB_SERVICE_NOTIFICATION_NT3X &h00040000
#define MB_SETFOREGROUND &h10000
#define MB_SYSTEMMODAL 4096
#define MB_TASKMODAL &h2000
#define MB_YESNO 4
#define MB_YESNOCANCEL 3
#define MB_ICONMASK 240
#define MB_DEFMASK 3840
#define MB_MODEMASK &h00003000
#define MB_MISCMASK &h0000C000
#define MB_NOFOCUS &h00008000
#define MB_TYPEMASK 15
#define MB_TOPMOST &h40000

#define IDOK 1
#define IDCANCEL 2
#define IDABORT 3
#define IDRETRY 4
#define IDIGNORE 5
#define IDYES 6
#define IDNO 7
#define IDCLOSE 8
#define IDHELP 9

type HWND as long
type UINT as __uinteger
type LPCTSTR as __zstring __ptr
type LPCSTR as __zstring __ptr
type LPSTR as __zstring __ptr

declare function MessageBox lib "user32" alias "MessageBoxA"( _
                            byval hWnd as HWND, _
                            byval lpText as LPCTSTR, _
                            byval lpCaption as LPCTSTR, _
                            byval uType as UINT ) as long

''=============================================================================

dim as integer r

r = MessageBox( 0,"text","caption",MB_OK )
print r

r = MessageBox( 0, "text","caption", _
                MB_ABORTRETRYIGNORE or MB_ICONEXCLAMATION )
select case r
    case IDABORT
        print "IDABORT"
    case IDRETRY
        print "IDRETRY"
    case IDIGNORE
        print "IDIGNORE"
end select

r = MessageBox( 0, "text", "caption", _
                MB_YESNOCANCEL or MB_DEFBUTTON2 or MB_ICONQUESTION )
select case r
    case IDYES
        print "IDYES"
    case IDNO
        print "IDNO"
    case IDCANCEL
        print "IDCANCEL"
end select

sleep

''=============================================================================
Theunis Jansen
Posts: 248
Joined: Jul 01, 2010 9:35

Re: Using QB4.5 Quick Libraries

Postby Theunis Jansen » Mar 03, 2013 18:14

@ RockTheShock

by gum chum this is yum.

I eliminated the gunk that is printed on row 25 by making the FOR ..NEXT loop 1 to 24.

FB doesn't like screen 0 - it gives a tiny screen that cannot be maximized.

I checked the screens and found that - Screen 17,,,GFX_Fullscreen - works the best for these fullscreen (80x25) BSV's .
The prog works on - #lang "fblite" #include fbgfx.bi. It is thus not necessary to use #lang "qb"

What really puzzled me is that the SUB's are not and cannot be declared.

I stuck your two CALL's in a SUB named ShowBSV and calls to it work fine.

So yes you Rock without giving any shock and a big thank you.

EDIT: Sorry I see I have done the same thing Don did. I was quite happy and just wanted to say thank you so I did not read any of the others posts.
Theunis Jansen
Posts: 248
Joined: Jul 01, 2010 9:35

Re: Using QB4.5 Quick Libraries

Postby Theunis Jansen » Mar 06, 2013 10:45

@ RockTheShock

The required info is as follows:

Signature : 0xFD Segment : 0xB800 Offset: 0x0 Length(Bytes): 3840

I fiddled a bit with the print position because this data did not show on the screen. I also used #lang "fblite" #include "fbgfx.bi" and Screen 17,,,GFX_FULLSCREEN
I deleted Screen 0: Width 80,25 as it gives a tiny screen on my monitor.

1 TO 25 - When it got to 25 I got a Beep and some gunk. But no problem I changed it to 24 and then just before END SUB I added - locate 25,1: Print Space$(80); and it looked perfect.
RockTheSchock
Posts: 232
Joined: Mar 12, 2006 16:25

Re: Using QB4.5 Quick Libraries

Postby RockTheSchock » Mar 07, 2013 14:26

Signature : 0xFD Segment : 0xB800 Offset: 0x0 Length(Bytes): 3840


Now we know for sure!
Segment: 0xB800 text console buffer
Offset: 0x0 the first page of the text console
80*24*2 = 3840 'so there are stored only 24 rows

i had extended last version.
Sub BLoad80x25 loads also meta data like length and stores that information
Sub Print80x25 has an exit condition dealing with that problem.

Do you have tested my version of a textfield?
Theunis Jansen
Posts: 248
Joined: Jul 01, 2010 9:35

Re: Using QB4.5 Quick Libraries

Postby Theunis Jansen » Mar 07, 2013 15:52

I ran the program where you added the signature, segment, offset, length.

It still printed gunk and a beep on line 25. I did change it to 24 and row 25 is printed with the fgcolor,bgcolor, to me, without the black row, it looks better than the original

I had to change one line to THEN exit sub. This check did not work because it still beeped and printed gunk on row 25.

I did not check the QB program.
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Re: Using QB4.5 Quick Libraries

Postby sir_mud » Mar 19, 2013 0:53

I needed a cross platform way to show dialogs in plain fb graphics windows, so I wrote a little helper lib:
https://code.google.com/p/muds-pixel-gf ... alog-1.zip
I wrote a little wrapper for it for -lang qb and tested it just now.
I've only tested it with 32/24 bit screen modes, but it most likely won't work as is in others. I know i've hardcoded some dialog colors in there. You can still do 32/24 bit in -lang qb using __screenres x, y, bpp though

Dialogs are easy with this (especially with the lang qb wrapper):

Code: Select all

#include once "dialogs.bi"

__screenres 640, 480, 32
message("I like waffles and FreeBASIC!", 1) 'includes icons :D see dialogs.bi for the included ones.
message( input_str("Do you like waffles?"), 2)
angros47
Posts: 1743
Joined: Jun 21, 2005 19:04

Re: Using QB4.5 Quick Libraries

Postby angros47 » Mar 19, 2013 17:42

Being able to use QLB libraries has never been a Freebasic goal.

Anyway, it's a planned feature in QB64, through an emulator. So, anyone who need to use an old QLB library, and cannot find any alternative (I don't believe you can't, but it doesn't matter), could ask on QB64 forum.

Return to “General”

Who is online

Users browsing this forum: grindstone and 9 guests