Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
39
Task/Variadic-function/BASIC/variadic-function-2.basic
Normal file
39
Task/Variadic-function/BASIC/variadic-function-2.basic
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
' version 15-09-2015
|
||||
' compile with: fbc -s console
|
||||
|
||||
Sub printAll_string Cdecl (count As Integer, ... )
|
||||
Dim arg As Any Ptr
|
||||
Dim i As Integer
|
||||
|
||||
arg = va_first()
|
||||
For i = 1 To count
|
||||
Print *Va_Arg(arg, ZString Ptr)
|
||||
arg = va_next(arg, ZString Ptr)
|
||||
Next i
|
||||
End Sub
|
||||
|
||||
' ------=< MAIN >=------
|
||||
' direct
|
||||
printAll_string (5, "Foxtrot", "Romeo", "Echo", "Echo", "BASIC")
|
||||
|
||||
' strings
|
||||
Print : Print
|
||||
Dim As String a = "one", b = "two", c = "three"
|
||||
printAll_string (3, a, b, c)
|
||||
|
||||
' count is smaller then the number of arguments, no problem
|
||||
Print : Print
|
||||
printAll_string (1, a, b, c)
|
||||
|
||||
' count is greater then the number of arguments
|
||||
' after the last valid argument garbage is displayed
|
||||
' should be avoided, could lead to disaster
|
||||
Print : Print
|
||||
printAll_string (4, a, b, c)
|
||||
Print
|
||||
|
||||
' empty keyboard buffer
|
||||
While InKey <> "" : Var _key_ = InKey : Wend
|
||||
Print : Print "hit any key to end program"
|
||||
Sleep
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue