SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

The FORMAT$ function supports character rotation. The ROTATE option rotates the last nn characters of a string to the first position in the string.


        FORMAT$(z$, '{ROTATE n}?') 

The ? can be replaced with a mask.

6.4.13 GETSYMBOL$( )

The GETSYMBOL$ function is used to return script variables and symbols. These can be the results of an HTML form submission, CGI environment variables, SheerPower symbols, DNS symbols, operating system symbols, or any variable you have defined as a symbol.

The GETSYMBOL$ function has an optional parameter that allows you to not trim the leading and trailing spaces of a symbol returned. The default parameter is set to TRUE. "True" is implied and means that the leading and trailing spaces will be trimmed. The FALSE parameter can be used if you do not want the leading and trailing spaces trimmed from the symbol retrieved.

Example 6-65 GETSYMBOL$ function - SheerPower Symbol & Trimming Option

  set system, symbol 'test': value '  hi there' 
  print '<';getsymbol$('sp:test');'>'
  print '<';getsymbol$('sp:test', false);'>'
  print '<';getsymbol$('sp:test', true);'>'
  
<hi there> 
<  hi there> 
<hi there>  

Below are a few more examples of GETSYMBOL$:

Example 6-66 GETSYMBOL$ function - HTML form submission

  //  print the contents of the symbol "city" from a HTML form submit. 
  print getsymbol$('city') 

Example 6-67 GETSYMBOL$ function - CGI Environment Symbol

  // print the contents of the environment symbol REMOTE_ADDR 
  print getsymbol$('env:REMOTE_ADDR') 

Example 6-68 GETSYMBOL$ function - Operating System Symbol

  // print the contents of the operating system symbol PATH 
  print getsymbol$('os:PATH') 
  // and list the contents of the TEMP directory 
  print getsymbol$('os:TEMP') 
 
 
C:\PROGRA~1\Java\JRE16~2.0_0\bin;C:\PROGRA~1\Java\JRE16~2.0_0\bin;C:\WINDOWS\sys 
tem32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PROGRA~1\ABSOLU~1;C:\Program Files\
QuickTime\QTSystem\;C:\Program Files\IDM Computer Solutions\UltraEdit\;C:\Progra 
m Files\IDM Computer Solutions\UltraCompare;. 
C:\DOCUME~1\User\LOCALS~1\Temp 

Below is a list of symbol prefixes supported:

Table 6-8 Supported Symbol Prefixes
Symbol Prefix Description
env: CGI environment variables (see Section 19.3.8, Summary of CGI Environment Variables)
os: Operating system symbols. If the symbol begins with a \ then it is a registry symbol.
sp: SheerPower symbols (see Section 11.14.15, SET SYSTEM, SYMBOL: VALUE )
dns: DNS symbols (see Section 11.14.14, Performing DNS Lookups with ASK SYSTEM, SYMBOL )

6.4.14 HASH$(str_expr1 [, str_expr2 [, int_expr]])

The HASH$ function changes the plain text in str_expr1 into a hashed eight-byte string value. It can be used to develop one-way hashed passwords. The optional text in str_expr2 and optional int_expr can be used to further make the hashed value unique.

Example 6-69 HASH$ function

  password$ = hash$('TRUTH') 
  input 'Password': pwd$ 
  if  hash$(pwd$) = password$  then
    print 'That was the correct password.' 
  else        
    print 'That was not the correct password.' 
  end if
  end     
 
 
password?  MONEY 
That was not the correct password. 

6.4.15 LCASE$(str_expr)

LCASE returns a string expression with all letters in lower case. See Section 6.4.41, UCASE$(str_expr).

Example 6-70 LCASE$ function

  print lcase$('IT HAS BEEN A WONDERFUL DAY!') 
 
 
it has been a wonderful day! 

6.4.16 LEFT[$](str_expr, int_expr)

LEFT$ returns the leftmost nn characters from a string. int_expr is the last character position to be included in the resulting string.

Example 6-71 LEFT [$] function

  print left$('Hello there!', 3 ) 
  
  
Hel 

6.4.17 LEN(str_expr)

LEN returns the length of a string. It returns an integer.

Example 6-72 LEN function

  print len('These are the built-in functions of SheerPower.') 
  
  
47 

6.4.18 LPAD$(text_str, size [, pad_str])

LPAD$ pads a string on the left with pad characters. The default pad character is a space.

Example 6-73 LPAD$ function

  print lpad$('123', 6, '0') 
 
 
000123 

6.4.19 LTRIM$(str_expr)

LTRIM$ removes all leading spaces (those on the left side of the string).

Example 6-74 LTRIM$ function

  print ltrim$('   This function gets rid of leading spaces to the left of a string.') 
  end
 
 
This function gets rid of leading spaces to the left of a string. 

6.4.20 MAXLEN(str_var)

MAXLEN returns the maximum number of characters that a string variable can contain. Since all string variables are variable length with a maximum of 16711425, this function always returns 16711425.

Example 6-75 MAXLEN function

  print maxlen('Hi') 
  
  
16711425 

6.4.21 MEM(int_memory_address)

MEM() returns a zero-terminated string where the first byte starts at the given memory address.

If the memory address passed to the MEM() function is not readable, MEM() returns a zero-length string.

The format for MEM() is:


  string_result = mem(int_memory_address) 

Where STRING_RESULT is the zero-terminated string pointed to by the given memory address.

Example 6-76 MEM function

  library 'msvcrt.dll' 
  call 'ctime' (0%)         // returns a pointer to a zero-terminated string 
  mytime$ = mem(_integer)   // get the string with the MEM() fuction 
  print '-- '; mytime$ 
  end
 
 
 
-- Wed Dec 31 16:00:00 1969 

6.4.22 MID[$](str_expr, int_expr1 [,int_expr2])

MID$ or MID returns a substring from the middle characters of a specified string, leaving the string unchanged. int_expr1 is the starting position of the substring, and int_expr2 is the length of the substring. MID$(str_expr,int_expr1) will return the rest of the string.

Example 6-77 MID [$] function

  a$      = 'beginmiddleend' 
  middle$ = mid$(a$, 6, 6) 
  end$    = mid$(a$, 6) 
  print middle$, end$ 
  end
 
 
middle     middleend 

6.4.23 ORD(str_expr)

Given the ASCII name of a character, the ORD function returns the location of that character in the ASCII character table. It returns an integer number.

Example 6-78 ORD function

  print ord('H') 
  
  
72 

6.4.24 ORDNAME$(int_expr)

Given the location of a character in the ASCII character table, the ORDNAME$ function returns the name of that character.

Example 6-79 ORDNAME$ function

  print ordname$(69) 
  
  
E 

6.4.25 PARSE$(str_expr)

PARSE$ splits a string into tokens and returns each token separated by a space. Letters are UPPERCASE except within quotes. Tail comments are ignored. Embedded "$" characters are allowed. Names/words can start with digits. The maximum line length is 1024 characters.

Example 6-80 PARSE$ function

  a$ = 'company$ = 123abc$ + "and sons" !rnn' 
  print parse$(a$) 
  end
 
 
COMPANY$ = 123ABC$ + "and sons" 


Previous Next Contents Index