Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BASCOM AVR, help reference (2007).PDF
Скачиваний:
305
Добавлен:
12.08.2013
Размер:
17.02 Mб
Скачать

© MCS Electronics, 1995-2007

Syntax

var = ROUND( x )

Remarks

Var

A single or double variable that is assigned with the ROUND of

 

variable x.

X

The single or double to get the ROUND of.

 

 

Round(2.3) = 2 , Round(2.8) = 3

Round(-2.3) = -2 , Round(-2.8) = -3

See Also

INT , FIX , SGN

Example

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

 

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

: round_fix_int.bas

'name

'copyright

: (c) 1995-2005, MCS Electronics

'purpose

: demo : ROUND,FIX

'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 S As Single , Z As Single

For S = -10 To 10 Step 0.5

Print S ; Spc(3) ; Round(s) ; Spc(3) ; Fix(s) ; Spc(3) ; Int(s)

Next

End

RTRIM

Action

Returns a copy of a string with trailing blanks removed

page -621-

© MCS Electronics, 1995-2007

Syntax

var = RTRIM( org )

Remarks

var

String that is assigned with the result.

org

The string to remove the trailing spaces from

 

 

See also

TRIM , LTRIM

ASM

NONE

Example

Dim S As String * 6

S =" AB "

Print Ltrim(s)

Print Rtrim(s)

Print Trim(s)

End

SECELAPSED

Action

Returns the elapsed Seconds to a former assigned time-stamp.

Syntax

Target = SECELAPSED(TimeStamp)

Remarks

Target

A variable (LONG), that is assigned with the elapsed Seconds

TimeStamp A variable (LONG), which holds a timestamp like the output of an earlier called SecOfDay()

The Function works with the SOFTCLOCK variables _sec, _min and _hour and considers a jump over midnight and gives a correct result within 24 hour between two events.

The Return-Value is in the range of 0 to 86399.

See also

Date and Time Routines , SecOfDay , SysSecElapsed

Partial Example

Lsecofday = Secofday()

page -622-

© MCS Electronics, 1995-2007

_hour = _hour + 1

Lvar1 = Secelapsed(lsecofday)

Print Lvar1

SECOFDAY

Action

Returns the Seconds of a Day.

Syntax

Target = SECOFDAY()

Target = SECOFDAY(bSecMinHour)

Target = SECOFDAY(strTime)

Target = SECOFDAY(lSysSec)

Remarks

Target

A variable (LONG), that is assigned with the Seconds of the Day

bSecMinHour

A Byte, which holds the Second-value followed by Minute(Byte) and

 

Hour(Byte)

strTime

A String, which holds the time in the format „hh:mm:ss"

LSysSec

A Variable (Long) which holds the System Second

 

 

The Function can be used with 4 different kind of inputs:

1.Without any parameter. The internal Time of SOFTCLOCK (_sec, _min, _hour) is used.

2.With a user defined time array. It must be arranged in same way (Second, Minute, Hour) as the internal SOFTCLOCK time. The first Byte (Second) is the input by this kind of usage. So the Second of Day can be calculated of every time.

3.With a time-String. The time-string must be in the Format „hh:mm:ss".

4.With a System Second Number (LONG)

The Return-Value is in the range of 0 to 86399 from 00:00:00 to 23:59:59. No validity-check of input is made.

See also

Date and Time Routines , SysSec

Partial Example

'================= Second of Day

=============================================

'Example 1 with internal RTC-Clock

_sec = 12 : _min = 30 : _hour = 18

' Load RTC-Clock

for example - testing

 

Lsecofday = Secofday()

 

 

page -623-

© MCS Electronics, 1995-2007

Print "Second of Day of " ; Time$ ; " is " ; Lsecofday

'Example 2 with defined Clock - Bytes (Second / Minute / Hour) Bsec = 20 : Bmin = 1 : Bhour = 7

Lsecofday = Secofday(bsec)

Print "Second of Day of Sec=" ; Bsec ; " Min=" ; Bmin ; " Hour=" ; Bhour ; " (" ; Time(bsec) ; ") is " ; Lsecofday

'Example 3 with System Second

Lsyssec = 1234456789 Lsecofday = Secofday(lsyssec)

Print "Second of Day of System Second " ; Lsyssec ; "(" ; Time(lsyssec) ; ") is " ; Lsecofday

' Example 4 with Time - String Strtime = "04:58:37"

Lsecofday = Secofday(strtime)

Print "Second of Day of " ; Strtime ; " is " ; Lsecofday

SEEK

Action

Function: Returns the position of the next Byte to be read or written

Statement: Sets the position of the next Byte to be read or written

Syntax

Function: NextReadWrite = SEEK (#bFileNumber)

Statement: SEEk #bFileNumber, NewPos

Remarks

bFileNumber

(Byte) Filenumber, which identifies an opened file

NextReadWrit

A Long Variable, which is assigned with the Position of the next Byte to

e

be read or written (1-based)

NewPos

A Long variable that holds the new position the file pointer must be set

 

too.

 

 

This function returns the position of the next Byte to be read or written. If an error occurs, 0 is returned. Check DOS-Error in variable gbDOSError.

The statement also returns an error in the gbDOSerror variable in the event that an error occurs.

You can for example not set the file position behinds the file size.

In VB the file is filled with 0 bytes when you set the file pointer behind the size of the file. For embedded systems this does not seem a good idea.

Seek and Loc seems to do the same function, but take care : the seek function willreturn the position of the next read/write, while the Loc function returns the position of the astl read/write. You may say that Seek = Loc+1.

page -624-