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

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

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

Добавлен: 12.06.2025

Просмотров: 8169

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

© MCS Electronics, 1995-2007

There are also other alternatives. You can use a Do.. Loop for example :

Dim Var As Byte

Do

'code

Incr Var

Loop Until Var = 10

There are various way to get the result you need.

See also

EXIT FOR

Example

'-----------------------------------------------------------------------------

------------

: for_next.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo: FOR, NEXT

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'-----------------------------------------------------------------------------

------------

$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 A As Byte , B1 As Byte , C As Integer

For A = 1 To 10 Step 2

Print "This is A " ; A

Next A

Print "Now lets count down"

For C = 10 To -5 Step -1

Print "This is C " ; C

Next

Print "You can also nest FOR..NEXT statements."

For A = 1 To 10

Print "This is A " ; A

For B1 = 1 To 10

Print "This is B1 " ; B1

' note that you do

Next

not have to specify the parameter

Next A

End

page -493-


© MCS Electronics, 1995-2007

FOURTHLINE

Action

Set LCD cursor to the start of the fourth line.

Syntax

FOURTHLINE

Remarks

Only valid for LCD displays with 4 lines.

See also

HOME , UPPERLINE , LOWERLINE , THIRDLINE, LOCATE

Example

Thirdline

Lcd "Line 3"

Fourthline

Lcd "Line 4"

'goto home on line

Home Third

three

Home Fourth

Home F

'first letter also works

FRAC

Action

Returns the fraction of a single.

Syntax

var = FRAC( single )

Remarks

var

A numeric single variable that is assigned with the fraction of

variable single.

single

The single variable to get the fraction of.

The fraction is the right side after the decimal point of a single.

See Also

INT

page -494-


© MCS Electronics, 1995-2007

Example

'-----------------------------------------------------------------------------

--

: (c) 1995-2005, MCS Electronics

'copyright

'micro

: Mega48

'suited for demo

: yes

'commercial addon needed

: no

'purpose

: demonstrates FRAC function

'-----------------------------------------------------------------------------

--

$regfile = "m48def.dat"

' specify the used

micro

' used crystal

$crystal = 8000000

frequency

' use baud rate

$baud = 19200

$hwstack = 32

' default use 32

for the hardware stack

' default use 10

$swstack = 40

for the SW stack

' default use 40

$framesize = 40

for the frame space

Dim X As Single

X = 1.123456

Print X

Print Frac(x)

End

FREEFILE

Action

Returns a free Filenumber.

Syntax

bFileNumber = FREEFILE()

Remarks

bFileNumber A byte variable , which can be used for opening next file

This function gives you a free file number, which can be used for file – opening statements. In contrast to VB this file numbers start with 128 and goes up to 255. Use range 1 to 127 for user defined file numbers to avoid file number conflicts with the system numbers from FreeFile()

This function is implemented for compatility with VB.

See also

INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FILEATTR , SEEK , BSAVE , BLOAD , KILL , DISKFREE , DISKSIZE , GET , PUT , FILEDATE , FILETIME ,

page -495-


© MCS Electronics, 1995-2007

FILEDATETIME , DIR , FILELEN , WRITE , INPUT

ASM

Calls

_GetFreeFileNumber

Input

none

Output

r24: Filenumber

r25: Errorcode

C-Flag: Set on Error

Partial Example

Ff =Freefile() ' get file handle

Open"test.txt" For Input As #ff ' we can use a constant for the file too Print Lof(#ff);" length of file"

Print Fileattr(#ff);" file mode" ' should be 1 for input Do

LineInput #ff , S ' read a line

' line input is used to read a line of text from a file Print S ' print on terminal emulator

Loop UntilEof(ff)<> 0

'The EOF() function returns a non-zero number when the end of the file is reached 'This way we know that there is no more data we can read

Close #ff

FUSING

Action

FUSING returns a formatted string of a single value.

Syntax

target = FUSING(source, "mask")

Remarks

target

The string that is assigned with the formatted string.

source

The source variable of the type SINGLE that will be converted

mask

The mask for formatting the string.

The mask is a string constant that always must start with #.

After the decimal point you can provide the number of digits you want

the string to have:

#.### will give a result like 123.456. Rounding is used when you use

the # sign. So 123.4567 will be converted into 123.457

When no rounding must be performed, you can use the & sign instead of

the # sign. But only after the DP.

#.&&& will result in 123.456 when the single has the value 123.4567

When the single is zero, 0.0 will be returned, no matter how the mask is set up.

page -496-