ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 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-


© MCS Electronics, 1995-2007

for the hardware stack

' default use 10

$swstack = 10

for the SW stack

' default use 40

$framesize = 40

for the frame space

Dim S As String * 4 , Idx As Byte

Idx = 0 : S = Lookupstr(idx , Sdata)

'will print 'This'

Print S

End

Sdata:

Data "This" , "is" , "a test"

LOW

Action

Retrieves the least significant byte of a variable.

Syntax

var = LOW( s )

Remarks

Var

The variable that is assigned with the LSB of var S.

S

The source variable to get the LSB from.

You can also assign a byte to retrieve the LSB of a Word or Long.

For example :

B = L , where B is a byte and L is a Long.

See also

HIGH , HIGHW

Example

$regfile = "m48def.dat"

' specify the used

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 I As Integer , Z As Byte

I = &H1001

' is 1

Z = Low(i)

End

page -566-


© MCS Electronics, 1995-2007

LOWERLINE

Action

Reset the LCD cursor to the lower line.

Syntax

LOWERLINE

Remarks

NONE

See also

UPPERLINE , THIRDLINE , FOURTHLINE , HOME

Partial Example

Lcd "Test"

Lowerline

Lcd "Hello"

End

MAKEBCD

Action

Convert a variable into its BCD value.

Syntax

var1 = MAKEBCD(var2)

Remarks

var1

Variable that will be assigned with the converted value.

Var2

Variable that holds the decimal value.

When you want to use an I2C clock device, which stores its values as BCD values you can use this function to convert variables from decimal to BCD.

For printing the bcd value of a variable, you can use the BCD() function which converts a BCD number into a BCD string.

See also

MAKEDEC , BCD , MAKEINT

page -567-

© MCS Electronics, 1995-2007

Example

Dim A As Byte

A = 65

Lcd A

Lowerline

Lcd Bcd(a)

A = Makebcd(a)

Lcd " " ; A

End

MAKEINT

Action

Compact two bytes into a word or integer.

Syntax

varn = MAKEINT(LSB , MSB)

Remarks

Varn

Variable that will be assigned with the converted value.

LSB

Variable or constant with the LS Byte.

MSB

Variable or constant with the MS Byte.

The equivalent code is: varn = (256 * MSB) + LSB

See also

LOW , HIGH , MAKEBCD , MAKEDEC

Example

Dim A As Integer , I As Integer

A = 2

I = Makeint(a , 1) 'I = (1 * 256) + 2 = 258

End

MAKEDEC

Action

Convert a BCD byte or Integer/Word variable to its DECIMAL value.

Syntax

var1 = MAKEDEC(var2)

page -568-