Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

6.3.4 DAY$[(int_expr)]

Given an integer expression specifying the number of days since January 1, 1600, DAY$ returns the day of the week. If no integer expression is given, DAY$ returns the day of the week for today's date. The day is returned as a string expression (Friday, Saturday, etc.).

Example 6-42 DAY$ function

  print day$
 
 
Saturday 

6.3.5 FULLTIME$[(float_expr, [int_var])]

Given the number of seconds since the Sheerpower base date, the FULLTIME$ function returns the date and time in one of the formats given below.

float_expr is the number of seconds since the Sheerpower base date. The default is the current date and time. January 1, 1600 00:00:00 is considered the second 0.

Table 6-3 FULLTIME$ Function - Integer Values
Value (int_var) Output Data Format
0 CCYYMDD HHMMSS
1 MMDDCCYY HHMMSS
2 DDMMCCYY HHMMSS
3 DD-Mon-CCYY HH:MM:SS
4 Month DD, CCYY HH:MM:SS

Example 6-43 FULLTIME$ Function

  print fulltime$
  sec = seconds('20000121 115042') 
  print fulltime$(sec, 0) 
  print fulltime$(sec, 1) 
  print fulltime$(sec, 2) 
  print fulltime$(sec, 3) 
  print fulltime$(sec, 4) 
  end
 
 
20000208 232653 
20000121 115042 
01212000 115042 
21012000 115042 
21-Jan-2000 11:50:42 
January 21, 2000 11:50:42 

6.3.6 SECONDS(str_expr)

Given a full-time string in CCYYMMDD HHMMSS, YYMMDD HHMMSS, HHMMSS or HHMM format, the SECONDS function returns the number of seconds since the Sheerpower base date (January 1, 1600 00:00:00).

The number of seconds is returned as a floating point number.

Example 6-44 SECONDS Function

  z  = seconds('20000122 103050') 
  z1 = seconds('990122 103050') 
  z2 = seconds('103050') 
  z3 = seconds('1030') 
  print 'Seconds cymdhms ='; z 
  print 'Seconds  ymdhms ='; z1 
  print 'Seconds     hms ='; z2 
  print 'Seconds     hm  ='; z3 
  end
 
 
Seconds cymdhms = 12624633050 
seconds  ymdhms = 12593097050 
seconds     hms = 37850 
seconds     hm  = 37800 

6.3.7 TIME(int_expr)

The value returned by the TIME function depends on the value of int_expr.

If int_expr = 0, TIME returns the number of seconds since midnight.

If int_expr = 1, TIME returns the CPU time of the process in tenths of a second.

If int_expr = 2, TIME returns connect time of the current process in minutes.

Example 6-45 TIME Function

  print time(0) 
  print time(1) 
  print time(2) 
  end
 
 
67004 
1 
0 

6.3.8 TIME(5)

TIME(5) returns the number of seconds since Sheerpower was invoked. This function can be used to time events to the nearest 100th/sec.

Example 6-46 TIME(5) Function

  print time(5)
 
 
 .03 

6.3.9 TIME$

or

TIME$(num_expr)

If num_expr is NOT specified, TIME$ returns the current time of day in HH:MM:SS format.

num_expr is the number of seconds since midnight. The result is returned in HH:MM format.

Example 6-47 TIME$ Function

  print time$(1800) 
  print time$(54178) 
  print time$
  end
 
 
00:30 
15:02 
11:33:27 

6.3.10 Pivot Date

Many applications allow the end-user to enter a six-digit date. For a six-digit date, Sheerpower needs to know which century the year is in. For example:


  161231 

Is this 1916, December 31 or 2016, December 31st?

The default PIVOT DATE in Sheerpower is year 20. As such, Sheerpower assumes that if a six-digit date is given, and the YEAR is less than 20, then it is the 20th century. In the example above:


  161231 --> December 31, 1916 

The default pivot date can be changed by creating a logical:


  Sheerpower_Y2K_PIVOT 

This can be done with the following small program:

Example 6-48 Pivot Date Logical

  set system, logical 'Sheerpower_Y2K_PIVOT': value '17' 

Then the value will automatically be setup for all Sheerpower applications. The logical is checked for only ONCE at sp4gl.exe STARTUP time.

6.4 String Manipulation Functions

The following are string manipulation functions that Sheerpower performs:

6.4.1 ASCII(str_expr)

The ASCII function returns the decimal ASCII value of a string's first character. It is returned as an integer. The Section 6.4.6 is the opposite of the ASCII function.

Example 6-49 ASCII Function

  print ascii('A') 
 
 
65 

6.4.2 BASE64ENCODE$(str_expr,[boolean])

The BASE64ENCODE$ function takes a text string and returns it encoded in Base64. To decode an Base64 encoded string, see Section 6.4.3, BASE64DECODE$(str_expr).

Example 6-50 BASE64ENCODE$ Function

  print base64encode$('What is the base64 encoded version of this sentence?') 
  end
 
V2hhdCBpcyB0aGUgYmFzZTY0IGVuY29kZWQgdmVyc2lvbiBvZiB0aGlzIHNlbnRlbmNlPw== 

When encoding a string to Base64, any whitespace in the text string is included. Note that when decoding a string of Base64 text, whitespace is not part of the decode data. The two examples below show the difference when the same strings are encoded, but one has whitespace in the string.

Example 6-51 BASE64ENCODE$ Function: Encoding With Whitespace

  print base64encode$('    Man ') 
  end
 
ICAgIE1hbiA= 

Example 6-52 BASE64ENCODE$ Function: Encoding Without Whitespace

  print base64encode$('Man') 
  end
  
TWFu 

By default the BASE64ENCODE$ function will, every 76 characters, write out a cr/lf (new line). If the OPTIONAL 2nd BOOLEAN parameter is set to FALSE, then no cr/lf is inserted. By default the boolean parameter is set to TRUE. The example below illustrates this optional parameter.

Example 6-53 BASE64ENCODE$ Function With CRLF Inserted

  \\ no boolean parameter specified defaults to "true" 
  \\ inserts line breaks (crlf) every 76 characters 
  print base64encode$(repeat$('Hi there ', 50), true)  
  end
 
SGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkg 
dGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhl 
cmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUg 
SGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkg 
dGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhl 
cmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUg 
SGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkg 
dGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUg 

Example 6-54 BASE64ENCODE$ Function With No CRLF Inserted

  \\ no line breaks (crlf) inserted 
  \\ results shown below are the full width of the SP4GL console window 
  print base64encode$(repeat$('Hi there ', 50), false) 
  end
 
 
SGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhl 
cmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkg 
dGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUg 
SGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhl 
cmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkg 
dGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUg 
SGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhl 
cmUgSGkgdGhlcmUgSGkgdGhlcmUgSGkgdGhlcmUg 


Previous Next Contents Index