© MCS Electronics, 1995-2007
push r2
#endif
'*** here we call the routine ***
Stcheck
'*** when error <>0 then there is a problem ***
#if Testmode = 1 pop r2
pop r1 pop r0
#endif
Return
STOP
Action
Stop the specified device. Or stop the program
Syntax
STOP device
STOP
Remarks
Device TIMER0, TIMER1, COUNTER0 or COUNTER1, WATCHDOG, AC (Analog comparator power) or ADC(A/D converter power)
The single STOP statement will end your program by generating a never ending loop. When END is used it will have the same effect but in addition it will disable all interrupts.
The STOP statement with one of the above parameters will stop the specified device.
TIMER0 and COUNTER0 are the same device.
The AC and ADC parameters will switch power off the device to disable it and thus save power.
See also
START , END
Example
See START example
STR
Action
Returns a string representation of a number.
© MCS Electronics, 1995-2007
Syntax
var = STR( x)
Remarks
var |
A string variable. |
X |
A numeric variable. |
|
|
The string must be big enough to store the result.
You do not need to convert a variable into a string before you print it.
When you use PRINT var, then you will get the same result as when you convert the numeric variable into a string, and print that string.
The PRINT routine will convert the numeric variable into a string before it gets printed to the serial port.
As the integer conversion routines can convert byte, integer, word and longs into a string it also means some code overhead when you do not use longs. You can include the alternative library named mcsbyte.lbx then. This library can only print bytes. There is also a library for printing integers and words only. This library is named mcsbyteint.
When you use these libs to print a long you will get an error message.
See also
VAL , HEX , HEXVAL , MCSBYTE , BIN
Difference with VB
In VB STR() returns a string with a leading space. BASCOM does not return a leading space.
Example
Dim A As Byte , S As String * 10 A = 123
S = Str(a)
Print S ' 123 'when you use print a, you will get the same result.
'but a string can also be manipulated with the string routines.
End
STRING
Action
Returns a string consisting of m repetitions of the character with ASCIICode n.
Syntax
var = STRING(m ,n)
Remarks
Var The string that is assigned.
page -680-
© MCS Electronics, 1995-2007
N |
The ASCII-code that is assigned to the string. |
M |
The number of characters to assign. |
Since a string is terminated by a 0 byte, you can't use 0 for n.
Using 0 for m will result in a string of 255 bytes, because there is no check on a length assign of 0.
See also
SPACE
Example
$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 S As String * 15 |
|
S = String(5 , 65) |
'AAAAA |
Print S |
End |
|
SUB
Action
Defines a Sub procedure.
Syntax
SUB Name[(var1 , … )]
Remarks
Name |
Name of the sub procedure, can be any non-reserved word. |
var1 |
The name of the parameter. |
|
|
You must end each subroutine with the END SUB statement.
You can copy the DECLARE SUB line and remove the DECLARE statement. This ensures that you have the right parameters.
See Also
FUNCTION , CALL
See the DECLARE SUB topic for more details.
page -681-
© MCS Electronics, 1995-2007
SYSSEC
Action
Returns a Number, which represents the System Second
Syntax
Target = SYSSEC()
Target = SYSSEC(bSecMinHour)
Target = SYSSEC(strTime, strDate)
Target = SYSSEC(wSysDay)
Remarks
Target |
A Variable (LONG), that is assigned with the System-Second |
BSecMinHou A Byte, which holds the Sec-value followed by Min(Byte), Hour (Byte), |
r |
Day(Byte), Month(Byte) and Year(Byte) |
StrTime |
A time-string in the format „hh:mm:ss" |
StrDate |
A date-string in the format specified in the Config Date statement |
wSysDay |
A variable (Word) which holds the System Day (SysDay) |
The Function can be used with 4 different kind of inputs:
1.Without any parameter. The internal Time and Date of SOFTCLOCK (_sec, _min, _hour, _day, _month, _year) is used.
2.With a user defined time and Date array. It must be arranged in same way (Second, Minute, Hour, Day, Month, Year) as the internal SOFTCLOCK time/date. The first Byte (Second) is the input by this kind of usage. So the SystemSecond can be calculated of every time/date.
3.With a time-String and a date-string. The time-string must be in the Format „hh:mm:ss". The date-string must be in the format specified in the Config Date statement
4.With a System Day Number (Word). The result ist the System Second of this day at 00:00:00.
The Return-Value is in the Range of 0 to 2147483647. 2000-01-01 at 00:00:00 starts with 0.
The Function is valid from 2000-01-01 to 2068-01-19 03:14:07. In the year 2068 a LONG – overflow will occur.
See also
Date and Time Routines , SYSSECELAPSED, SYSDAY
Example
Enable Interrupts
Config Clock = Soft
Config Date = YMD , Separator =.' ANSI-Format
Dim Strdate As String * 8
Dim Strtime As String * 8
© MCS Electronics, 1995-2007
Dim Bsec As Byte , Bmin As Byte , Bhour As Byte
Dim Bday As Byte , Bmonth As Byte , Byear As Byte
Dim Wsysday As Word
Dim Lsyssec As Long
'Example 1 with internal RTC-Clock
'Load RTC-Clock for example - testing
_sec = 17 : _min = 35 : _hour = 8 : _day = 16 : _month = 4 : _year = 3 Lsyssec = Syssec()
Print "System Second of " ; Time$ ; " at " ; Date$ ; " is " ; Lsyssec
'System Second of 08:35:17 at 03.04.16 is 103797317
'Example 2 with with defined Clock - Bytes (Second, Minute, Hour, Day / Month / Year)
Bsec = 20 : Bmin = 1 : Bhour = 7 : Bday = 22 : Bmonth = 12 : Byear = 1 Lsyssec = Syssec(bsec)
Strtime = Time_sb(bsec) : Strdate = Date_sb(bday)
Print "System Second of " ; Strtime ; " at " ; Strdate ; " is " ; Lsyssec
'System Second of 07:01:20 at 01.12.22 is 62319680
'Example 3 with Time and Date - String
Strtime = "04:58:37" strDate ="02.09.18"
Lsyssec = Syssec(strtime , Strdate)
Print "System Second of " ; Strtime ; " at " ; Strdate ; " is " ; Lsyssec ' System Second of 04:58:37 at 02.09.18 is 85640317
'Example 4 with System Day Wsysday = 2000
Lsyssec = Syssec(wsysday)
Print "System Second of System Day " ; Wsysday ; " (00:00:00) is " ; Lsyssec
'System Second of System Day 2000 (00:00:00) is 172800000
SYSSECELAPSED
Action
Returns the elapsed Seconds to a earlier assigned system-time-stamp.
Syntax
Target = SysSecElapsed(SystemTimeStamp)
Remarks
Target |
A variable (LONG), that is assigned with the elapsed Seconds |
SystemTimeStamp |
A variable (LONG), which holds a Systemtimestamp like the output |
|
of an earlier called SysSec() |
|
|
The Return-Value is in the Range of 0 to 2147483647. The Function is valid from 2000-01-01 to 2068-01-19 at 03:14:07. In the year 2068 a LONG – overflow will occur.
The difference to the pair DayOfSec and SecElapsed is, that SysSec and SysSecElapsed can