Filter: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 2,990: | Line 2,990: | ||
<syntaxhighlight lang="q">x where 0=x mod 2</syntaxhighlight> |
<syntaxhighlight lang="q">x where 0=x mod 2</syntaxhighlight> |
||
=={{header|QBASIC}}== |
==={{header|QBASIC}}=== |
||
{{works with|QuickBasic|4.x}} |
{{works with|QuickBasic|4.x}} |
||
{{works with|Visual Basic for DOS|1.0}} |
{{works with|Visual Basic for DOS|1.0}} |
||
Line 2,999: | Line 2,999: | ||
' Filter |
' Filter |
||
' This program selects certain elements from an array into a new array in a generic way |
' This program selects certain elements from an array into a new array in a generic way |
||
' Extra points: Destroys the original values in the array |
|||
' SUBs |
' SUBs |
||
Line 3,008: | Line 3,009: | ||
CONST Uneven = 1 |
CONST Uneven = 1 |
||
DIM t AS INTEGER |
DIM t AS INTEGER |
||
Dim t2 AS INTEGER |
|||
DIM i AS INTEGER |
DIM i AS INTEGER |
||
DIM iArray%(1 TO 1) |
DIM iArray%(1 TO 1) |
||
DIM iArray2%(1 TO 1) |
|||
' Register |
' Register |
||
Line 3,034: | Line 3,035: | ||
' Shows the result |
' Shows the result |
||
t2 = UBOUND(iArray%) |
|||
IF |
IF t2 > 0 THEN |
||
PRINT "Selected items from the array (total:"; |
PRINT "Selected items from the array (total:"; t2; "of"; t; "):" |
||
FOR i = 1 TO |
FOR i = 1 TO t2 |
||
PRINT |
PRINT iArray%(i); |
||
NEXT i |
NEXT i |
||
END IF |
END IF |
||
Line 3,055: | Line 3,056: | ||
DIM rSub AS regSub |
DIM rSub AS regSub |
||
SHARED iArray%() |
SHARED iArray%() |
||
SHARED iArray2%() |
|||
CONST aName$ = "DUMMY$$$.$$$" |
CONST aName$ = "DUMMY$$$.$$$" |
||
CONST False = 0, True = NOT False |
CONST False = 0, True = NOT False |
||
Line 3,082: | Line 3,082: | ||
' Redims the 2nd array |
' Redims the 2nd array |
||
t = LOF(f) / LEN(rSub) |
t = LOF(f) / LEN(rSub) |
||
REDIM |
REDIM iArray%(1 TO t) |
||
FOR i = 1 TO t |
FOR i = 1 TO t |
||
GET #f, i, rSub |
GET #f, i, rSub |
||
iArray%(i) = rSub.aNum |
|||
NEXT i |
NEXT i |
||