Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Variadic-function/FreeBASIC/variadic-function-1.basic
Normal file
39
Task/Variadic-function/FreeBASIC/variadic-function-1.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 <> "" : Wend
|
||||
Print : Print "hit any key to end program"
|
||||
Sleep
|
||||
End
|
||||
13
Task/Variadic-function/FreeBASIC/variadic-function-2.basic
Normal file
13
Task/Variadic-function/FreeBASIC/variadic-function-2.basic
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
100 DEF PROC printAll DATA
|
||||
110 DO UNTIL ITEM()=0
|
||||
120 IF ITEM()=1 THEN
|
||||
READ a$
|
||||
PRINT a$
|
||||
130 ELSE
|
||||
READ num
|
||||
PRINT num
|
||||
140 LOOP
|
||||
150 END PROC
|
||||
|
||||
200 printAll 3.1415, 1.4142, 2.71828
|
||||
210 printAll "Mary", "had", "a", "little", "lamb",
|
||||
Loading…
Add table
Add a link
Reference in a new issue