'
'                           ___________________________________________
'         _______ _ _ _     \___           ___________________________/
'    /\  (_______) (_) |       /  //  //  /  
'   /  \  _  __  | |_| | _    /  //  //  / << version 0.86 alpha test >>
'  / /\ \| |(__| | | | || \  /  //  //  /  For FreeBASIC (v0.20b or later).
' | |__| | |     | | | |_) )/  //  //  /     
' |_|  |_|_|     |_|_|____//  //  //  /   Original Development by
'  _______________________/  //  //  /___ Adigun Azikiwe Polack for Aura Flow.
' /_____________________________________/
'
'  A  u  r  a      F  l  o  w      L  i  b  r  a  r  y      3
'_________________________________________________________________________
'
' (c)2005-2016 Adigun Azikiwe Polack/Aura Flow.  All Rights Reserved.
'
'
'
'    __  ____                ____                                 
'   /  |/  (_)____________  / / /___ _____  ___  ____  __  _______
'  / /|_/ / / ___/ ___/ _ \/ / / __ `/ __ \/ _ \/ __ \/ / / / ___/
' / /  / / (__  ) /__/  __/ / / /_/ / / / /  __/ /_/ / /_/ (__  ) 
'/_/  /_/_/____/\___/\___/_/_/\__,_/_/ /_/\___/\____/\__,_/____/  
'                                              __  ___          __      __   
'                                             /  |/  /___  ____/ /_  __/ /__ 
'                                            / /|_/ / __ \/ __  / / / / / _ \
'                                           / /  / / /_/ / /_/ / /_/ / /  __/
'                                          /_/  /_/\____/\__,_/\__,_/_/\___/ 
'                        
'
'_________________________________________________________________________
'                        ----- N O T I C E -----
'_________________________________________________________________________
' The following is this piece of source code to this version of AFlib III.
' You are free to look at it to give you some inspiring ideas in your own
' programming in FreeBASIC, but you are *never* to even change or adjust
' any of this source code whatsoever in any way, shape, or form at all.
' EVER.  ;)
'
' The reason for this is to ensure that all of the routines in this source
' code are working as properly as they should in FreeBASIC v0.20b or
' newer.  That is all.
'
' With that said, do enjoy the library and be inspired even more
' greatly than ever!!!  (^-^)//
'_________________________________________________________________________


#include once "windows.bi"
#include once "win/mmsystem.bi"

'$profile
'$stop_scan

#include once "fbgfx.bi"
ScreenControl(FB.SET_DRIVER_NAME, "GDI")

Dim Shared As Integer AF3_cons_file_handle = 0

Declare Sub AFlibIII_CustomSync (Byval framerate as Integer)

Declare Sub AFlibIII_Delay (Byval ticks as Integer)

Declare Function AFlibIII_ShowFPS as Integer

Declare Sub AFlibIII_ClearKeyBuffer

Declare Function AFlibIII_CheckScoreDigit_1s ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_10s ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_100s ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_1000s ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_10000s ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_100000s ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_1millions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_10millions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_100millions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_1billions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_10billions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_100billions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_1trillions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_10trillions ( Byval Score as Double ) as Integer
Declare Function AFlibIII_CheckScoreDigit_100trillions ( Byval Score as Double ) as Integer

Declare Function AFlibIII_Detect_CloseWindow as Integer

Declare Function AFlibIII_DetectCPUmhz as UlongInt

Declare Function AFlibIII_CheckFile ( Byref filename as String ) as Integer

Declare Sub AFlibIII_ConsoleEdit_Open
Declare Sub AFlibIII_ConsoleEdit_Print ( Byref text as String )
Declare Sub AFlibIII_ConsoleEdit_Close

Declare Sub AFlibIII_EndProgram






'_________________________________________________________________________
Sub AFlibIII_CustomSync (Byval framerate as Integer)

