| Previous | Contents | Index |
FILEINFO$ parses a file specification and returns either a full file specification or specific file specification fields.
str_expr1 is the file specification to be parsed. If no file specification is given, the device and directory you are currently running from are returned.
str_expr2 is a list of field names, separated by commas, which are to be returned. The field names are:
| CONTENTS | file contents |
| DEVICE | drive name |
| DIRECTORY | directory name |
| NAME | file name |
| TYPE | type or extension name |
| LOCATION | device and directory names |
| BACKUP_DATE | last file backup date |
| CREATION_DATE | date file was created |
| EXPIRATION_DATE | file expiration date |
| REVISION_DATE | date file was last modified |
| REVISION | the number of times a given file has been revised (given that the underlying OS supports this) |
| SIZE | the size of the file in bytes |
| ALL or "" | full file specification |
str_expr3 is the default file specification. This parameter is optional.
FILEINFO$ can be used in various formats.
| Example 6-153 FILEINFO$ function |
|---|
print fileinfo$('x.y', 'ALL')
print fileinfo$('', 'ALL')
end
c:\sheerpower\x.y
c:\sheerpower
|
| Example 6-154 FILEINFO$ function |
|---|
x$ = 'sheerpower:samples\client' print fileinfo$(x$, 'ALL', '.ars') end c:\sheerpower\samples\client.ars |
| Example 6-155 FILEINFO$ function |
|---|
print fileinfo$('sheerpower:\samples\client', 'all', '.ars')
print fileinfo$('sheerpower:\samples\client', 'location')
print fileinfo$('sheerpower:\samples\client', 'location, name')
print fileinfo$('sheerpower:\samples\client.ars')
end
c:\sheerpower\samples\client.ars
c:\sheerpower\samples\
c:\sheerpower\samples\client
c:\sheerpower\samples\client.ars
|
all_of_file$ = fileinfo$('some_file.xxx', 'contents')
|
| Example 6-156 FILEINFO$ function - CONTENTS |
|---|
all_of_file$ = fileinfo$('sheerpower:sheerpower.ini', 'contents')
print all_of_file$
end
! the specified file contents will display in the console window when the program
! is run:
[license]
LicenseKey=F0CE-2E43-7583-3130-3030-3030-3131-0003-873F-000A
Username=non-commercial
EmailAddress=non-commercial
|
| Example 6-157 Copy a file with FILEINFO$ CONTENTS |
|---|
sourcefile$ = 'source.xxx' destfile$ = 'destination.xxx' contents$ = fileinfo$(sourcefile$, 'contents') open file dest_ch: name destfile$, access output, unformatted print #dest_ch: contents$ close #x end |
Given a file name to find, FINDFILE$ returns the complete file specification of the first file found that matches the name given. If no file is found, the function returns a null string.
FINDFILE$ calls can be nested if the inner call has only one argument (i.e., the file specification, but no index number).
| str_expr | The name of the file to search for. This can be just part of the full file specification. | |
| int_expr | Which file specification to return if multiple files are found. This parameter is optional. The default is to return the first file found. | |
| result | The complete file specification of the file found. |
| Example 6-158 FINDFILE$ function |
|---|
print findfile$('sheerpower:\samples\*.spsrc')
c:\sheerpower\samples\cdplayer.spsrc
|
| Example 6-159 FINDFILE$ function |
|---|
do
line input 'File specification': spec$
if _exit then exit do
for i = 1 to 9999
file$ = findfile$(spec$, i)
if file$ = '' then exit for
print file$
next i
loop
end
File specification? sheerpower:samples\client.* <---- type this in
c:\sheerpower\samples\client.ars
c:\sheerpower\samples\client.def
c:\sheerpower\samples\client.fdl
c:\sheerpower\samples\client.str
File specification? exit
|
The following are debugging and exception handling functions that SheerPower performs:
_DEBUG returns a TRUE or FALSE value. TRUE if DEBUG is on. FALSE if DEBUG is off.
| Example 6-160 _DEBUG system function |
|---|
debug on
if _debug then
print 'I am debugging'
end if
debug off
if _debug then
print 'I am still debugging.'
else print 'I am no longer debugging.'
end if
end
I am debugging.
I am no longer debugging.
|
_STATUS returns the value given to SheerPower by the operating system for the last operating system request. It also returns the operating exception number for the last exception that occurred. This function is useful when debugging system level errors. The _STATUS function is often used with the SYSTEXT$ function.
| Example 6-161 _STATUS system function |
|---|
when exception in
open #1: name 'c:\stuff\otherstuff\myfile.txt'
close #1
use
print 'The error was: '; systext$(_status)
end when
end
The error was: The system cannot find the path specified.
|
Upon the completion of an INPUT MENU statement, the concept _STRING contains the menu path taken by the user when selecting the menu item. (i.e., "#2;#3" means the 3rd item of the 2nd submenu.)
| Example 6-162 _STRING system function |
|---|
line1$ = '%width 12, %menubar, %autovbar ON,'
line2$ = 'file = {new, get_file, save, save_as},'
line3$ = 'edit = {cut, copy, paste},'
line4$ = 'paragraph = {font, alignment, spacing, tabs, headers, footers},'
line5$ = 'options = {ruler = {on, off}, side_bar = {on, off},'
line6$ = 'view = {enlarged, normal, small}},exit'
test_menu$ = line1$ + line2$ + line3$ + line4$ + line5$ + line6$
the_default$ = ''
do
input menu test_menu$, default the_default$: ans$
if _exit then exit do
message 'Menu path was', _string
the_default$ = _string
loop
end
+------------------------------------------------------------------------------+
| FILE | EDIT | PARAGRAPH | OPTIONS | EXIT |
+--------------------------------------------+---OPTIONS---+-------------------+
| RULER [>|
| SIDE_BAR +----VIEW-----+
| VIEW | ENLARGED |
+-----------| NORMAL |
| SMALL |
+-------------+
The menu path was: #4;#3;#2
|
EXLABEL$ returns the routine name and line number executing when the last exception occurred, e.g., DO_INPUT.4
| Example 6-163 EXLABEL$ function |
|---|
try_it
stop
routine try_it
when exception in
open #1: name 'xx.yy'
use
print 'Open error at '; exlabel$
print 'Error was: '; extext$(extype)
end when
end routine
Open error at TRY_IT.0002
Error was: File not found
|
| Previous | Next | Contents | Index |