Oxygen Basic

Programming => Problems & Solutions => Topic started by: chrisc on March 24, 2018, 11:42:25 AM

Title: Equivalent of PB Array Scan command
Post by: chrisc on March 24, 2018, 11:42:25 AM
in PB we have an Array Scan command, according to
http://manmrk.net/tutorials/basic/PowerBASIC/pbcc/array_scan_statement.htm (http://manmrk.net/tutorials/basic/PowerBASIC/pbcc/array_scan_statement.htm)

Code: [Select]
Scan all or part of an array for a given value.

Syntax


Numeric array:

ARRAY SCAN array([index]) [FOR count], expression, TO lvar&

String arrays:

ARRAY SCAN array ([index]) [FOR count] [, FROM start TO end] [, COLLATE {UCASE |

    cstring}], expression, TO lvar&


what is the O2 equivalent to this command?
Title: Re: Equivalent of PB Array Scan command
Post by: Charles Pegge on March 24, 2018, 01:42:20 PM

Hi Chris,

That command is one of the most complicated command I have ever encountered. It just needs to be broken down into regular Basic, then it becomes comprehensible.

Code: [Select]
'2018-03-24 T 21:29:07
'ARRAY SCAN FUNCTIONALITY
int a={2,4,6,8,1,3,5,7,9} 'some data for testing
int i,j
j=0
for i=1 to countof a
  if a[i]<2 then j=i : exit for
next
print j '5'