Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How many parameters are too many parameters?
#6
Not all that difficult to adapt the code to a User Defined Type scheme, and you can make awesome shorthand routines:

Code: (Select All)
'not a whole program just a block to edit the original
Type box_type
    Mode As Integer
    X1 As Integer
    Y1 As Integer
    X2 As Integer
    Y2 As Integer
    Caption As String
    FontColor As _Unsigned Long
    FontBackground As _Unsigned Long
    BoxColor As _Unsigned Long
    BoxHighLight As _Unsigned Long
    XOffset As Integer
    YOffset As Integer
End Type
Dim bx As box_type
Screen _NewImage(1280, 720, 32)
$Color:32

Dim i As Long
For i = 0 To 4
    Print "Showcasing diffferent modes for Box.  This is mode #"; i
    Set_Box bx, i, 100, 100, 200, 200, "Hello World", Red, Blue, Gold, Silver, 0, 0

   if i = 4 then  Change_BoxCaption Bx,"Bye Bye"
    Box bx
    Sleep
    Cls
Next

Sub Set_Box (TheBox As box_type, Mode As Integer, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer, Caption As String, FontColor As _Unsigned Long, FontBackground As _Unsigned Long, BoxColor As _Unsigned Long, BoxHighLight As _Unsigned Long, XOffset As Integer, YOffset As Integer)
    TheBox.Mode = Mode
    TheBox.X1 = X1
    TheBox.Y1 = Y1
    TheBox.X2 = X2
    TheBox.Y2 = Y2
    TheBox.Caption = Caption
    TheBox.FontColor = FontColor
    TheBox.FontBackground = FontBackground
    TheBox.BoxColor = BoxColor
    TheBox.BoxHighLight = BoxHighLight
    TheBox.XOffset = XOffset
    TheBox.YOffset = YOffset
End Sub

Sub Set_BoxMode (TheBox As box_type, mode As Integer)
    If mode > 0 And mode < 5 Then
        TheBox.Mode = mode
    Else
        TheBox.Mode = 0
    End If
End Sub
Sub Change_BoxCaption (TheBox As box_type, caption As String)
    TheBox.Caption = caption
End Sub
Sub move_Box (TheBox As box_type, xmove As Integer, ymove As Integer)
    TheBox.X1 = TheBox.X1 + xmove
    TheBox.Y1 = TheBox.Y1 + ymove
    TheBox.X2 = TheBox.X2 + xmove
    TheBox.Y2 = TheBox.Y2 + ymove
End Sub

Sub Box (TheBox As box_type)
    Dim Mode As Integer, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer, Caption As String, FontColor As _Unsigned Long, FontBackground As _Unsigned Long, BoxColor As _Unsigned Long, BoxHighLight As _Unsigned Long, XOffset As Integer, YOffset As Integer
    Mode = TheBox.Mode
    X1 = TheBox.X1
    Y1 = TheBox.Y1
    X2 = TheBox.X2
    Y2 = TheBox.Y2
    Caption = TheBox.Caption
    FontColor = TheBox.FontColor
    FontBackground = TheBox.FontBackground
    BoxColor = TheBox.BoxColor
    BoxHighLight = TheBox.BoxHighLight
    XOffset = TheBox.XOffset
    YOffset = TheBox.YOffset
  '  ...
Reply


Messages In This Thread
RE: How many parameters are too many parameters? - by James D Jarvis - 10-19-2023, 05:03 PM



Users browsing this thread: 1 Guest(s)