04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Section 7. Installation<br />

7.8.13.7 Formatting Strings<br />

Table 43. Formatting Strings Examples<br />

Expression<br />

Str(1)=123e4<br />

Str(2)=FormatFloat(123e4,"%12.2f")<br />

Str(3)=FormatFloat(Values(2)," The battery is %.3g Volts ")<br />

Str(4)=Strings(3,1,InStr(1,Strings(3),"The battery is ",4))<br />

Str(5)=Strings(3,1,InStr(1,Strings(3),"is ",2) + 3)<br />

Str(6)=Replace("The battery is 12.4 Volts"," is "," = ")<br />

Str(7)=LTrim("The battery is 12.4 Volts")<br />

Str(8)=RTrim("The battery is 12.4 Volts")<br />

Str(9)=Trim("The battery is 12.4 Volts")<br />

Str(10)=UpperCase("The battery is 12.4 Volts")<br />

Str(12)=Left("The battery is 12.4 Volts",5)<br />

Str(13)=Right("The battery is 12.4 Volts",7)<br />

Result<br />

1230000<br />

1230000.00<br />

“The battery is 12.4 Volts”<br />

12.4 Volts<br />

12.4 Volts<br />

The battery = 12.4 Volts<br />

The battery is 12.4 Volts<br />

The battery is 12.4 Volts<br />

The battery is 12.4 Volts<br />

THE BATTERY IS 12.4 VOLTS<br />

The b<br />

Volts<br />

CRBasic Example 49.<br />

Formatting Strings<br />

Objective:<br />

Format the string "The battery is 12.4 Volts"<br />

Use CRBasic expression:<br />

StringVar(11) = Mid("The battery is 12.4 Volts", _<br />

InStr(1,"The battery is 12.4 Volts"," is ",2)+3,Len("The battery is 12.4 Volts"))<br />

Result:<br />

12.4 Volts<br />

7.8.13.8 Formatting String Hexadecimal Variables<br />

Table 44. Formatting Hexadecimal Variables - Examples<br />

Expression Comment Result<br />

CRLFNumeric(1) = &H0d0a Add leading zero to hex step 1 3338<br />

StringVar(20) = "0" & Hex(CRLFNumeric) Add leading zero to hex step 2 0D0A<br />

CRLFNumeric(2) = HexToDec(Strings(20)) Convert Hex string to Float 3338.00<br />

7.8.14 Data Tables<br />

CRBasic Example 50.<br />

Two Data Intervals in One Data Table<br />

'CRBasic program to write to a single table with two different time intervals.<br />

'Note: this is a conditional table, check the table fill times in the Status table.<br />

'For programs with conditional tables AND other time driven tables, it is generally<br />

'wise to NOT auto allocate the conditional table; set a specific number of records.<br />

'Declare Public Variables<br />

Public PTemp, batt_volt, airtempC, deltaT<br />

Public int_fast As Boolean<br />

Public int_slow As Boolean<br />

Public counter(4) As Long<br />

240

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!