ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8234
Скачиваний: 1
© MCS Electronics, 1995-2007
'lookup and return the index
Idx = Lookdown(search , Label , Entries)
Print Idx
Search = 1
Idx = Lookdown(search , Label , Entries)
Print Idx
Search = 100 |
|
Idx = Lookdown(search , Label , Entries) |
' return -1 if not |
Print Idx |
|
found |
|
'looking for integer or word data requires that the search variable is |
|
'of the type integer ! |
|
Dim Isearch As Integer |
|
Isearch = 400 |
|
Idx = Lookdown(isearch , Label2 , Entries) |
' return 3 |
Print Idx |
|
End
Label:
Data 1 , 2 , 3 , 4 , 5
Label2:
Data 1000% , 200% , 400% , 300%
LOOKUP
Action
Returns a value from a table.
Syntax
var = LOOKUP( value, label)
Remarks
Var |
The returned value |
Value |
A value with the index of the table |
Label |
The label where the data starts |
The value can be up to 65535. 0 will return the first entry.
See also
LOOKUPSTR
Example
$regfile = "m48def.dat" ' specify the used
page -564-
© MCS Electronics, 1995-2007 |
|
micro |
' used crystal |
$crystal = 4000000 |
|
frequency |
' use baud rate |
$baud = 19200 |
|
$hwstack = 32 |
' default use 32 |
for the hardware stack |
' default use 10 |
$swstack = 10 |
|
for the SW stack |
' default use 40 |
$framesize = 40 |
|
for the frame space |
|
Dim B1 As Byte , I As Integer |
|
B1 = Lookup(2 , Dta) |
' Prints 3 (zero |
Print B1 |
|
based) |
|
I = Lookup(0 , Dta2) |
' print 1000 |
Print I |
|
End |
|
Dta: |
|
Data 1 , 2 , 3 , 4 , 5 |
|
Dta2: |
|
Data 1000% , 2000% |
LOOKUPSTR
Action
Returns a string from a table.
Syntax
var = LOOKUPSTR( value, label )
Remarks
Var |
The string returned |
Value |
A value with the index of the table. The index is zero-based. That is, 0 will |
return the first element of the table. |
|
Label |
The label where the data starts |
The index value can have a maximum value of 255.
See also
LOOKUP , LOOKDOWN
Example
$regfile = "m48def.dat" |
' specify the used |
micro |
' used crystal |
$crystal = 4000000 |
|
frequency |
' use baud rate |
$baud = 19200 |
|
$hwstack = 32 |
' default use 32 |
page -565- |