KazuLog.bi

Game development specific discussions.
Post Reply
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

KazuLog.bi

Post by Kamui_Kazuma »

A small thing I made a while ago, recently remade;
Its a header file that enables the easy usage of detailed debug logs:

Code: Select all

#PRAGMA ONCE
''To use this you must specify the program's title and version number something like this:
''#INCLUDE "KazuLog.bi"
''progtitle = "ProgramNameHere"
''progversion = "ProgramVersionHere"
Dim Shared As String progtitle, progversion
Dim Shared As Boolean dbmode
#IF __FB_DEBUG__ <> 0
dbmode = true
#ELSE
dbmode = false
#ENDIF

Sub startlog( log_name As String, fnum As ULong )
    Open logname For OutPut As #fnum
    Open logname For Output As #fnum
    Print #fnum, progtitle
    Print #fnum, progversion
    Print #fnum, ""
    Print #fnum, "Compiled with: " & __FB_SIGNATURE__ & " From: " & __FB_BUILD_DATE__
    
    If dbmode = true Then
        Print #fnum, " In debug mode"
    Else
        Print #fnum, " In release mode"
    End If
    
    Print #fnum, " On: "; __DATE__; " "; __TIME__
    Print #fnum, ""
    Print #fnum, " Run time: "; Date; " "; Time
    Print #fnum, ""
End Sub

Sub putlog( text As String, fnum As ULong )
    Print #fnum, Time; " -"; text
End Sub
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: KazuLog.bi

Post by Tourist Trap »

Nice, it's a clean example of the kind of tool. But what is PRAGMA doing?
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

Re: KazuLog.bi

Post by Kamui_Kazuma »

Tourist Trap wrote:Nice, it's a clean example of the kind of tool. But what is PRAGMA doing?
this is actually part of a larger header I made to just allow for quick access to several variables and subs/functions I use on a regular basis... things like( this is in snippits btw, don't want to share the whole thing; hope you understand ^^ )

Code: Select all

Const wincolor = RGBA( 0, 0, 150, 225 )


Sub emptyinkey
    While Inkey <> "" : WEnd
End Sub

Sub arrowmenu( ByVal topval As Single, ByVal bottomval As Single )
    Sleep
    If Multikey( SC_UP   ) And menupos > topval    Then menupos -= 1
    If Multikey( SC_DOWN ) And menupos < bottomval Then menupos += 1
End Sub
The reason for PRAGMA being there is there happens to be code that I only want run once, ( also this header is included in some other headers I've made )

I started off with Sinclair BASIC which is a whole different ball-game to FB, but the ability to just have access to a 'template' of sorts and a small set of predefined variables makes me feel at home.

Long story short: "It's so I don't always need to type #INCLUDE ONCE"
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: KazuLog.bi

Post by Tourist Trap »

Kamui_Kazuma wrote: Long story short: "It's so I don't always need to type #INCLUDE ONCE"
Thanks a lot, I learned something because I always wondered what this keyword was made for.
Kamui_Kazuma
Posts: 14
Joined: Oct 23, 2016 1:22

Re: KazuLog.bi

Post by Kamui_Kazuma »

Once I get this header in a somewhat presentable state I'll put it up here on another thread.
Post Reply