Campbell Scientific CR1000KD CR800 and CR850 Measurement and Control Systems - Page 241
Data Tables
View all Campbell Scientific CR1000KD manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 241 highlights
Section 7. Installation 7.8.13.7 Formatting Strings Table 43. Formatting Strings Examples Expression 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) Result 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 CRBasic Example 49. Formatting Strings 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 44. Formatting Hexadecimal Variables - Examples Expression Comment CRLFNumeric(1) = &H0d0a Add leading zero to hex step 1 StringVar(20) = "0" & Hex(CRLFNumeric) Add leading zero to hex step 2 CRLFNumeric(2) = HexToDec(Strings(20)) Convert Hex string to Float Result 3338 0D0A 3338.00 7.8.14 Data Tables CRBasic Example 50. Two Data Intervals in One Data Table '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 241