'------------------------------------------------------------------------
' This command sets forth a custom VSync-like timer to help balance
' the desired frame rate you select without even ending up with a 100%
' CPU usage problem, period!  Great for programming all-new games and
' stuff, you know?  (^-^)v
'
' BIG Special Thanks to yetifoot and MichaelW again for helping me to
' improve this routine a lot for AFlib III!!!  :D !!
'------------------------------------------------------------------------
  
  If framerate > 120 then framerate = 120
  If framerate < 1 then framerate = 1
  
  Static As Integer frames_per_second = 0.0
  Static As Double last_time = 0.0
  Static As Double time_start = 0.0
   
  Static As Single GL_fps = 60
       
  frames_per_second += 1

  timeBeginPeriod(1)
  Do: Sleep(1,1): Loop Until (Timer - time_start) >= (1/framerate)
  timeEndPeriod(1)
   
  time_start =  Timer
   
  If (time_start - last_time) > 1.0 Then
    last_time = time_start
    GL_fps = frames_per_second
    frames_per_second = 0
  End If
   
End Sub



'_________________________________________________________________________
Sub AFlibIII_Delay (Byval ticks as Integer)

Dim DelayTime as Integer

For DelayTime = 0 to ticks
  Sleep 6, 1
Next

End Sub



'___________________________________________________________________________
Function AFlibIII_ShowFPS as Integer

Static as Integer AFlibIII_frames, AFlibIII_frametime, AFlibIII_stime, AFlibIII_FPScount

AFlibIII_frames += 1 
AFlibIII_frametime = timer - AFlibIII_stime 
If AFlibIII_frametime > 2 then 
  AFlibIII_FPScount = AFlibIII_frames / AFlibIII_frametime
  AFlibIII_stime = timer 
  AFlibIII_frames = 0 
End if 

Return AFlibIII_FPScount
End Function



'_________________________________________________________________________
Sub AFlibIII_ClearKeyBuffer
While inkey$ <> "": Wend

