Help converting from QuickBasic to FreeBASIC

General FreeBASIC programming questions.
Gablea
Posts: 991
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Help converting from QuickBasic to FreeBASIC

Postby Gablea » Mar 18, 2012 10:27

Hi all

can someone help me please I am trying to convert this code

Code: Select all

   DIM ScanX AS INTEGER
   DIM ScanY AS INTEGER
   DIM background(9585)

   GET (0, 0)-(639, 15), background
      LINE (0, 0)-(639, 15), 0, BF
         LOCATE 1, 1: PRINT txt$
            FOR ScanY = 0 TO 12
               FOR ScanX = 0 TO 639
                  IF POINT(ScanX, ScanY) <> 0 THEN
                     LINE (ScanX * size + x, ScanY * size + y)-(ScanX * size + size + x, ScanY * size + size + y), POINT(ScanX, ScanY), BF
                  END IF
               NEXT ScanX
            NEXT ScanY

   PUT (0, 0), background, PSET


this is what I have so far come up with but it is not working

Code: Select all

SUB sprint (txt As string, x As Integer, y As Integer, size As Integer)
   DIM ScanX AS INTEGER
   DIM ScanY AS Integer
      ScreenInfo w,h
      screenbuffer = imagecreate(640,480)
      Get (0,0) - (639,479), screenbuffer


   GET (0, 0)-(639, 15), screenbuffer
      LINE (0, 0)-(639, 15), 0, BF
         LOCATE 1, 1: PRINT txt
            FOR ScanY = 0 TO 12
               FOR ScanX = 0 TO 639
                  IF POINT(ScanX, ScanY) <> 0 THEN
                     LINE (ScanX * size + x, ScanY * size + y)-(ScanX * size + size + x, ScanY * size + size + y), POINT(ScanX, ScanY), BF
                  END IF
               NEXT ScanX
            NEXT ScanY

   PUT (0, 0), screenbuffer, PSET
 
END Sub


any advice would be welcomed
fxm
Posts: 8347
Joined: Apr 22, 2009 12:46
Location: Paris (suburb), FRANCE

Re: Help converting from QuickBasic to FreeBASIC

Postby fxm » Mar 18, 2012 12:31

Code: Select all

SUB sprint (BYREF txt AS STRING, BYVAL x AS INTEGER, BYVAL y AS INTEGER, BYVAL size AS INTEGER)

   DIM ScanX AS INTEGER
   DIM ScanY AS INTEGER
   DIM ColorP AS INTEGER
   DIM w AS INTEGER
   SCREENINFO w
   DIM fh AS INTEGER = 16 ' compatible up to font height of 16 pixels
   DIM screenbuffer AS ANY PTR = IMAGECREATE(w, fh)

   DRAW STRING screenbuffer, (0, 0), txt
   FOR ScanY = 0 TO fh - 1
      FOR ScanX = 0 TO w - 1
         ColorP = POINT(ScanX, ScanY, screenbuffer)
         IF ColorP <> 0 THEN
            LINE (ScanX * size + x, ScanY * size + y)-STEP(size, size), ColorP, BF
         END IF
      NEXT ScanX
   NEXT ScanY
   
   IMAGEDESTROY screenbuffer

END SUB



SCREEN 12
COLOR 11
sprint("Zoom x 5", 20, 10, 5)
SLEEP

[Edit]
Updated from the below two remarks of counting_pine.
Last edited by fxm on Mar 21, 2012 14:11, edited 1 time in total.
counting_pine
Site Admin
Posts: 5953
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Help converting from QuickBasic to FreeBASIC

Postby counting_pine » Mar 19, 2012 21:18

Don't forget to ImageDestroy the screenbuffer! :)
For speed, the POINT() value should probably be put into a variable rather than re-called.
fxm
Posts: 8347
Joined: Apr 22, 2009 12:46
Location: Paris (suburb), FRANCE

Re: Help converting from QuickBasic to FreeBASIC

Postby fxm » Mar 19, 2012 21:34

counting_pine wrote:Don't forget to ImageDestroy the screenbuffer! :)
Yes, I forgot it at the end of the Sub.

Remark: This topic has been copied to 'General', but not suppressed in 'DOS'!
Last edited by fxm on Mar 21, 2012 13:34, edited 4 times in total.
Gablea
Posts: 991
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Help converting from QuickBasic to FreeBASIC

Postby Gablea » Mar 19, 2012 21:50

Is there a way i can make this work with out having to use screen 11 or screenres ?

beacuse at the moment the software crashes when it trys to set the screen
dodicat
Posts: 5156
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Help converting from QuickBasic to FreeBASIC

Postby dodicat » Mar 21, 2012 0:22

Maybe you could try:

SetEnviron("fbgfx=GDI")

at the beginning of your code, then retry screen/screenres.
counting_pine
Site Admin
Posts: 5953
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Help converting from QuickBasic to FreeBASIC

Postby counting_pine » Mar 21, 2012 13:27

fxm wrote:Remark: This topic has been copied to 'General', but not suppressed in 'DOS'

I do that deliberately when I move threads, in order to make sure the original poster sees it has been moved instead of just disappearing. The phpbb software calls it a Shadow Topic.
But I'd rather you didn't use text in this format to try and draw attention, if that's ok.
:)

@dodicat: I think it may have just become relevant that Gablea is using DOS, so can't change the driver.

@Gablea: From a quick scan of the routine, its purpose is to put large text on the screen.
It's not clear here whether you can get any graphics mode at all, but if you need to avoid graphics mode entirely, I think your options are either to Print the text at normal size or to go 8|16 times bigger and Print each pixel as its own character.

Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests