Dim number
As String ' stores whole number(w/o dec) minus "." Dim convert
As String ' stores the orginal number in string format
convert
= Str$(num
) ' convert it all to a strig If Right$(convert
, 1) <> "." Then convert
= convert
+ "." ' weird fix for lower numbers number
= Left$(convert
, InStr(convert
, ".") - 1) ' store the integer
tpl = "" ' create a template string for USING
For I
= 1 To Len(number
): tpl
= tpl
+ "#":
Next ' add a hash per digit per integer digit tpl = tpl + "," ' set the comma tag
If flt
> 0 Then ' is the decimal count set? tpl = tpl + "." ' add the decimal tag
For I
= 1 To flt: tpl
= tpl
+ "#":
Next ' how many places (as per dec) ' PRINT "tpl for "; num
' PRINT tpl
Print Using tpl; num;
' now PRINT USING should look cleaner
'// MANY GRID GAME DIST CALCULATOR
'3D Distance Calc Pathag Theorym
DIST
= Sqr((x1
- x2
) ^ 2 + (y1
- y2
) ^ 2 + (z1
- z2
) ^ 2)
'// DETERMINE IF STRING IS A INTEGER/DOUBLE OR NOT
Function IS_NUMBER
(NUM
As String) ' returns 1 if string is an integer, 0 if not IS_NUMBER = 1
IS_NUMBER = 0
'@option_str = list of characters (can be separated by comma) as only option to seelect from
OPTION_STR = " " + OPTION_STR 'The space in the INSTR instruction and the > 1 are there as otherwise the loop would exit on the first pass.
GET_OPTION = OPT
'//==========================================================================================================================
'// --- THESE ARE LEGACY FUNCTIONS USE AT OWN DISCRECTION
'//==========================================================================================================================
'// DEC(X) -1 TO X
'// INC(X) +1 TO X
'// DISTANCE: DISTANCE BETWEEN 2 X,Y COORDS
'// yesNo (default AS STRING)
day$
= Str$(d
) ' eliminate any leading zeros Case 1: moon$
= "January" Case 2: moon$
= "February" Case 9: moon$
= "September" Case 10: moon$
= "October" Case 11: moon$
= "November" Case 12: moon$
= "December" TODAYS_DATE
= WeekDay$
(m
, d
, y
) + ", " + moon$
+ day$
+ ", " + year$
+ Space$(10)
If M
< 3 Then M
= M
+ 12: Y
= Y
- 1 'add 12 to Jan - Feb month, -1 year C
= Y \
100: Y
= Y
Mod 100 'split century and year number S1 = (C \ 4) - (2 * C) - 1 'century leap
S2 = (5 * Y) \ 4 '4 year leap
S3 = 26 * (M + 1) \ 10 'days in months
WKDAY
= (S1
+ S2
+ S3
+ D
) Mod 7 'weekday total remainder If WKDAY
< 0 Then WKDAY
= WKDAY
+ 7 'Adjust negative results to 0 to 6 Case 3: Day$
= "Wednesday" Case 4: Day$
= "Thursday" Case 6: Day$
= "Saturday" WeekDay$ = Day$
'============================================================================
'--- PASCAL FUNCTION: DECREASES X BY 1)
'============================================================================
X = X - 1
DEC = X
'============================================================================
'--- PASCAL FUNCTION: INCREASE X BY 1)
'============================================================================
X = X + 1
INC = X
'============================================================================
'--- DIST BETWEEN 2 POINTS
'============================================================================
DISTANCE
= Sqr((X1
- X2
) ^ 2 + (Y1
- Y2
) ^ 2)
'// @default = when ENTER is pressed what will be the default answer
yesNo = 1
yesNo = 0
'//
'// RETURNS THE NUMBER OF LORD TAGS IN A STRING
'//
COUNT = 0
COUNT_TAGS = COUNT
'//
'// CENTER TEXT AS A SPECIFIED ROW
'//
TAGS = COUNT_TAGS(text) * 2
textLen
= Int((Len(text
) - TAGS
) / 2)
col = 40 - textLen
LWRITE text
'======================================================
'--- THIS IS A POPULAR COLOR ROUTINE BASED ON THE
'--- SETH ABLE L.O.R.D. BBS GAME COLOR FORMATTING
'=====================================================
' CHECK FOR A COLOR CHANGE
i = i + 1
i = i + 1
LWRITE (TXT$)
'//
'// speical thanks to SPRIGGYSPRIG for his inspiration to make this sub.
'// https://www.qb64.org/forum/index.php?topic=3721.0
'// USAGE
'// EXPLODE DELIMITED STRING, DELIMETER, ARRAY TO RETURN
'// EXAMPLE: EXPLODE CONSOLE.Extentions, CHR$(32), SPLIT_EXT()
'//
CNT = 1
EXPLODED_ARY
(CNT
) = EXPLODED_ARY
(CNT
) + Mid$(HAYSTACK
, i
, 1) CNT = CNT + 1
'Sub EXPLODE (SplitMeString As String, delim As String, loadMeArray() As String)
' Dim curpos As Long, arrpos As Long, LD As Long, dpos As Long 'fix use the Lbound the array already has
' curpos = 1: arrpos = LBound(loadMeArray): LD = Len(delim)
' dpos = InStr(curpos, SplitMeString, delim)
' Do Until dpos = 0
' loadMeArray(arrpos) = Mid$(SplitMeString, curpos, dpos - curpos)
' arrpos = arrpos + 1
' If arrpos > UBound(loadMeArray) Then ReDim _Preserve loadMeArray(LBound(loadMeArray) To UBound(loadMeArray) + 1000) As String
' curpos = dpos + LD
' dpos = InStr(curpos, SplitMeString, delim)
' Loop
' loadMeArray(arrpos) = Mid$(SplitMeString, curpos)
' ReDim _Preserve loadMeArray(LBound(loadMeArray) To arrpos) As String 'get the ubound correct
'End Sub
CENTER "`8 --`2------------=`0=`%[ " + TXT + " `%]=`0= `2------------`8-- ", Y
LWRITELN ("`8 - --`3------------------=`!=`%*`!=`3------------------`8-- - ")
'y = y coord to place it
'dark = dark color
'med = medium color
'light = light color
'center pause? = 1(yes), 0(mo)
SPIN(1) = "*": SPIN(2) = "/": SPIN(3) = "-"
SPIN(4) = "\": SPIN(5) = "|": SPIN(6) = "/"
SPIN(7) = "-": SPIN(8) = "\": SPIN(9) = "|"
x = 2
'// IF NOT CENTERED
LWRITE "`" + DARK + "--`" + MED + "------------=`" + LIGHT + "=`" + HILITE + "[ " + SPIN(x) + " `" + HILITE + "]=`" + LIGHT + "= `" + MED + "------------`" + DARK + "-- "
CENTER "`" + DARK + "--`" + MED + "------------=`" + LIGHT + "=`" + HILITE + "[ " + SPIN(x) + " `" + HILITE + "]=`" + LIGHT + "= `" + MED + "------------`" + DARK + "-- ", y
'// ANIMATE SPINNER
x
= x
+ 1:
If x
> 9 Then x
= 2