Campbell-scientific CR3000 Micrologger Instrukcja Użytkownika Strona 245

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
Przeglądanie stron 244
Section 7. Installation
245
7.8.13.7 Formatting Strings
Table 45. Formatting Strings Examples
Expression Result
Str(1)=123e4
Str(2)=FormatFloat(123e4,"%12.2f")
Str(3)=FormatFloat(Values(2)," The battery is %.3g Volts ")
Str(4)=Strings(3,1,InStr(1,Strings(3),"The battery is ",4))
Str(5)=Strings(3,1,InStr(1,Strings(3),"is ",2) + 3)
Str(6)=Replace("The battery is 12.4 Volts"," is "," = ")
Str(7)=LTrim("The battery is 12.4 Volts")
Str(8)=RTrim("The battery is 12.4 Volts")
Str(9)=Trim("The battery is 12.4 Volts")
Str(10)=UpperCase("The battery is 12.4 Volts")
Str(12)=Left("The battery is 12.4 Volts",5)
Str(13)=Right("The battery is 12.4 Volts",7)
1230000
1230000.00
“The battery is 12.4 Volts”
12.4 Volts
12.4 Volts
The battery = 12.4 Volts
The battery is 12.4 Volts
The battery is 12.4 Volts
The battery is 12.4 Volts
THE BATTERY IS 12.4 VOLTS
The b
Volts
CRBasicExample49. FormattingStrings
Objective:
Format the string "The battery is 12.4 Volts"
Use CRBasic expression:
StringVar(11) = Mid("The battery is 12.4 Volts", _
InStr(1,"The battery is 12.4 Volts"," is ",2)+3,Len("The battery is 12.4 Volts"))
Result:
12.4 Volts
7.8.13.8 Formatting String Hexadecimal Variables
Table 46. Formatting Hexadecimal Variables - Examples
Expression Comment Result
CRLFNumeric(1) = &H0d0a
Add leading zero to hex step 1
3338
StringVar(20) = "0" & Hex(CRLFNumeric)
Add leading zero to hex step 2
0D0A
CRLFNumeric(2) = HexToDec(Strings(20))
Convert Hex string to Float
3338.00
7.8.14 Data Tables
CRBasicExample50. TwoDataIntervalsinOneDataTable
'CRBasic program to write to a single table with two different time intervals.
'Note: this is a conditional table, check the table fill times in the Status table.
'For programs with conditional tables AND other time driven tables, it is generally
'wise to NOT auto allocate the conditional table; set a specific number of records.
'Declare Public Variables
Public PTemp, batt_volt, airtempC, deltaT
Public int_fast As Boolean
Public int_slow As Boolean
Public counter(4) As Long
Przeglądanie stron 244
1 2 ... 240 241 242 243 244 245 246 247 248 249 250 ... 589 590

Komentarze do niniejszej Instrukcji

Brak uwag