End Sub



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_1s ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 1)) '<---- Used for helping to check the 1s
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case 0: ScTargetDigit = 0
    Case 1: ScTargetDigit = 1
    Case 2: ScTargetDigit = 2
    Case 3: ScTargetDigit = 3
    Case 4: ScTargetDigit = 4
    Case 5: ScTargetDigit = 5
    Case 6: ScTargetDigit = 6
    Case 7: ScTargetDigit = 7
    Case 8: ScTargetDigit = 8
    Case 9: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_10s ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 2)) '<---- Used for helping to check the 10s
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case  0 to  9: ScTargetDigit = 0
    Case 10 to 19: ScTargetDigit = 1
    Case 20 to 29: ScTargetDigit = 2
    Case 30 to 39: ScTargetDigit = 3
    Case 40 to 49: ScTargetDigit = 4
    Case 50 to 59: ScTargetDigit = 5
    Case 60 to 69: ScTargetDigit = 6
    Case 70 to 79: ScTargetDigit = 7
    Case 80 to 89: ScTargetDigit = 8
    Case 90 to 99: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_100s ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 3)) '<---- Used for helping to check the 100s
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case   0 to  99: ScTargetDigit = 0
    Case 100 to 199: ScTargetDigit = 1
    Case 200 to 299: ScTargetDigit = 2
    Case 300 to 399: ScTargetDigit = 3
    Case 400 to 499: ScTargetDigit = 4
    Case 500 to 599: ScTargetDigit = 5
    Case 600 to 699: ScTargetDigit = 6
    Case 700 to 799: ScTargetDigit = 7
    Case 800 to 899: ScTargetDigit = 8
    Case 900 to 999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_1000s ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 4)) '<---- Used for helping to check the 1-thousands
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case    0 to  999: ScTargetDigit = 0
    Case 1000 to 1999: ScTargetDigit = 1
    Case 2000 to 2999: ScTargetDigit = 2
    Case 3000 to 3999: ScTargetDigit = 3
    Case 4000 to 4999: ScTargetDigit = 4
    Case 5000 to 5999: ScTargetDigit = 5
    Case 6000 to 6999: ScTargetDigit = 6
    Case 7000 to 7999: ScTargetDigit = 7
    Case 8000 to 8999: ScTargetDigit = 8
    Case 9000 to 9999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_10000s ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 5)) '<---- Used for helping to check the 10-thousands
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case     0 to  9999: ScTargetDigit = 0
    Case 10000 to 19999: ScTargetDigit = 1
    Case 20000 to 29999: ScTargetDigit = 2
    Case 30000 to 39999: ScTargetDigit = 3
    Case 40000 to 49999: ScTargetDigit = 4
    Case 50000 to 59999: ScTargetDigit = 5
    Case 60000 to 69999: ScTargetDigit = 6
    Case 70000 to 79999: ScTargetDigit = 7
    Case 80000 to 89999: ScTargetDigit = 8
    Case 90000 to 99999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_100000s ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 6)) '<---- Used for helping to check the 100-thousands
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case      0 to  99999: ScTargetDigit = 0
    Case 100000 to 199999: ScTargetDigit = 1
    Case 200000 to 299999: ScTargetDigit = 2
    Case 300000 to 399999: ScTargetDigit = 3
    Case 400000 to 499999: ScTargetDigit = 4
    Case 500000 to 599999: ScTargetDigit = 5
    Case 600000 to 699999: ScTargetDigit = 6
    Case 700000 to 799999: ScTargetDigit = 7
    Case 800000 to 899999: ScTargetDigit = 8
    Case 900000 to 999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_1millions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 7)) '<---- Used for helping to check the 1-millions
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case       0 to  999999: ScTargetDigit = 0
    Case 1000000 to 1999999: ScTargetDigit = 1
    Case 2000000 to 2999999: ScTargetDigit = 2
    Case 3000000 to 3999999: ScTargetDigit = 3
    Case 4000000 to 4999999: ScTargetDigit = 4
    Case 5000000 to 5999999: ScTargetDigit = 5
    Case 6000000 to 6999999: ScTargetDigit = 6
    Case 7000000 to 7999999: ScTargetDigit = 7
    Case 8000000 to 8999999: ScTargetDigit = 8
    Case 9000000 to 9999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_10millions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 8)) '<---- Used for helping to check the 10-millions
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case        0 to  9999999: ScTargetDigit = 0
    Case 10000000 to 19999999: ScTargetDigit = 1
    Case 20000000 to 29999999: ScTargetDigit = 2
    Case 30000000 to 39999999: ScTargetDigit = 3
    Case 40000000 to 49999999: ScTargetDigit = 4
    Case 50000000 to 59999999: ScTargetDigit = 5
    Case 60000000 to 69999999: ScTargetDigit = 6
    Case 70000000 to 79999999: ScTargetDigit = 7
    Case 80000000 to 89999999: ScTargetDigit = 8
    Case 90000000 to 99999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_100millions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 9)) '<---- Used for helping to check the 100-millions
                                                        '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case         0 to  99999999: ScTargetDigit = 0
    Case 100000000 to 199999999: ScTargetDigit = 1
    Case 200000000 to 299999999: ScTargetDigit = 2
    Case 300000000 to 399999999: ScTargetDigit = 3
    Case 400000000 to 499999999: ScTargetDigit = 4
    Case 500000000 to 599999999: ScTargetDigit = 5
    Case 600000000 to 699999999: ScTargetDigit = 6
    Case 700000000 to 799999999: ScTargetDigit = 7
    Case 800000000 to 899999999: ScTargetDigit = 8
    Case 900000000 to 999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_1billions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 10)) '<---- Used for helping to check the 1-billions
                                                         '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case          0 to  999999999: ScTargetDigit = 0
    Case 1000000000 to 1999999999: ScTargetDigit = 1
    Case 2000000000 to 2999999999: ScTargetDigit = 2
    Case 3000000000 to 3999999999: ScTargetDigit = 3
    Case 4000000000 to 4999999999: ScTargetDigit = 4
    Case 5000000000 to 5999999999: ScTargetDigit = 5
    Case 6000000000 to 6999999999: ScTargetDigit = 6
    Case 7000000000 to 7999999999: ScTargetDigit = 7
    Case 8000000000 to 8999999999: ScTargetDigit = 8
    Case 9000000000 to 9999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_10billions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 11)) '<---- Used for helping to check the 10-billions
                                                         '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case           0 to  9999999999: ScTargetDigit = 0
    Case 10000000000 to 19999999999: ScTargetDigit = 1
    Case 20000000000 to 29999999999: ScTargetDigit = 2
    Case 30000000000 to 39999999999: ScTargetDigit = 3
    Case 40000000000 to 49999999999: ScTargetDigit = 4
    Case 50000000000 to 59999999999: ScTargetDigit = 5
    Case 60000000000 to 69999999999: ScTargetDigit = 6
    Case 70000000000 to 79999999999: ScTargetDigit = 7
    Case 80000000000 to 89999999999: ScTargetDigit = 8
    Case 90000000000 to 99999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_100billions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 12)) '<---- Used for helping to check the 100-billions
                                                         '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case            0 to  99999999999: ScTargetDigit = 0
    Case 100000000000 to 199999999999: ScTargetDigit = 1
    Case 200000000000 to 299999999999: ScTargetDigit = 2
    Case 300000000000 to 399999999999: ScTargetDigit = 3
    Case 400000000000 to 499999999999: ScTargetDigit = 4
    Case 500000000000 to 599999999999: ScTargetDigit = 5
    Case 600000000000 to 699999999999: ScTargetDigit = 6
    Case 700000000000 to 799999999999: ScTargetDigit = 7
    Case 800000000000 to 899999999999: ScTargetDigit = 8
    Case 900000000000 to 999999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_1trillions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 13)) '<---- Used for helping to check the 1-trillions
                                                         '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case             0 to  999999999999: ScTargetDigit = 0
    Case 1000000000000 to 1999999999999: ScTargetDigit = 1
    Case 2000000000000 to 2999999999999: ScTargetDigit = 2
    Case 3000000000000 to 3999999999999: ScTargetDigit = 3
    Case 4000000000000 to 4999999999999: ScTargetDigit = 4
    Case 5000000000000 to 5999999999999: ScTargetDigit = 5
    Case 6000000000000 to 6999999999999: ScTargetDigit = 6
    Case 7000000000000 to 7999999999999: ScTargetDigit = 7
    Case 8000000000000 to 8999999999999: ScTargetDigit = 8
    Case 9000000000000 to 9999999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_10trillions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 14)) '<---- Used for helping to check the 10-trillions
                                                         '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case              0 to  9999999999999: ScTargetDigit = 0
    Case 10000000000000 to 19999999999999: ScTargetDigit = 1
    Case 20000000000000 to 29999999999999: ScTargetDigit = 2
    Case 30000000000000 to 39999999999999: ScTargetDigit = 3
    Case 40000000000000 to 49999999999999: ScTargetDigit = 4
    Case 50000000000000 to 59999999999999: ScTargetDigit = 5
    Case 60000000000000 to 69999999999999: ScTargetDigit = 6
    Case 70000000000000 to 79999999999999: ScTargetDigit = 7
    Case 80000000000000 to 89999999999999: ScTargetDigit = 8
    Case 90000000000000 to 99999999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_CheckScoreDigit_100trillions ( Byval Score as Double ) as Integer
  
  Dim ScTargetDigit as Double
  ScTargetDigit = Val(Right(Ltrim(str(int(Score))), 15)) '<---- Used for helping to check the 100-trillions
                                                         '      digit in your score... VERY IMPORTANT!!!
  Select Case ScTargetDigit
    Case               0 to  99999999999999: ScTargetDigit = 0
    Case 100000000000000 to 199999999999999: ScTargetDigit = 1
    Case 200000000000000 to 299999999999999: ScTargetDigit = 2
    Case 300000000000000 to 399999999999999: ScTargetDigit = 3
    Case 400000000000000 to 499999999999999: ScTargetDigit = 4
    Case 500000000000000 to 599999999999999: ScTargetDigit = 5
    Case 600000000000000 to 699999999999999: ScTargetDigit = 6
    Case 700000000000000 to 799999999999999: ScTargetDigit = 7
    Case 800000000000000 to 899999999999999: ScTargetDigit = 8
    Case 900000000000000 to 999999999999999: ScTargetDigit = 9
  End Select
  
  Return ScTargetDigit 
End Function



'_________________________________________________________________________
Function AFlibIII_Detect_CloseWindow as Integer

If Inkey = Chr(255, 107) or MultiKey(&h38) and MultiKey(&h3E) then Return -1 else Return 0
End Function



'_________________________________________________________________________
Function AFlibIII_DetectCPUmhz as UlongInt

'----------------------------------------------------------------------
' Special thanks to D.J.Peters for this fine CPU detection routine!!
'----------------------------------------------------------------------

  Dim As UlongInt start64,diff64
  Dim As Double starttimer=Timer
  ASM
    rdtsc
    mov dword Ptr [start64], eax
    mov dword Ptr [start64+4], edx
  End ASM
  While (timer-starttimer)<1.0:Wend
  ASM
    rdtsc
    mov ebx, eax
    mov eax, edx
    sub ebx, dword Ptr [start64]
    sbb eax, dword Ptr [start64+4]
    mov dword Ptr [diff64], ebx
    mov dword Ptr [diff64+4], eax
  End ASM
  Return diff64\1000000

End Function



'_________________________________________________________________________
Function AFlibIII_CheckFile ( Byref filename as String ) as Integer

'----------------------------------------------------------------------
' VERY BIG special thanks to Mateusz Viste on this MOST TRULY
' OUTSTANDING file-checking routine!!!  d=^-^=b !!
'----------------------------------------------------------------------

  If Len(Dir(filename, 1 OR 2 OR 4 OR 16 OR 32)) > 0 then Return -1: Exit Function '<---- If the selected target filename is currently available, it will return "-1", 
                                                                                   '      otherwise "0" (NULL) is returned when using this function.
  Return 0
End Function



'_________________________________________________________________________
Sub AFlibIII_ConsoleEdit_Open
'----------------------------------------------------------------------
' BIG special thanks to notthecheatr for this great console output
' opening routine!!!
'----------------------------------------------------------------------
  AF3_cons_file_handle = Freefile()
  Open Cons For Output as #AF3_cons_file_handle
End Sub



'_________________________________________________________________________
Sub AFlibIII_ConsoleEdit_Print ( Byref text as String )
'----------------------------------------------------------------------
' BIG special thanks to notthecheatr for this great console output
' printing routine!!!
'----------------------------------------------------------------------
  If AF3_cons_file_handle = 0 then Exit Sub
  Print #AF3_cons_file_handle, text
End Sub



'_________________________________________________________________________
Sub AFlibIII_ConsoleEdit_Close
'----------------------------------------------------------------------
' BIG special thanks to notthecheatr for this great console output
' closing routine!!!
'----------------------------------------------------------------------
  If AF3_cons_file_handle = 0 then Exit Sub
  Close #AF3_cons_file_handle
End Sub



'_________________________________________________________________________
Sub AFlibIII_EndProgram
'----------------------------------------------------------------------
' This command is to ENSURE that your FreeBASIC program safely ends
' and gets you back to Windows 10 or later, all without any hanging or
' becoming 'stuck' at the end of your program's run-time.   It is VERY
' IMPORTANT that you use this command whenever you want to end your
' program or get the user safely back to Windows!!!  ;)
'----------------------------------------------------------------------
  Screen 0: End 0
End Sub





