Documente Academic
Documente Profesional
Documente Cultură
FLL
A Library for Visual FoxPro
Reference Guide
Version 8.10
FastWrite s.c.r.l.
Rue Amédé Bracke, 9
1950 Kraainem
Belgium
Tel.: +32-2-720.82.28
Fax: +32-2-720.79.30
Internet: http://www.fastwrite.com
Email: techsupp@fastwrite.com
Table Of Contents
Table Of Contents
ARRAY FUNCTIONS...............................................................................................................................................................37
ARR_average() : Returns the average of all numeric elements contained in an array.................................................................38
ARR_Create() : Creates an array of given dimensions............................................................................................................38
ARR_Dimensions() : Determines the dimensions of an array (rows and cols)............................................................................39
ARR_elements() : Total number of elements in an array........................................................................................................40
ARR_columns() : Number of columns in an array..................................................................................................................40
ARR_IsArray() : Determines if a variable is an array.............................................................................................................41
ARR_max() : Returns the biggest numeric value of all elements contained in an array...............................................................41
ARR_min() : Returns the smallest numeric value of all elements contained in an array...............................................................41
ARR_rows() : Number of rows in an array...........................................................................................................................42
ARR_LastVersion() : Returns the file stamp of ARR_*() functions............................................................................................42
BMP FUNCTIONS..................................................................................................................................................................44
BMP_bits() : Number of bits per pixel..................................................................................................................................45
BMP_colors() : Number of colors in the bitmap file...............................................................................................................45
BMP_header() : Reads a bitmap file header..........................................................................................................................45
BMP_height() : Returns bitmap height.................................................................................................................................46
BMP_isbmp() : Tests whether a file is a bitmap file...............................................................................................................46
BMP_LastVersion() : Returns the file stamp of BMP functions.................................................................................................47
BMP_width() : Returns bitmap width...................................................................................................................................47
CD FUNCTIONS....................................................................................................................................................................49
CD_bayope() : Opens the door and ejects CD media (if possible)...........................................................................................51
CD_bayclo() : Retracts the tray and closes the door bay (if possible)......................................................................................51
CD_caneje() : Can CD audio device eject the media?............................................................................................................51
CD_canpla() : Can CD audio device play the media?.............................................................................................................51
CD_close() : Closes CD device...........................................................................................................................................52
CD_command() : Sends a MCI command string to the CD device open with CD_open().............................................................52
CD_curpos() : Returns the current position..........................................................................................................................52
CD_curtra() : Returns the current track...............................................................................................................................52
CD_end() : Moves to the end of audio data on the disc..........................................................................................................53
CD_home() : Moves to the start of audio data on the disc......................................................................................................53
CD_iscd() : Is a CD-ROM attached to the computer?.............................................................................................................53
CD_LastError() : Determines the last error that occurred within the CD_*() functions................................................................54
CD_LastVersion() : Returns the file stamp of CD_*() functions...............................................................................................54
CD_loff() : Disables output to the left audio channel.............................................................................................................54
CD_lon() : Enables output to the left audio channel..............................................................................................................55
CD_MediaPresent() : Returns .T. if a disc is inserted in the drive.............................................................................................55
CD_mode() : Returns a value indicating the current mode of the device..................................................................................55
CD_msf() : Sets the current time format to MSF (minutes, seconds, frames)............................................................................56
CD_ms() : Sets the current time format to MS (milliseconds).................................................................................................56
CD_off() : Disables audio output (mute)..............................................................................................................................56
CD_on() : Enables audio output (unmute)...........................................................................................................................57
CD_open() : Opens CD device............................................................................................................................................57
CD_pause() : Pauses playing.............................................................................................................................................57
CD_play() : Plays CD tracks...............................................................................................................................................57
CD_ready() : Determines whether the CD is ready................................................................................................................58
CD_resume() : Resumes playback......................................................................................................................................58
CD_roff() : Disables output to the right audio channel...........................................................................................................58
CD_ron() : Enables output to the right audio channel............................................................................................................59
CD_seek() : Moves to the specified position.........................................................................................................................59
CD_start() : Positions the disc at the starting position...........................................................................................................59
CD_stop() : Stops playback...............................................................................................................................................59
CD_time() : Returns the current time format........................................................................................................................60
CD_tmsf() : Sets the current time format to TMSF................................................................................................................60
CD_totlen() : Returns the total length of disc.......................................................................................................................60
CD_tottra() : Returns the number of tracks on the disc..........................................................................................................60
CD_tralen() : Returns the length of a given track..................................................................................................................61
CD_trapos() : Returns the starting position of a given track...................................................................................................61
CLIPBOARD FUNCTIONS.........................................................................................................................................................62
CLP_CountFormats() : Counts the number of different data formats available in the clipboard....................................................63
CLP_empty() : Clears the Windows clipboard.......................................................................................................................63
CLP_GetText() : Gets text from Windows clipboard...............................................................................................................63
CLP_IsFormatAvailable() : Determines whether the clipboard contains data in the specified format.............................................64
CLP_LastVersion() : Returns the file stamp of CLP functions...................................................................................................65
CLP_SetText() : sets text into the Windows clipboard............................................................................................................65
COM FUNCTIONS.................................................................................................................................................................66
COM_BuildCommDCB() : Fills the internal DCB structure of one of the COM handles of FOCUS with the specified values................69
COM_close() : to be continued...........................................................................................................................................69
COM_LastVersion() : Returns the file stamp of COM functions................................................................................................69
COM_open() : to be continued...........................................................................................................................................70
COM_read() : to be continued............................................................................................................................................70
CURSORS FUNCTIONS............................................................................................................................................................72
CUR_LastVersion() : Returns the file stamp of CUR functions.................................................................................................73
CUR_load() : Creates a cursor based on data contained in a file..............................................................................................73
DATE FUNCTIONS.................................................................................................................................................................74
DAT_bom() : Beginning of the month.................................................................................................................................75
DAT_boy() : Beginning of the year.....................................................................................................................................75
DAT_ctot() : Character to datetime string............................................................................................................................75
DAT_DateTime() : Current date and time (char YYYY-MM-DD hh:mm:ss)................................................................................76
DAT_day() : Returns the numeric day-of-the-month for a given date.......................................................................................76
DAT_doy() : Returns the day-of-the-year of a given date.......................................................................................................76
DAT_eom() : End of the month..........................................................................................................................................77
DAT_eoy() : End of the year..............................................................................................................................................77
DAT_Easter() : Determines the exact date of Easter..............................................................................................................77
DAT_IsLeap() : Is this a leap year?.....................................................................................................................................78
DAT_jtod() : Julian date to date.........................................................................................................................................78
DAT_LastVersion() : Returns the file stamp of DAT functions..................................................................................................78
DAT_month() : Returns the number of the month for a given date..........................................................................................79
DAT_num() : Converts a date into a number (Julian date).....................................................................................................79
DAT_NumberOfDays() : Returns the number of days in a month.............................................................................................80
DAT_stod() : Transforms a YYYYMMDD date string into a FoxPro date (opposite to DTOS()).......................................................80
DAT_year() : Returns the year from the specified date..........................................................................................................80
DAT_ymd() : Splits a date into its basic components.............................................................................................................81
DBF FUNCTIONS..................................................................................................................................................................82
DBF_append() : Appends a new record or a series of records.................................................................................................83
DBF_bot() : Is the table at begin of file?..............................................................................................................................83
DBF_commit() : Flushes current record to disk.....................................................................................................................83
DBF_empty() : Is it an empty table?...................................................................................................................................83
DBF_eot() : Is the table at end of file?................................................................................................................................84
DBF_exclu() : Table open exclusively?................................................................................................................................84
DBF_GoBottom() : Go to the bottom of a given work area.....................................................................................................84
DBF_GoTop() : Go to the top of a given work area...............................................................................................................85
DBF_flockd() : Table locked or open exclusively?..................................................................................................................85
DBF_LastVersion() : Returns the file stamp of DBF functions..................................................................................................85
DBF_lock() : Locks a file or a record...................................................................................................................................86
DBF_readon() : Table open without write access?.................................................................................................................86
DBF_reccnt() : Number of records......................................................................................................................................86
DBF_replac() : Replaces a field with a value.........................................................................................................................87
DBF_rlockd() : Current record locked, table locked or table open exclusively?..........................................................................87
DBF_seek() : Performs a SEEK...........................................................................................................................................87
DBF_Skip() : Skips a specified number of records in a given work area...................................................................................88
DBF_status() : Retrieves the status of a DBF........................................................................................................................88
EVENT FUNCTIONS..............................................................................................................................................................122
EVE_CustomizeEventCommand() : Customizes the command associated to a given event........................................................124
EVE_End() : Ends event processing...................................................................................................................................124
EVE_GetIdleSince() : Gets the last time when an event did occur that postponed the inactivity in a program..............................125
EVE_LastError() : Last error encountered in EVE functions...................................................................................................126
EVE_LastVersion() : Returns the file stamp of EVE functions.................................................................................................126
EVE_OnIdleCommand() : Gets/Sets the idle command........................................................................................................126
EVE_OnIdleInterval() : Gets/Sets the idle interval...............................................................................................................127
EVE_ResetIdleSince() : Resets the last event.....................................................................................................................128
EVE_SetUserDefinedAtNullCommand() : Sets a command to be launched at firts null event......................................................129
EVE_Start() : Starts event processing...............................................................................................................................130
FILE FUNCTIONS................................................................................................................................................................134
FIL_AreFileAPIsANSI() : Determines whether a set of Win32 file functions is using the ANSI or OEM character set code page.......137
FIL_BrowseForComputer() : Displays a dialog box that enables the user to select a computer...................................................137
FIL_BrowseForFolder() : Displays a dialog box that enables the user to select a shell folder.....................................................137
FIL_BrowseForPrinter() : Displays a dialog box that enables the user to select a printer...........................................................138
FIL_Canonicalize() : Canonicalizes a path..........................................................................................................................138
FIL_chdir() : Change Directory service..............................................................................................................................139
FIL_ClearArchived() : Clears the Archive attribute of a file....................................................................................................139
FIL_ClearCompressed() : Clears the Compressed attribute of a file........................................................................................139
FIL_ClearHidden() : Clears the Hidden attribute of a file......................................................................................................140
FIL_ClearNormal() : Clears the Normal attribute of a file......................................................................................................140
FIL_ClearReadOnly() : Clears the Read-Only attribute of a file..............................................................................................140
FIL_ClearSystem() : Clears the System attribute of a file.....................................................................................................140
FIL_ClearTmp() : Clears the Temporary attribute of a file.....................................................................................................141
FIL_close() : Closes a file................................................................................................................................................141
FIL_commit() : Flushes a file’s data buffer to disk...............................................................................................................141
FIL_Common() : Compares two paths to determine if they share a common prefix..................................................................142
FIL_comp() : Reports if two files are the same...................................................................................................................143
FIL_CompareTime() : Compares time and date stamps of two files.......................................................................................143
FIL_copy() : Copies a file................................................................................................................................................144
FIL_copyTimes() : Determines how many times the callback function of FIL_copy() will be called.............................................147
FIL_count() : Returns the number of files and directories that match a particular specification..................................................148
FIL_create() : Creates a file.............................................................................................................................................148
FIL_CreateHardLink() : Establishes an NTFS hard link between an existing file and a new file. An NTFS hard link is similar to a POSIX
hard link........................................................................................................................................................................150
FIL_crypt() : Encrypts a file.............................................................................................................................................151
FIL_decrypt() : Decrypts a file encrypted with FIL_crypt()....................................................................................................151
FIL_del() : Deletes file or directory...................................................................................................................................152
FIL_DeleteAll() : Deletes all file........................................................................................................................................152
FIL_drive() : Returns the drive letter from a complete path..................................................................................................153
FIL_exenam() : Returns the executable file name...............................................................................................................153
FIL_expand() : Expands a file...........................................................................................................................................154
FIL_Explore() : Explores a specified folder.........................................................................................................................154
FIL_ext() : Returns the three letter extension from a complete path......................................................................................155
FIL_first() : Gets first instance of a filename that matches a given file specification.................................................................155
FIL_FlushAll() : Flushes all streams; clears all buffers..........................................................................................................156
FIL_FndExe() : Find executable associated with a given filename..........................................................................................156
FIL_FullName() : Returns the full path to a specified file......................................................................................................156
FIL_gdate() : Gets file date stamp....................................................................................................................................157
FIL_get() : Open File Dialog Box.......................................................................................................................................157
GRAPHICAL/GDI FUNCTIONS...............................................................................................................................................211
GDI_CreateEllipticRegion() : Creates an elliptical region.......................................................................................................213
GDI_CreatePolygonalRegion() : Creates a region based on a polygon....................................................................................214
GDI_DeleteRegion() : Frees a region and all its associated internal GDI objects......................................................................217
GDI_CombineRegions() : Creates a rectangular region........................................................................................................218
GDI_CreateRectangleRegion() : Creates a rectangular region...............................................................................................220
GDI_Ellipse() : Draws an ellipse.......................................................................................................................................222
GDI_LastVersion() : Returns the file stamp of GDI functions. GRA_LastVersion() : Returns the file stamp of GRA functions...........223
GDI_Rectangle() : Draws a rectangle................................................................................................................................223
GDI_RoundRectangle() : Draws a round rectangle...............................................................................................................225
GDI_ScreenToClient() : Converts the screen coordinates of a specified point on the screen to client-area coordinates..................226
GDI_ClientToScreen () : Converts the client-area coordinates of a specified point to screen coordinates.....................................227
GDI_Arc() : Draws an elliptical arc....................................................................................................................................227
GDI_ArcTo() : Draws an elliptical arc................................................................................................................................228
GDI_CreateSolidBrush() : Creates a brush that has the specified hatch pattern and color.........................................................228
GDI_chord() : Draws a chord...........................................................................................................................................229
GDI_circle() : Draws a circle............................................................................................................................................230
GRA_line() : Draws a line................................................................................................................................................230
GDI_SetPixel() : Draws a pixel.........................................................................................................................................231
GRA_carve() : Draws a box with carving effect...................................................................................................................231
HTML/HTTP FUNCTIONS....................................................................................................................................................232
HTML_Decode() : decodes an HTML encoded string.............................................................................................................234
HTML_Encode() : applies HTML encoding to the specified text string.....................................................................................234
HTML_LastVersion() : Returns the file stamp of HTML functions............................................................................................235
HTTP_AttemptConnect() : Attempts to make a connection to the Internet..............................................................................235
HTTP_CanonicalizeURL() : Canonicalizes a URL, which includes converting unsafe characters and spaces into escape sequences.. .236
HTTP_CrackURL() : Cracks a URL into a domain and path....................................................................................................237
HTTP_CombineURL() : Combines a base and a relative URL into a single URL.........................................................................237
HTTP_DecodeQueryString() : Decodes the QUERY_STRING of a URL request..........................................................................238
HTTP_GetCodeText() : Returns a descriptive text corresponding to a given HTTP responde code...............................................238
HTTP_GetDefaultBrowser() : Returns the default browser application that will be invoked for *.htm files....................................239
HTTP_GetURL() : Retrieves URL as a string........................................................................................................................240
HTTP_GetURL2() : Retrieves URL as a string......................................................................................................................241
HTTP_InternetDial() : Initiates a connection to the Internet using a modem...........................................................................250
HTTP_IsURL() : Returns status information about a URL......................................................................................................251
HTTP_LastError() : Last error encountered in HTTP functions................................................................................................254
HTTP_LastGetURLTime() : Returns the time the last HTTP_GetURL() operation in milliseconds..................................................254
HTTP_LastVersion() : Returns the file stamp of HTTP functions.............................................................................................255
HTTP_PostURL() : Gets URL and posts information..............................................................................................................255
HTTP_SetCallback() : Gets/Sets a callback function for the HTTP_GetURL*() functions.............................................................256
HTTP_SetURLTimeout() : Gets/Sets the timeout value used in HTTP functions........................................................................256
HTTP_URLDecode() : Decodes a URL.................................................................................................................................257
HTTP_URLEncode() : Encodes a URL.................................................................................................................................257
IP FUNCTIONS...................................................................................................................................................................264
IP_GetAddress() : Returns the IP address of the PC.............................................................................................................265
IP_GetIP() : Returns the IP address corresponding to a giuven domain name.........................................................................265
IP_LastError() : Determines the last error that occurred within the IP_*() functions.................................................................265
IP_LastVersion() : Returns the file stamp of IP functions......................................................................................................266
IP_ping() : Pings to an IP address.....................................................................................................................................266
KERNEL FUNCTIONS............................................................................................................................................................279
KNL_major() : Returns the major version number of KERNEL.DLL.........................................................................................281
KNL_minor() : Returns the minor version number of KERNEL.DLL.........................................................................................281
KNL_vers() : Returns the version number of KERNEL.DLL....................................................................................................281
LOCALE SETTINGS...............................................................................................................................................................287
LOC_EnumSystemLocales() : Enumerates the locales that are installed on a system................................................................288
LOC_GetLocaleSetting() : Returns a locale setting...............................................................................................................288
LOC_GetSystemLocales() : Gets the locales that were enumerated via the LOC_EnumSystemLocales() function..........................290
LOC_GetUserDefaultLanguage() : Retrieves the user default language identifier......................................................................290
LOC_GetUserPrimaryLanguage() : Extracts a primary language identifier from a language identifier...........................................291
LOC_GetUserSubLanguage() : Extracts a sublanguage identifier from a language identifier.......................................................292
LOC_LastVersion() : Returns the file stamp of LOC functions................................................................................................294
LOG FUNCTIONS.................................................................................................................................................................295
LOG_Append() : Appends a line of text to a log file.............................................................................................................297
LOG_Close() : Closes a log file.........................................................................................................................................297
LOG_FindFirstLog() : Finds the first available log handle......................................................................................................298
LOG_LastError() : Determines the last error that occurred within the LOG_*() functions...........................................................298
LOG_LastVersion() : Returns the file stamp of LOG functions................................................................................................299
LOG_Set() : Sets a log file...............................................................................................................................................299
LOG_Successful() : Returns the string that is used to declare that the last operation has been successfully executed...................300
LZH FUNCTIONS.................................................................................................................................................................301
LZH_encode() : Compresses a file using the LZH algorithm..................................................................................................302
LZH_decode() : Uncompresses a file using the LZH algorithm...............................................................................................302
MAPI FUNCTIONS..............................................................................................................................................................303
MCI FUNCTIONS................................................................................................................................................................317
MCI_device() : Retrieves the device identifier corresponding to the name of an open device.....................................................318
MCI_error() : Gets last MCI command error string..............................................................................................................318
MCI_IsRiff() : Is a given file in the RIFF format?.................................................................................................................318
MCI_IsWave() : Is a given file in the WAVE format?............................................................................................................319
MCI_LastVersion() : Returns the file stamp of MCI functions.................................................................................................319
MCI_send() : Sends a command to MCI devices.................................................................................................................319
METRIC FUNCTIONS............................................................................................................................................................320
MET_CmToInch() : Cm to inches......................................................................................................................................321
MET_FeetToInch() : Feet to inches....................................................................................................................................321
MET_FeetToMeters() : Feet to meters................................................................................................................................321
MET_FeetToMile() : Feet to miles......................................................................................................................................322
MET_FeetToYard() : Feet to yards.....................................................................................................................................322
MET_InchToCm() : Inches to cm......................................................................................................................................322
MET_InchToFeet() : Inches to feet....................................................................................................................................323
MET_InchToMile() : Inches to miles..................................................................................................................................323
MET_InchToYard() : Inches to yards.................................................................................................................................323
MET_KmToMile() : Km to mile..........................................................................................................................................324
MET_LastVersion() : Returns the file stamp of MET functions................................................................................................324
MET_MetersToFeet() : Meters to feet.................................................................................................................................324
MET_MileToKm() : Miles to km.........................................................................................................................................325
MET_MileToFeet() : Miles to feet.......................................................................................................................................325
MET_MileToInch() : Miles to inches...................................................................................................................................325
MET_MileToYard() : Miles to yards....................................................................................................................................326
MET_MToYard() : Meters to yards.....................................................................................................................................326
MET_YardToFeet() : Yards to feet.....................................................................................................................................326
MET_YardToInch() : Yards to inches..................................................................................................................................327
MET_YardToM() : Yards to meters.....................................................................................................................................327
MET_YardToMile() : Yards to mile.....................................................................................................................................327
MISCELLANEOUS FUNCTIONS.................................................................................................................................................329
MIS_Aliases() : Returns all the aliases that are known for a specified FOCUS.FLL function........................................................330
MIS_AllFunctions() : Returns all the function and aliases that are known in FOCUS.FLL............................................................330
MIS_Argc() : Number of arguments that a specified function of FOCUS.FLL expects................................................................331
MIS_Argv() : Argument types that a specified function of FOCUS.FLL expects.........................................................................331
MIS_BodyMassIndex() : Calculates the body mass index.....................................................................................................332
MIS_credits() : Returns the credits of FOCUS.FLL...............................................................................................................332
MIS_DocVers() : Returns the version of the FOCUS documentation.......................................................................................333
MIS_Error() : Generates a Visual FoxPro error....................................................................................................................333
MIS_ErrorInfo() : Visual FoxPro error message associated with the error...............................................................................334
MIS_ExecFuncPtr() : Executes the code that is pointed to by the internal execution pointer......................................................334
MIS_false() : Always returns a logical .F............................................................................................................................335
MIS_FuncPtr() : Returns a function pointer to a specified function contained in FOCUS.FLL.......................................................335
MIS_GetCommonSlot() : Gets/Sets the contents of a shared memory slot.............................................................................336
MIS_GetFocusUsage() : Gets the usage count of FOCUS.FLL................................................................................................337
MIS_IsFunction() : Returns .T. if a specified function exists in FOCUS.FLL..............................................................................337
MIS_knlmajor() : Returns the major version number of KERNEL.DLL.....................................................................................338
MIS_knlminor() : Returns the minor version number of KERNEL.DLL.....................................................................................338
MIS_knlvers() : Returns the version number of KERNEL.DLL................................................................................................338
MIS_LastVersion() : Returns the file stamp of MIS functions.................................................................................................339
MIS_major() : Returns the major version number of FOCUS.FLL...........................................................................................339
MIS_minor() : Returns the minor version number of FOCUS.FLL...........................................................................................340
MIS_nothin() : Does not do anything !..............................................................................................................................340
MIS_OnlineDocVers() : Returns the version of the FOCUS online documentation.....................................................................341
MIS_OutputDebugString() : Sends a string to the debugger for the current application............................................................341
MIS_NumberOfFunctions() : Number of functions included in FOCUS.FLL...............................................................................342
MIS_SetExecPtr() : Assigns the internal execution pointer to a given value.............................................................................342
MIS_true() : Always returns a logical .T.............................................................................................................................343
MIS_vers() : returns the version number of FOCUS.FLL.......................................................................................................343
MENU FUNCTIONS...............................................................................................................................................................345
MNU_AddItem() : Adds an item to a menu created with MNU_Make()....................................................................................346
MNU_AddMenu() : Attach a submenu to a menu.................................................................................................................348
MNU_create() : Creates a context menu at the position of the mouse....................................................................................350
MNU_Destroy() : Destroys an internal menu structure created with MNU_Make()....................................................................351
MNU_Make() : Creates an internal menu structure suitable for context menus........................................................................353
MNU_Play() : Plays a menu created by MNU_Make()...........................................................................................................355
MQSERIES FUNCTIONS........................................................................................................................................................368
MQ_close() : Closes the current queue..............................................................................................................................371
MQ_connect() : Connects to the Queue Manager.................................................................................................................371
MQ_disconnect() : Disconnects from the Queue Manager.....................................................................................................371
MQ_open() : Opens a Queue............................................................................................................................................372
MESSAGING FUNCTIONS.......................................................................................................................................................373
MSG_Broadcast() : Sends a message to all recipients of the Post Office.................................................................................377
MSG_BytesSent() : Total number of bytes sent with the current Post Office............................................................................377
MSG_count() : Counts the number of unread messages for a given recipient..........................................................................377
MSG_CreateAccount() : Creates an account in the current Post Office....................................................................................378
MSG_CreatePostOffice() : Creates a Post Office..................................................................................................................378
MSG_DeleteAccount() : Deletes an account in the current Post Office....................................................................................379
MSG_DeleteUnread() : Deletes all pending messages of an account.......................................................................................379
MSG_GetAllAccounts() : Gets all accounts that are defined in the current Post Office...............................................................379
MSG_GetDir() : Returns the mailbox directory of a given recipient (absolute path)..................................................................380
MSG_GetSep() : Returns the separator that is used internally by FOCUS.FLL to tokenize a message..........................................381
MSG_GetSubDir() : Returns the mailbox directory of a given recipient (relative path)..............................................................381
MSG_IsAccount() : Determines if the specified account is known bt the current Post Office.......................................................382
MSG_IsPostOfficeAccessible() : Determines whether the Post Office can be contacted or not....................................................382
MSG_LastError() : Returns a string indicating the last error in Messaging functions..................................................................383
MSG_LastVersion() : Returns the file stamp of MSG functions...............................................................................................383
MSG_MessagesRead() : Returns the number of messages the specified recipient has already read.............................................384
MSG_MessagesReceived() : Returns the number of messages the specified recipient has received in total..................................384
MSG_MessagesSent() : Returns the number of messages a specified originator has sent..........................................................384
MSG_PO() : Gets the Post Office location...........................................................................................................................385
MSG_POFile() : Gets the Post Office settings file.................................................................................................................385
MSG_PostOffice() : Gets/Sets the Post office location and settings file...................................................................................385
MSG_Read() : Reads the least recent message of a given recipient.......................................................................................386
MSG_Send() : Sends a message.......................................................................................................................................386
MSG_SetPONotification() : Sets a directory notification on a specified directory......................................................................387
MSG_Successful() : Returns the string that is used to declare that the last operation has been successfully executed...................387
MSG_TotalMessagesSent() : Returns the total number of messages sent through the current Post Office....................................388
MATHEMATICAL FUNCTIONS..................................................................................................................................................389
MTH_atan() : Returns a Double specifying the arctangent of a number..................................................................................390
MTH_combinations() : Computes the number of unordered combinations of n on x.................................................................390
MTH_distance() : computes the distance between 2 points...................................................................................................392
MTH_LastVersion() : Returns the file stamp of MTH functions...............................................................................................392
MTH_origin() : détermine l'origine à l'ordonnée d'une droite passant par deux points..............................................................393
MTH_pente() : détermine la pente d'une droite passant par deux points................................................................................393
MTH_permutations() : Computes the number of ordered permutations of n on x.....................................................................394
NETWORK FUNCTIONS.........................................................................................................................................................395
NET_CancelConnection() : Breaks an existing network connection.........................................................................................396
NET_ConnectionDialog() : Presents a dialog box to establish a new network connection...........................................................396
NET_DisconnectDialog() : Presents a dialog box to cancel a network connection.....................................................................397
NET_EnumConnections() : Enumerates the network connections...........................................................................................398
NET_EthernetAddress() : Obtains the Ethernet address of the network card...........................................................................398
NET_GetComputerName() : Retrieves the computer name of the current system....................................................................399
NET_GetHostName() : Returns the standard host name for the local machine.........................................................................399
NET_GetUserName() : Returns the user name attached to the local machine..........................................................................399
NET_InternetTime() : Returns the Atomic clock date/time with 1sec accuracy.........................................................................400
NET_LastError() : Last error encountered in NET functions...................................................................................................400
NET_LastVersion() : Returns the file stamp of NET functions................................................................................................401
NET_level() : Sets up the user level..................................................................................................................................401
NET_max() : Maximum number of software users that can log in simultaneously....................................................................401
NET_mode() :?????????..................................................................................................................................................402
NET_proc() : Customizes the command to be executed by dedicated network timer................................................................402
NET_SetComputerName() : Sets the computer name to be used the next time the system is restarted......................................402
NET_setnet() : Must the network be setting up...................................................................................................................403
NOTIFICATION FUNCTIONS...................................................................................................................................................405
NOT_Frequency() : Adjusts the frequency of the internal timer of FOCUS.FLL.........................................................................407
NOT_HandlesCount() : Returns the maximum number of notification handles.........................................................................407
NOT_HandlesFree() : Returns the number of free notification handles....................................................................................407
NOT_info() : Returns notification information.....................................................................................................................408
NOT_IsTimer() : Is the internal timer of FOCUS.FLL active?.................................................................................................409
NOT_Kill() : Kills a notification.........................................................................................................................................409
NOT_KillTimer() : Kills the internal timer of FOCUS.FLL.......................................................................................................410
NOT_LastError() : Returns an error string indicating the nature of the last error encountered....................................................410
NOT_LastVersion() : Returns the file stamp of NOT functions...............................................................................................411
NOT_MaxHandle() : Returns the highest possible notification handle.....................................................................................411
NOT_MinHandle() : Returns the lowest possible notification handle.......................................................................................411
NOT_RestoreAll() : Restores all notifications saved with NOT_SaveAll().................................................................................412
NOT_Resume() : Resumes a notification............................................................................................................................412
NOT_ResumeAll() : Resumes all notifications.....................................................................................................................413
NOT_SaveAll() : Saves all notifications in a character string.................................................................................................413
NOT_Set() : Sets a notification.........................................................................................................................................414
NOT_Strategy() : Establishes the strategy used to respond to directory notification.................................................................415
NOT_Successful() : Returns the string that is used to declare that the last operation has been successfully executed...................415
NOT_Suspend() : Suspends a notification..........................................................................................................................415
NOT_SuspendAll() : Suspends all notifications....................................................................................................................416
NOT_ZapAll() : Discards all notifications............................................................................................................................417
NTEVENTS FUNCTIONS........................................................................................................................................................418
NTE_ClearEventLog() : Clears a given event log.................................................................................................................421
NTE_CloseEventLog() : Closes a read handle to the specified event log..................................................................................421
NTE_OpenEventLog() : Opens an event log........................................................................................................................422
NUMERIC FUNCTIONS..........................................................................................................................................................423
NUM_Base() : Converts the digits of a given integer argument to a string, by taking into account a given radix...........................424
NUM_between() : Determines if a number is between 2 others.............................................................................................424
NUM_BinHi() : Returns the high byte value of a number......................................................................................................424
NUM_BinLow() : Returns the low byte value of a number.....................................................................................................425
NUM_gcd() : Euclid's implementation of the greatest common divisor of two integers..............................................................425
NUM_GetNextPrime() : Get the next prime number.............................................................................................................426
NUM_GetPrevPrime() : Get the previous prime number........................................................................................................426
NUM_hexa() : Hexadecimal equivalent of an integer............................................................................................................427
NUM_htoi() : Integer equivalent of an hexadecimal number.................................................................................................427
NUM_InitRandom() : Initializes internal buffers and values for random numbers generation.....................................................427
NUM_int_max() : Get the highest value of an integer..........................................................................................................428
NUM_int_min() : Get the lowest value of an integer............................................................................................................428
NUM_IsPrime() : Is a number a prime number?..................................................................................................................429
NUM_LastVersion() : Returns the file stamp of NUM functions...............................................................................................429
NUM_long_max() : Get the highest value of a long.............................................................................................................429
NUM_long_min() : Get the lowest value of a long...............................................................................................................430
NUM_octal() : Octal equivalent to an integer number..........................................................................................................430
NUM_Radix() : Reverse function of NUM_Base().................................................................................................................431
NUM_RandomDouble() : Generates a random float in the range 0 to 1...................................................................................431
NUM_RandomInt() : Generates a random integer................................................................................................................432
NUM_UniversalID() : Generates a unique identifier that is supposed to be unique in space and unique in time.............................432
PRINTER FUNCTIONS...........................................................................................................................................................436
PRN_color() : Color printer to render color or monochrome output........................................................................................439
PRN_copies() : Number of copies printed if the device supports multiple-page copies..............................................................439
PRN_device() : Device name............................................................................................................................................439
PRN_dialog() : Displays a dialog box to setup application printer..........................................................................................440
PRN_driver() : Printer driver version number......................................................................................................................440
PRN_drv() : Printer driver name.......................................................................................................................................440
PRN_duplex() : Double-sided printing................................................................................................................................441
PRN_EnumPrinters() : Enumerates available printers...........................................................................................................441
PRN_extra() : Size of the optional dmDriverData member for device-specific data...................................................................442
PRN_fields() : Set of flags that indicate which members of the DEVMODE structure have been initialized....................................442
PRN_GetDefaultPrinter() : Gets the default printer...............................................................................................................443
PRN_GetDrvInfo() : Retrieves driver data for the specified printer.........................................................................................443
PRN_GetJobs() : List all printing jobs for a given printer......................................................................................................445
PRN_GetPrnData() : Retrieves information about a specified printer......................................................................................446
PRN_LastVersion() : Returns the file stamp of PRN functions................................................................................................451
PRN_name() : Device name/printer name..........................................................................................................................451
PRN_orient() : Paper orientation.......................................................................................................................................452
PRN_paperL() : Paper length, in tenths of a millimeter.........................................................................................................452
PRN_paperS() : Paper size...............................................................................................................................................452
PRN_paperW() : Paper width, in tenths of a millimeter........................................................................................................453
REGISTRY FUNCTIONS.........................................................................................................................................................462
REG_CreateKey() : Creates a key in the Windows registry....................................................................................................463
REG_CreateValue() : Creates a value in the Windows registry...............................................................................................463
REG_DeleteKey() : Deletes a key in the Windows registry....................................................................................................464
REG_DeleteValue() : Deletes a value in the Windows registry...............................................................................................464
REG_EnumKeyEx() : Enumerates all subkeys of a given key of the Windows registry...............................................................465
REG_LastVersion() : Returns the file stamp of REG functions................................................................................................465
REG_QueryValue() : Gets data from the Registry................................................................................................................466
SCREEN FUNCTIONS............................................................................................................................................................473
SCR_BitmapHeight() : Height of bitmaps contained in title bar.............................................................................................474
SCR_BitmapWidth() : Width of bitmaps contained in title bar...............................................................................................474
SCR_ColorDepth() : Determines screen color depth.............................................................................................................474
SCR_cols() : Displays width in pixels.................................................................................................................................475
SCR_EnumDisplaySettings() : Retrieves information about one of the graphics modes for a display device.................................475
SCR_GetDMMember() : Retrieves a member of the internal DEVMODE structure that is populated after a call to
SCR_EnumDisplaySettings()............................................................................................................................................476
SCR_GetFullScreenDimensions() : Determines the usable dimensions of the Windows desktop.................................................477
SCR_GetScreenDimensions() : Determines the usable dimensions of the Windows desktop......................................................477
SCR_LastVersion() : Returns the file stamp of SCR functions................................................................................................478
SCR_MinimumDragHeight() : Minimum tracking height of a window......................................................................................478
SCR_MinimumDragWidth() : Minimum tracking width of a window........................................................................................478
SCR_RefreshDisplay() : Refreshes the entire display...........................................................................................................479
SCR_ResetDisplaySettings() : Returns to the default mode display........................................................................................479
SCR_roloc() : Reverses color attribute...............................................................................................................................480
SHELL FUNCTIONS..............................................................................................................................................................481
SHE_AddIcon() : Adds an icon in the System Tray of Windows.............................................................................................483
SHE_CopyFile() : Copies multiple source files from one location to another............................................................................484
SHE_DeleteAllTrayIcons() : Removes all icons set with SHE_AddIcon().................................................................................485
SHE_DeleteIcon() : Removes an icon from the System Tray of Windows................................................................................486
SHE_GetDllVersion() : Obtains version information from the shell32.dll.................................................................................487
SHE_GetIconCount() : Get the number of icons found in an executable, or .DLL.....................................................................487
SHE_IconsFree() : Determines how many icons can still be placed in the System Tray of Windows............................................488
SHE_IsActiveDesktopInstalled() : Checks for the Active Desktop...........................................................................................488
SHE_LastError() : Returns the last error that occurred in the SHE_*() functions......................................................................489
SHE_LastVersion() : Returns the file stamp of SHE functions................................................................................................489
SHE_QueryRecycleBin() : Determines the number of deleted items in the recycle bin of a specific drive.....................................489
SHE_PathAddBackslash() : Adds a backslash to the end of a path.........................................................................................490
SHE_PathCompact() : Truncates a path to fit within a certain number of characters by replacing path components with ellipses....490
SHE_PathIsRelative() : Searches a path and determines if it is relative..................................................................................491
SHE_PathIsRoot() : Parses a path to determine if it is a directory root...................................................................................491
SHE_PathIsUNC() : Determines if the string is a valid UNC (universal naming convention) for a server and share path.................492
SHE_PathIsUNCServer() : Determines if a string is a valid UNC for a server path only..............................................................492
SHE_PathIsUNCServerShare() : Determines if a string is a valid UNC share path, \\server\share...............................................492
SHE_PathIsURL() : Tests a given string to determine if it conforms to a valid URL format.........................................................493
SHE_PathRemoveBackslash() : Removes the trailing backslash from a given path...................................................................493
SIZEOF FUNCTIONS.............................................................................................................................................................494
SIZ_bool() : Size of a bool..............................................................................................................................................495
SIZ_char() : Size of a char..............................................................................................................................................495
SIZ_double() : Size of a double........................................................................................................................................495
SIZ_dword() : Size of a DWORD.......................................................................................................................................495
SIZ_enum() : Size of an enum.........................................................................................................................................496
SIZ_float() : Size of a float..............................................................................................................................................496
SIZ_int() : Size of an integer...........................................................................................................................................496
SIZ_int8() : Size of a 8-bit integer....................................................................................................................................496
SIZ_int16() : Size of a 16-bit integer................................................................................................................................497
SIZ_int32() : Size of a 32-bit integer................................................................................................................................497
SIZ_int64() : Size of a 64-bit integer................................................................................................................................497
SIZ_handle() : Size of a handle........................................................................................................................................497
SIZ_hwnd() : Size of a window handle (HWND).................................................................................................................498
SIZ_LastVersion() : Returns the file stamp of the SIZ functions............................................................................................498
SIZ_long() : Size of a long..............................................................................................................................................498
SOUND FUNCTIONS.............................................................................................................................................................501
SND_AppEvent() : Plays a waveform identified by an entry in the registry..............................................................................502
SND_asterisk() : Plays a waveform identified by an entry in the registry (iconasterisk)............................................................502
SND_error() : Plays a waveform identified by an entry in the registry (iconhand)....................................................................503
SND_exclamation() : Plays a waveform identified by an entry in the registry (iconexclamation)................................................503
SND_LastVersion() : Returns the file stamp of SND functions...............................................................................................503
SND_OK() : Plays a waveform identified by an entry in the registry (iconok)..........................................................................504
SND_play() : Plays a waveform sound specified by a filename..............................................................................................504
SND_repeat() : Repeats the last waveform that was played.................................................................................................504
SND_Standard() : Standard beep using the computer speaker..............................................................................................505
SND_Stop() : Stops playing any wave file..........................................................................................................................505
SND_vers() : Returns the FOCUS Sound version.................................................................................................................505
STRING FUNCTIONS............................................................................................................................................................523
STR_addcod() : Adds an ASCII code to each character of a string.........................................................................................524
STR_AllChars() : Returns all the characters found in a string in a sorted manner.....................................................................524
STR_ascii() : Forms a number based on each character value...............................................................................................524
STR_ascii2() : Forms a number based on each character value multiplied by its position..........................................................525
STR_Ascii2Ebcdic() : Converts a string to its EBCDIC equivalent...........................................................................................525
STR_AtLine() : Determines the number of the line a given position belongs to........................................................................526
STR_balanc() : Finds position where a given character is balanced with another.....................................................................527
STR_char() : Extracts the rest of a string...........................................................................................................................528
STR_chrcnt() : Counts occurrences of a character in a string................................................................................................528
STR_chrswa() : Swaps one character with another within a string.........................................................................................529
STR_comma() : Formats a string that only contains digits....................................................................................................529
STR_CompareStrings() : Compares two character strings, using the current User Locale as the basis for the comparison.............529
STR_Compare() : Compares two character strings, and reports where they differ....................................................................530
STR_ConvertA2B() : Converts a character string based on an internal conversion table............................................................531
STR_ConvertB2A() : Reverses the conversion set by the STR_ConvertA2B() function..............................................................531
STR_cpbrk() : Finds the 1st occurrence in a string of any character from another string. String result........................................532
STR_Decode64() : Decodes a base 64 encoded string.........................................................................................................533
STR_dionly() : Keeps digits only.......................................................................................................................................533
STR_Ebcdic2Ascii() : Converts a string to its ASCII equivalent..............................................................................................533
STR_Encode64() : Encodes a string in base 64...................................................................................................................534
SYSTEM FUNCTIONS............................................................................................................................................................579
SYS_ACLineStatus() : AC power status..............................................................................................................................580
SYS_AllocConsole() : Allocates a new console to the current program (EXE)...........................................................................580
SYS_avaclu() : Gets the number of available clusters on disk...............................................................................................580
SYS_BatteryFlag() : Battery charge status.........................................................................................................................581
SYS_BatteryFullLifeTime() : Number of seconds of battery life when at full charge..................................................................581
SYS_BatteryLifePercent() : Percentage of full battery charge remaining.................................................................................582
SYS_BatteryLifeTime() : Number of seconds of battery life remaining....................................................................................582
SYS_Broadcast() : Broadcasts a WIN.INI change to all applications.......................................................................................582
SYS_bytsec() : Gets the number of bytes per sector on given disk........................................................................................583
SYS_ConfigurePort() : Displays the port-configuration dialog box for a port...........................................................................583
SYS_GetConsoleHWND() : Returns the Windows handle of the current console.......................................................................585
SYS_GetConsoleTitle() : Gets the title of the current console................................................................................................586
SYS_CreateMutex() : Creates a named mutex object...........................................................................................................586
SYS_curdri() : Obtains the current drive............................................................................................................................587
SYS_DeleteMutex() : Releases mutex object......................................................................................................................587
SYS_displa() : Returns the display driver which is used by Windows......................................................................................587
SYS_DoesDriveExist() : Finds out if given drive exists in the system.....................................................................................588
SYS_DoesSupportCompression() : Does the file system support file-based compression..........................................................588
SYS_dosmaj() : Returns DOS major version number...........................................................................................................588
SYS_dosmin() : Returns DOS minor version number...........................................................................................................589
SYS_dristr() : Returns a string with all drives.....................................................................................................................589
SYS_DriveType() : Returns the drive type..........................................................................................................................589
SYS_dsksiz() : Returns the total capacity in bytes of a specified disk drive.............................................................................590
SYS_dskspa() : Returns the number of available bytes on a given disk drive..........................................................................591
SYS_EnumDeviceDrivers() : List of active device drivers in the system..................................................................................592
SYS_errhan() : Custom Windows error handling.................................................................................................................593
SYS_exenam() : Returns the executable file name..............................................................................................................593
SYS_ExitProcess() : Ends a process and all of its threads.....................................................................................................594
SYS_ExitWindows() : Either logs off, shuts down, or shuts down and restarts the system........................................................594
SYS_FatalExit() : Displays a message box and terminates the application..............................................................................595
SYS_FileSystemName() : File system installed on a given drive............................................................................................595
SYS_FormatDrive() : Presents the standard dialog box of Windows to format a drive...............................................................596
SYS_FreeConsole() : Frees the current console (if any).......................................................................................................596
SYS_FreeLibrary() : Unloads a 32-bit DLL previously loaded with SYS_LoadLibrary()...............................................................597
SYS_GetBinaryType() : Determines the type of an executable..............................................................................................597
SYS_GetCaretBlinkTime() : Returns the elapsed time, in milliseconds, required to invert the caret's pixels.................................598
SYS_GetCaretPosX() : Caret's position, in client coordinates................................................................................................598
SYS_GetCaretPosY() : Caret's position, in client coordinates.................................................................................................599
SYS_GetCommandLine() : Command-line string for the current process................................................................................599
SYS_GetCurrentDirectory() : Returns current directory........................................................................................................599
SYS_GetDllVersion() : Obtains version information from any DLL..........................................................................................600
SYS_GetEnvironmentStrings() : Retrieves the whole environment block of the current process.................................................601
SYS_GetEnvironmentVariable() : Retrieves the value of the specified variable from the environment block of the calling process...601
SYS_GetHInstance() : Retrieves the handle of the application instance that handles the main FoxPro window.............................602
SYS_GetLocalTime() : Gets the local time..........................................................................................................................602
SYS_GetNumDrives() : Finds out how many drives exist in the system..................................................................................603
SYS_GetStdHandle() : Gets the handle of a standard handle................................................................................................603
SYS_GetSysColor() : Retrieves the current color of the specified display element....................................................................604
SYS_GetSystemMetrics() : Retrieves various system metrics and system configuration settings................................................605
SYS_GetThreadLocale() : Returns the calling thread's current locale......................................................................................607
SYS_GetTickCount() : Retrieves the number of milliseconds that have elapsed since Windows was started.................................608
SYS_GetTimeZoneInformation() : Retrieves the current time-zone parameters.......................................................................609
SYS_GetTmpPath() : Gets the Windows temporary path......................................................................................................610
SYS_GlobalMemoryStatus() : Retrieves information about current available memory...............................................................611
SYS_HideCaret() : Removes the caret from the screen........................................................................................................611
SYS_inp() : input a byte from a port.................................................................................................................................612
SYS_iscd() : Is the given drive a CD-ROM?........................................................................................................................612
SYS_IsCompressed() : Determines if the specified volume is a compressed volume................................................................613
SYS_isDMA() : Is a DMA installed.....................................................................................................................................613
SYS_IsDriveReady() : Is a given drive ready?.....................................................................................................................613
SYS_IsFileCaseSensitive() : Does the system distinct between upper and lower case filenames?...............................................614
SYS_IsFileCasePreserved() : Does the system preserve cases?.............................................................................................614
SYS_isfixe() : Is the given drive a fixed drive?....................................................................................................................615
SYS_IsFlop() : Is the given drive a floppy drive? (is disk removable?)...................................................................................615
SYS_IsGame() : Is a game adapter present?......................................................................................................................616
SYS_IsLoaded() : Determines if a process (EXE) or library (DLL) is loaded.............................................................................616
SYS_IsMath() : Is Math coprocessor present?.....................................................................................................................617
SYS_IsModem() : Is a modem present?.............................................................................................................................617
SYS_IsMutex() : Does a given mutex object exist...............................................................................................................617
SYS_isNT() : Is the application running under Windows NT?.................................................................................................618
SYS_ispen() : Is it a pen computing prepared machine?......................................................................................................618
SYS_isram() : Is the given drive a RAM disk?.....................................................................................................................619
SYS_isremo() : Is the given drive a remote drive?..............................................................................................................619
TIME FUNCTIONS................................................................................................................................................................656
TIM_ctime() : Converts a time value retrieved via TIM_time() as a character string.................................................................658
TIM_FormatMilli() : Transforms a number of milliseconds in HH:MM:SS.mmm........................................................................658
TIM_FormatTimeInterval() : Converts a time interval, specified in milliseconds, to a string.......................................................658
TIM_GetNumberOfDays() : Computes the days difference between two dates.........................................................................659
TIM_gmt() : Converts a time value retrieved via TIM_time() to an Universal Time Coordinated (UTC)........................................659
TIM_LastVersion() : Returns the file stamp of Time functions...............................................................................................660
TIM_localt() : Converts a time value retrieved via TIM_time() to a local time string.................................................................660
TIM_MakeSeconds() : Computes the number of seconds from a time string............................................................................661
TIM_MakeTime() : Computes a time value from a date........................................................................................................661
TIM_SetFormat() : Customizes the internal string buffer that TIM_UserTime() will use.............................................................661
TIMER FUNCTIONS..............................................................................................................................................................666
TIM_kill() : Kills the global timer.......................................................................................................................................668
TIM_proc() : Customizes the command to be executed by the global timer............................................................................668
TIM_set() : Sets the global timer......................................................................................................................................669
TMR_Create() : Creates a timer........................................................................................................................................669
TMR_Destroy() : Destroys a timer.....................................................................................................................................670
TMR_HandlesCount() : Returns the maximum number of handles.........................................................................................670
TMR_HandlesFree() : Returns the number of free timer handles............................................................................................670
TMR_info() : Returns timer information.............................................................................................................................671
TMR_LastError() : Returns an error string indicating the nature of the last error encountered....................................................671
TMR_LastVersion() : Returns the file stamp of TMR functions................................................................................................672
TMR_MaxHandle() : Returns the highest possible handle......................................................................................................672
TMR_MinHandle() : Returns the lowest possible handle........................................................................................................672
TMR_Resume() : Resumes a timer....................................................................................................................................673
TMR_Suspend() : Suspends a timer..................................................................................................................................673
VERSION...........................................................................................................................................................................678
VER_alpha() : Gets/sets the alpha flag..............................................................................................................................681
VER_author() : Gets/sets the author name.........................................................................................................................681
VER_beta() : Gets/sets the beta flag.................................................................................................................................681
VER_cargo() : Gets/sets the cargo member. You can write whatever information you’d like to..................................................682
VER_cpyrig() : Gets/sets the application copyrights............................................................................................................682
VER_counte() : Gets/sets the application counter................................................................................................................682
VER_company() : Gets/sets the Company member.............................................................................................................683
VER_date() : Gets/sets the date field................................................................................................................................683
VER_demo() : Gets/sets the demo flag..............................................................................................................................683
VER_FinalRelease() : Gets/sets the Final Release flag..........................................................................................................684
VER_GetFileVersionInfo() : Determines executable version information..................................................................................684
VER_ini() : Gets/sets the INI file field................................................................................................................................686
VER_init() : Initializes C structure members.......................................................................................................................687
VER_LastVersion() : Returns the file stamp of VER functions................................................................................................687
VER_major() : Gets/sets the major version number............................................................................................................687
VER_minor() : Gets/sets the minor version number............................................................................................................688
VER_name() : Gets/sets the application name....................................................................................................................688
VER_prerel() : Gets/sets the pre-release flag......................................................................................................................688
VER_Release() : Gets/sets the Release flag........................................................................................................................689
VER_ReleaseCandidate() : Gets/sets the Release Candidate flag...........................................................................................689
VER_Revision() : Gets/sets the revision number.................................................................................................................690
VIDEO FUNCTIONS..............................................................................................................................................................691
VID_close() : Closes the AVI device..................................................................................................................................692
VID_end() : Sets the AVI to the end position......................................................................................................................692
VID_home() : Sets the AVI to the start position..................................................................................................................692
VID_LastError() : Determines the last error that occurred within the CD_*() functions.............................................................692
VID_LastVersion() : Returns the file stamp of VID functions.................................................................................................693
VID_loff() : Sets the AVI audio left off...............................................................................................................................693
VID_lon() : Sets the AVI audio left on...............................................................................................................................693
VID_off() : Sets the AVI audio off.....................................................................................................................................694
VID_on() : Sets the AVI audio on.....................................................................................................................................694
VID_open() : Opens the AVI device..................................................................................................................................694
VID_play() : Plays the AVI device.....................................................................................................................................694
VID_pause() : Pauses the AVI device................................................................................................................................695
VID_ron() : Sets the AVI audio right on.............................................................................................................................695
WHOIS FUNCTIONS...........................................................................................................................................................696
WHOIS_LastError() : Last error encountered in WHOIS functions..........................................................................................698
WHOIS_LastVersion() : Returns the file stamp of WHOIS functions.......................................................................................698
WHOIS_whois() : Queries a central repository for information regarding users, hosts, company addresses, and phone numbers.. .698
WINDOWS FUNCTIONS.........................................................................................................................................................702
WIN_bottom() : Window bottom border position in pixels....................................................................................................704
WIN_ClearOval() : Deletes an elliptical region created with WIN_MakeOval()..........................................................................704
WIN_Destroy() : Destroys the specified window.................................................................................................................705
WIN_DestroyIcon() : Destroys a given icon........................................................................................................................705
WIN_dialog() : Displays a dialog box that is the specified color scheme and contains the specified body text and button text........706
WIN_DrawAnimatedRects() : Draws a wire-frame rectangle and animates it to indicate the opening of an icon or the minimizing or
maximizing of a window..................................................................................................................................................706
ZIP FUNCTIONS.................................................................................................................................................................739
MEM_Compress() : Compresses a string............................................................................................................................741
MEM_Decompress() : Decompresses a string compressed with MEM_Compress()....................................................................742
ZIP_Compress() : Compresses a set of files into a ZIP archive..............................................................................................743
ZIP_Expand() : Expands all files contained in a ZIP archive..................................................................................................744
ZIP_LastError() : Determines the last error that occurred within the ZIP_*() functions.............................................................744
ZIP_LastVersion() : Returns the source file stamp of ZIP functions........................................................................................745
ZIP_List() : List all files contained in a ZIP archive..............................................................................................................745
ZIP_SetCallback() : Gets/Sets a callback function for the ZIP_Compress(), ZIP_Expand() and ZIP_List() functions......................746
ZIP_SetSubdirs() : Gets/Sets the subdirectory flag as used in ZIP_Compress()......................................................................747
Terms of Use
FOCUS.FLL is copyrighted shareware, not public-domain software. All source code and documentation contained in the
present notes is exclusive material and has been developed at FastWrite s.c.r.l.. As part of our service, FastWrite
s.c.r.l. agrees to provide freely downloadable evaluation versions of this software. FastWrite s.c.r.l. agrees to provide
this service free of charge You may use the unregistered version for an evaluation period of 60 days only. To
continue to use the software beyond the 60-day evaluation period, you must register it.
Upon notice published by FastWrite, FastWrite s.c.r.l. may amend or modify these Terms of Use at any time. You agree
to use the service in accordance with the Terms of Use.
Copyright Notices
The product is owned by FastWrite s.c.r.l.. All rights in the product including, copyrights, licensing rights, patents,
trademarks, trade secrets, design rights, engineering rights, moral rights, and any other intellectual property rights
belong to FastWrite. These rights are not transferred as part of this agreement.
This license agreement is a legal agreement between you the end user (either as an individual or an entity) and
FastWrite s.c.r.l. herein after referred to as FastWrite. The software and any of its supporting documentation are
herein after referred to as the product.
By purchasing, installing or using the product, you indicate your complete and unconditional acceptance of these terms
and conditions. If you do not agree to the terms and conditions of this agreement promptly remove the product from
your computer and destroy the associated documentation.
Should there be any conflict between the terms and conditions of this agreement and the terms and conditions of any
other agreement between you and FastWrite or their servants or agents in relation to the product the terms and
conditions of this agreement shall prevail.
If any provision of this agreement is found to be unlawful or void then that provision shall be severed from this
agreement and will not affect the validity of the remaining provisions. You will accept any new lawful provision
replacing the deleted clause and having an equivalent economic effect.
Information contained in the product is subject to change without notice and does not represent a commitment or
contracted obligation on the part of FastWrite.
Limitations of Use
You are expressly forbidden to develop more than one program associated to the product per registration. A new
registration is thus compulsory for each new development associating the product.
You are expressly forbidden from making alterations or modifications to, merge, adapt, de-compile, disassemble,
reverse engineer, or attempt to discover the source code without the expressed written permission from FastWrite. You
are expressly forbidden from using any part of the evaluation version of the product but for evaluation purposes
excluding any commercial or non-profit development as well as development for internal or private purposes.
You may use, modify, copy, distribute, and demonstrate any source code published in the documentation, example
programs, or documentation herein contained. This is to the sole exclusion of the library itself, namely the physical
files FOCUS.FLL and KERNEL.DLL.
You shall take the necessary steps in order to prevent any user of any program associated to the product from
developing and/or distributing new programs including the licensed product hereunder and shall notify FastWrite
s.c.r.l. in writing of the identity and address of any user of a program associated with the product. The latter clause is
of the essence of this agreement.
The programs developed by you and using the product FOCUS.FLL shall contain the full text of this license agreement.
FastWrite reserves the right to make changes to the specifications of the program and contents of the manual without
obligation to notify any person or organization of such changes.
Under no circumstances, including, but not limited to, negligence, shall FastWrite s.c.r.l., its subsidiary or affiliates be
liable for any direct, indirect, incidental, special or consequential damages that result from the use of, or the inability
to use, the product.
All the work contained herein and in the product is only intended as a pure illustration of basic concepts that apply to
Visual FoxPro development. It is distributed in the hope that it will be useful but is provided on an "as is" basis, with no
implied warranty regarding merchantability or fitness for any particular purpose. FastWrite s.c.r.l. and the author will
not be liable for any damages, no matter how severe they are, real or imagined, direct or indirect resulting from the
use of this software and documentation. FastWrite s.c.r.l. does not warrant that the functions contained in the
materials will be uninterrupted or error-free, nor that defects will be corrected.
With regard to the evaluation period freely granted by FastWrite s.c.r.l., no claim concerning the product shall be
admissible for any reason whatsoever.
If you are dissatisfied with any part of the product, or with any of FastWrite s.c.r.l. terms and conditions, your sole and
exclusive remedy is to discontinue using the product. In addition, You release FastWrite s.c.r.l. and its affiliates from
any damages that you incur, and agree not to assert any claims against them, arising from your use of it's products or
services.
In no way shall Fastwrite s.c.r.l. be liable for an amount exceeding the price of the product.
Breach of contract
You acknowledge that any breach of this agreement shall cause FastWrite s.c.r.l. irremediable harm and that FastWrite
s.c.r.l. reserves the right to claim damages in such occurrence with a minimum penalty of EUR 10,000.00 (ten
thousand euros and no cents).
Any dispute arising out of or in connection with this agreement shall be of the sole jurisdiction of the commercial court
of Nivelles.
We have developed FOCUS at FastWrite s.c., a long time ago. This project is actually rooted in Clipper. In fact it all
started in 1990 while we were developing Do-It!, a powerful library designed especially for Clipper Autumn '86.
As the project continued, we included more and more functions in Do-It! Many of them were developed in Assembler,
and C. From time to time we also included Clipper functions as well, as the Clipper compiler produced .OBJs.
Do-It! was also accompanied with a powerful screen generator, The Builder. Many functions that we have included in
Do-It! were just needed by the screen generator. We have updated Do-It! With the many new versions of Clipper :
Summer '87, then Clipper 5.0, finally Clipper 5.2. We thought that nothing was worse than this step : adapting our
library to new versions of the language. This process has led us to "subclass" all Clipper routines to ours, a treatment
we called "code floating". We have passed from Lattice C, to Microsoft C 4.0, then Microsoft C 5.0. From Microsoft
Macro Assembler 4.0 to 5.0 ... and we have survived them all!
In 1993, we saw the BIG change : turning Do-It! to FoxPro 2.5 for Windows. Not only the language was different, but
so was the target operating system—Windows 3.11. Many of the Assembler routines we have created were simply not
portable to Windows code. The Clipper code called many features that FoxPro didn't support : static variables, multi-
dimensional arrays (we're talking about arrays whose each individual element can be in turn an array), code blocks
(pointers to functions if you want, but much more than that), and also powerful preprocessor. Basically all the Clipper
code had to be removed and because FoxPro didn't (still doesn't) produce real .OBJs we could not turn any Clipper
code to FoxPro in order to include this code in the library itself. Additionally, we have gone away from Microsoft C 5.0
in favor of Microsoft Visual C++ 1.0, 1.5, 2.0, and 2.2.
That was a major earthquake but we eventually did it. We have adapted our "subclasses" to FoxPro API routines; we
have turned our old DOS code to Windows code; we have fine-tuned the memory allocation routines to properly avoid
the infamous GPFs! We grab the opportunity of these major changes to introduce a new one : we change from Do-It to
FOCUS. After this work has been completed we once again updated FOCUS to work with a new version of FoxPro—
version 2.6.
In 1995, we have once more introduced a major change : the shift to a new paradigm with the introduction of Visual
FoxPro 3.0. Call it evolution or revolution, we called it a nightmare! Not only was the version of FoxPro different, but
we also faced for the first time the importance of 32-bit code. Yes ... we were obliged to replace our old 16-bit code
with 32-bit code. We have simplified our task in the sense we decided not to support the 16-bit platform anymore,
namely Windows 3.11 and the like.
Once again, we updated our code to be compatible with Visual FoxPro 5.0. That was very easy ... for the first time! So
easy, that we actually decided once to have a library that would work for both versions. We did it for several months
up to the moment we only supported version 5. But the miracle is that FOCUS seems to be compatible, without any
change, with version 6. A miracle, we say.
Today, FOCUS is designed to suit any need (we hope) in the 32-bit environment, that is Windows 95, Windows 98 and
Windows NT. Although some of our machines are already equipped with Windows 98, we haven't performed any test
yet. We'll see what the future brings.
You may ask, why not develop classes as well? We did. In November 1996 we have announced FOCUS classes on
CompuServe although we didn't grab much attention from the FoxPro community. That was surprising to us as
FOCUS.FLL was such a success (more than 8.000 downloads). Perhaps we came too late with our classes?
The classes we planned to distribute included features not seen anywhere else. Of course, because we used our own
library and classes in our projects, some of the features were geared to our own way of doing things. We in Belgium,
for example, have a special need for multi-lingual applications : we have 3 national languages (yeah ... for such a
small country). That's the reason why we have included many features that you can also find in Steven Black Intl
product, a flagship product. Anyone serious with multi-lingual needs should get his development arsenal. Multi-lingual
needs drove us to develop Artificial Intelligence routines, a feature that's not available in any other library of classes,
we can assure you.
FOCUS.VCX grew up very rapidly and has known a number of revisions. We have rebuilt FOCUS.VCX many times;
we have "childed" FOCUS.VCX with POINTDBF.VCX , FOCUS2.VCX , etc. Now we're back with our original
FOCUS.VCX , cleaned up from many features that are only suitable for us. FOCUS.VCX can be obtained from our
Web Site (http://www.fastwrite.com ) and is constructed as a wrapper around FOCUS.FLL . Of course we have
developed many additional classes. And like many other libraries it provides an application framework (which is by no
means the last word on frameworks ... see also the fabulous work of Alan Griver with CodeBook, or the incredible
Sorry
From time to time (or very often) you might find English mistakes all along this document. This is due to the fact that
the authors are non native English persons. We sincerely apologize for this. Should anyone want to correct some parts
of this document, he (or she) is very welcomed.
Writing code can be a team effort, but in the case of FOCUS.FLL it is mostly a solo activity. So was the documentation
… up to October 98, period at which Pete Cuiry turned words into prose and reviewed the documentation. "Pete, you
went above and beyond the call of duty. Thank you".
1. FOCUS.FLL
2. KERNEL.DLL .
FOCUS.FLL is the only library you'll consciously deal with. However, FOCUS.FLL uses KERNEL.DLL internally.
FOCUS.FLL should be available in your project directory (the directory of your application). KERNEL.DLL should be
placed in the SYSTEM directory of Windows (most likely C:\WINDOWS\SYSTEM for Windows 95 or
C:\WINNT\SYSTEM32 for Windows NT 4.0). KERNEL.DLL cal also be placed in the application's home directory.
2. Invalid library.
FOCUS.FLL depends on KERNEL.DLL to work correctly. Both files work with each other. FOCUS.FLL should be
placed in the home directory of the application you need FOCUS.FLL for, and KERNEL.DLL is best placed in the
System directory of Windows.
When downloading FOCUS.FLL and KERNEL.DLL from Web sites, some browsers assign an .EXE extension to the
files when saving them to your hard disk. Should this happen, simply rename FOCUS.EXE to FOCUS.FLL or
KERNEL.EXE to KERNEL.DLL . This should solve the problem.
Long function names are available to Visual FoxPro developers that want to take advantage of improved readability
rather than to stick with 10 character function names. It is indeed simpler to use FIL_ReadIni() than
FIL_reaini() , even though both names point to the same internal service. Long function names are usually aliases.
5. What is an alias?
FOCUS.FLL treats aliases as alternate names for the same function. It helps developers to find the function they want
to use according to a logical category. When such functions can be placed under different categories, they are most
likely available under each category. That makes it very simple to find them. On the other hand, when such functions
are also known from other libraries, the alias technique makes it simple to keep calling the same function, even if it is
in fact called differently in FOCUS.FLL itself. For example, consider the SYS_dskspa() function that returns the
number of bytes that are currently available on a specified disk drive. This function can also be called with
DiskRoom() , SYS_DiskSpace() , SYS_DiskSpaceLeft() , or SYS_DiskEmpty() .
Under construction
Some functions are indicated as being under construction. These functions have been requested and accepted by
FastWrite but are not implemented yet. However, you can expect to get these ... one of these days!
Change Control
With version 7.87 of FOCUS.FLL we have introduced the Change Control Table so that you can follow what changes
have been made to FOCUS.FLL . Change Control is also a necessity to comply with a set of rules such as FDA CFR Title
21 Part 11. With it, you can rest assured that your library remains in full compliance with the rules of your industry.
1
MQSeries is a product of IBM for Queue Messaging
8.01 8 October 2002 1. STR_Like() : turning optimization off because of some weird problems on
some strings. We will have to rework our fast string search algorithm.
2. STR_strstr() : new function. No code impact. However, the function is
not yet documented and should not be used by the developers before
FastWrite gives the green light.
8.02 12 October 2002 1. STR_FndExe() : internal bug corrected (no impact on the VFP code).
Documentation reflects what the function really does now.
2. RG_Compile() : first introduction of Regular Expressions inside
FOCUS.FLL . Before long, all functions that were once created in the
FOCUSReg.dll, will be included in FOCUS.FLL for ease of use. The
RG_Compile() function works fine but we recommend not using it so
far.
3. RG_Execute() : first introduction of Regular Expressions inside
FOCUS.FLL . Before long, all functions that were once created in the
FOCUSReg.dll, will be included in FOCUS.FLL for ease of use. The
RG_Execute() function works fine but we recommend not using it so
far.
4. Documentation has been reviewed and many inconsistencies were
corrected.
5. HTTP_GetDefaultBrowser() : new function. No code impact.
Determines the location of the default browser.
6. NUM_BinHi() : new function. No code impact. Determines the high byte
value of a number.
7. NUM_BinLow() : new function. No code impact. Determines the low byte
value of a number.
8.03 12 January 2003 1. LOG_Append() : internal bug fixed when strategy set to “Reduce to Half
Size”.
2. EnumWindows() : this was an internal alias of WIN_EnumChildren() .
This is no longer the case as it became the alias of WIN_EnumWindows() .
Potential code impact.
3. GetWindows() : this was an internal alias of WIN_GetChildren() . This
is no longer the case as it became the alias of WIN_GetWindows() .
Potential code impact.
4. WIN_EnumWindows() : new function. No code impact. Initiates the
8.04 22 February 2003 1. FIL_CreateHardLink() : creates a new logical name for a file and
referring to the file with that logical name. Very similar to UNIX. New
function. No code impact.
2. Introduction of TAO functions. Even though simple, and maybe seen by
some programmers as useless, empty functions make it possible to return
results from basically any input. This makes them very suitable to build
long expressions that are nothing else but chaining of commands. TAO
functions were existing in FOCUS for a long time but they were kept sparse
(consider MIS_nothing() for example). Now all the same functions have
been gathered in one source. All TAO_*() functions are totally new and
hence do not have any code impact.
3. PRN_GetJobs() : internal bug corrected. Code impact.
4. PRN_GetJobInfo() : new function. No code impact.
5. TAO_false() : returns always .F.. New function. No code impact.
Identical to MIS_false() .
6. TAO_true() : returns always .T. . New function. No code impact. Identical
to MIS_true() .
7. TAO_string() : returns always "". New function. No code impact.
Identical to STR_null() .
8. TAO_datetime() : returns always { / / : : } . New function. No code
impact.
9. NUM_base() : converts the digits of a given integer argument to a string,
by taking into account a given radix. New function. No code impact.
10. STR_FormatByteSize() : Converts a numeric value into a string that
represents the number expressed as a size value in bytes, kilobytes,
megabytes, or gigabytes, depending on the size. New function. No code
impact.
11. TIM_FormatTimeInterval() : Converts a time interval, specified in
milliseconds, to a string. New function. No code impact.
12. HTML_Decode() : the function was present in the library but was not
documented. New function. No code impact.
8.05 17 April 2003 1. NUM_int_min() : determines the minimum of an integer. New function.
No code impact.
2. NUM_int_max() : determines the maximum of an integer. New function.
No code impact.
3. NUM_long_min() : determines the minimum of a long. New function. No
code impact. Even though NUM_long_min() is a different function than
NUM_int_min() , they both return the same value.
4. NUM_long_max() : determines the maximum of a long. New function. No
code impact. Even though NUM_long_max() is a different function than
NUM_int_max() , they both return the same value.
5. NUM_radix() : reverse function of NUM_Base() . New function. No code
impact.
6. PRN_GetPrnData() : takes additional flags to obtain the following
information: printer attributes, printer priority, printer default priority,
printer start time, printer until time, printer status, printer job count,
printer average page per minute. New parameters. No code impact.
7. WIN_Select() : selects a given window an redirects the VFP output to it.
New function. No code impact.
8. WIN_bottom() : the parameter of the function can either be the title of
the window, or its WHANDLE. New parameter. No code impact.
9. WIN_top() : the parameter of the function can either be the title of the
window, or its WHANDLE. New parameter. No code impact.
10. WIN_height() : the parameter of the function can either be the title of
the window, or its WHANDLE. New parameter. No code impact.
11. WIN_width() : the parameter of the function can either be the title of the
window, or its WHANDLE. New parameter. No code impact.
12. WIN_left() : the parameter of the function can either be the title of the
window, or its WHANDLE. New parameter. No code impact.
13. WIN_right() : the parameter of the function can either be the title of the
window, or its WHANDLE. New parameter. No code impact.
14. WIN_setPort() :Changes the user output window to be the specified
window. New function. No code impact.
15. WIN_getPort() :Returns the WHANDLE of the window that is currently
selected for user output. New function. No code impact.
16. FIL_wipe() : Wipes a file. New function. No code impact.
17. STR_hexa() : internal bug corrected. No code impact.
Version Dependencies
7.88 1. ADVAPI32.DLL 4.80.0.1675
2. COMCTL32.DLL 5.81.3105.105
3. COMDLG32.DLL 4.72.3110.2
4. FOCUS.FLL 7.88.0.0
5. GDI32.DLL 4.10.10.1998
6. KERNEL.DLL 0.0.0.0
7. KERNEL32.DLL 4.10.0.1998
8. LZ32.DLL 4.10.0.1998
9. MPR.DLL 4.10.0.1998
10. MSVCRT.DLL 6.0.8797.0
11. NETAPI32.DLL 4.10.0.1998
12. NETBIOS.DLL 0.0.0.0
13. OLE32.DLL 4.71.2612.0
14. SHELL32.DLL 4.72.3110.6
15. SHLWAPI.DLL 5.0.3105.105
16. USER32.DLL 4.10.0.1998
17. VERSION.DLL 4.10.0.1998
18. WININET.DLL 5.0.3105.105
19. WINMM.DLL 4.3.0.1998
20. WINSPOOL.DRV 4.10.0.1998
21. WS2HELP.DLL 4.10.0.1998
22. WS2_32.DLL 4.10.0.1998
Array Functions
Parameters
aArray the array to process. MUST BE PASSED BY REFERENCE
Returns
nAverage average value. Only the numeric values contained in aArray are taken into account.
Example
LOCAL ARRAY aArray[2,3]
aArray[1,1] = 1
aArray[1,2] = 45
aArray[1,3] = 3
aArray[2,1] = 113
aArray[2,2] = 5
aArray[2,3] = 78
aArray[1] = 2
aArray[2] = 10
aArray[3] = 8
aArray[4] = 7
aArray[5] = 8
Syntax
ARR_Create( szArray,iRows,iCols[,iScope] ) lSuccess
Parameters
szArray the name of the variable that will hold the array. Please notice that if szArray is already an
existing variable, ARR_create() will fail.
iRows the number of rows for a two-dimensional array, or number of elements for a one-dimensional
array (in that case, iCols is set to 0).
iCols the number of columns for two-dimensional arrays. In case of one-dimensional arrays, this
parameter must be set to 0.
iScope 0 for PUBLIC variables; 1 for PRIVATE variables. This parameter is optional. By default,
ARR_create() uses PRIVATE variables.
Returns
lSuccess .T. if the array was created successfully; .F. if not.
Example
IF ( ARR_create( "aArray",4,2 ) )
? "aArray has been created as an array of 4 rows,2 columns"
ENDIF
RELEASE aNoElemArray
Parameters
aArray the array to process. MUST BE PASSED BY REFERENCE.
iRows the variable that will receive the number of rows contained in the array. MUST BE PASSED BY
REFERENCE. If aArray is one-dimensional, this variable will receive the number of elements
contained in the array and iCols will be fetched with 0.
iCols the variable that will receive the number of cols contained in the array. MUST BE PASSED BY
REFERENCE. If aArray is two-dimensional, this variable will receive the number of columns
contained in the array; otherwise this variable is set to 0.
Returns
lSuccess .T. if the function was successful; .F. if not (aArray is not an array for example).
Example
LOCAL ARRAY aArray[4,8]
LOCAL iRows,iCols
iRows = 0
iCols = 0
IF ( ARR_Dimensions( @aArray,@iRows,@iCols ) )
? iRows && 4
? iCols && 8
ENDIF
IF ( ARR_Dimensions( @aArray,@iRows,@iCols ) )
? iRows && 16
? iCols && 0
ENDIF
RELEASE ALL
LOCAL iRows,iCols
LOCAL szVar
IF ( ! ARR_Dimensions( @szVar,@iRows,@iCols ) )
? "szVar is probably not an array"
ENDIF
Parameters
aArray the array to process. MUST BE PASSED BY REFERENCE.
Returns
nElements number of elements in the array (the array can be empty-none of its elements initialized). If
aArray is not passed by reference, the function returns –1. If aArray is not an array, the
function returns –1.
Example
LOCAL MyVar
LOCAL ARRAY aArray1[10,11]
LOCAL ARRAY aArray2[3]
? ARR_elements( aArray1 ) && -1 (because the array hasn't been passed by ref.)
? ARR_elements( @aArray1 ) && 110
Parameters
aArray the array to process.
Returns
nElements number of columns in the array (the array can be empty-none of its elements initialized). If
aArray is not passed by reference, the function returns –1. If aArray is not an array, the
function returns –1. If aArray does not have a second subscript, the function returns 0.
Example
LOCAL ARRAY aArray1[10,11]
LOCAL ARRAY aArray2[3]
? ARR_columns( aArray1 ) && -1 (because the array hasn't been passed by ref.)
? ARR_columns( @aArray1 ) && 11
? ARR_rows( @aArray1 ) && 10
? ARR_columns( aArray2 ) && -1 (because the array hasn't been passed by ref.)
? ARR_columns( @aArray2 ) && 0
? ARR_rows( @aArray2 ) && 3
Parameters
var the variable to test. MUST BE PASSED BY REFERENCE.
Returns
lSuccess .T. if var is an array; .F. if not.
Example
LOCAL ARRAY aArray[4,8]
LOCAL szVar
Parameters
aArray the array to process. MUST BE PASSED BY REFERENCE
Returns
nValue maximum value. Only the numeric values contained in aArray are taken into account.
Example
LOCAL ARRAY aArray[2,3]
aArray[1,1] = 1
aArray[1,2] = 45
aArray[1,3] = 3
aArray[2,1] = 113
aArray[2,2] = 5
aArray[2,3] = 78
Parameters
aArray the array to process. MUST BE PASSED BY REFERENCE
Example
LOCAL ARRAY aArray[2,3]
aArray[1,1] = 1
aArray[1,2] = 45
aArray[1,3] = 3
aArray[2,1] = 113
aArray[2,2] = 5
aArray[2,3] = 78
Parameters
aArray the array to process.
Returns
nRows number of rows in the array (the array can be empty-none of its elements initialized). If
aArray is not passed by reference, the function returns –1. If aArray is not an array, the
function returns –1.
Example
LOCAL ARRAY aArray1[10,11]
LOCAL ARRAY aArray2[3]
? ARR_columns( aArray1 ) && -1 (because the array hasn't been passed by ref.)
? ARR_columns( @aArray1 ) && 11
? ARR_rows( @aArray1 ) && 10
? ARR_columns( aArray2 ) && -1 (because the array hasn't been passed by ref.)
? ARR_columns( @aArray2 ) && 0
? ARR_rows( @aArray2 ) && 3
Syntax
ARR_LastVersion() szLastVersion
Parameters
None.
BMP Functions
Parameters
None.
Returns
nBits number of bits per pixel.
Caution
Use BMP_height() , BMP_width() , BMP_colors() , and BMP_bits() only after a successful call to
BMP_header() .
Parameters
None.
Returns
nColors number of colors.
Caution
Use BMP_height() , BMP_width() , BMP_colors() , and BMP_bits() only after a successful call to
BMP_header() .
Syntax
BMP_header( szFile ) nError
Parameters
szFile bitmap file to read.
Returns
nError 0 if function is successful. <0 if error occurred.
Example
LOCAL szFile
szFile = "C:\MYOWN.BMP"
IF ( BMP_isbmp( szFile ) )
IF ( BMP_header( szFile ) == 0 )
? BMP_height(),BMP_width()
ENDIF
ENDIF
Syntax
BMP_height() nHeight
Parameters
None.
Returns
nHeight bitmap height; -1 if not applicable.
Example
LOCAL szFile
szFile = "C:\MYOWN.BMP"
IF ( BMP_isbmp( szFile ) )
IF ( BMP_header( szFile ) == 0 )
? BMP_height(),BMP_width()
ENDIF
ENDIF
Caution
Use BMP_height() , BMP_width() , BMP_colors() , and BMP_bits() only after a successful call to
BMP_header() .
Syntax
BMP_isbmp( szFile ) lIsBitmap
Returns
lIsBitmap .T. if file is a bitmap file, .F. otherwise.
Example
LOCAL szFile
szFile = "C:\MYOWN.BMP"
IF ( BMP_isbmp( szFile ) )
IF ( BMP_header( szFile ) == 0 )
? BMP_height(),BMP_width()
ENDIF
ENDIF
Syntax
BMP_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion if a string identifying the last version of the BMP functions. The string is similar to
"C:\Focus\5.0\BMP.C-Mon Oct 19 15:55:22 1998" .
Syntax
BMP_width() nWidth
Parameters
None.
Returns
nWidth bitmap width; -1 if not applicable.
szFile = "C:\MYOWN.BMP"
IF ( BMP_isbmp( szFile ) )
IF ( BMP_header( szFile ) == 0 )
? BMP_height(),BMP_width()
ENDIF
ENDIF
Caution
Use BMP_height() , BMP_width() , BMP_colors() , and BMP_bits() only after a successful call to
BMP_header() .
CD Functions
Function Synopsis
CD functions are specialized built-in services of FOCUS.FLL which allow the developer to control a CD player.
CD functions are using MCI functions to control the CD player. Most of the time, FOCUS.FLL is internally using the
mciSendString() function which uses MCI commands.
How to use CD’s functions?
Prior to using any function you should make sure a CD player is attached to the PC. You can use CD_iscd() function
to determine whether a CD player is attached to the system.
After checking, you must observe the following rules:
1. Open the CD device (CD_open() )
3. Close the CD device when you no longer need it (you do not need to close the device necessarily).
Windows Control Panel
For the CD functions to work properly, you must ensure that a CD driver has been installed in the driver section of the
Control Panel.
CD player device name
All CD functions are directed to the FWCD device that is the alias the CD_open() function gave to the CDAUDIO
device. By default, you should use this alias (FWCD) if you desire to obtain tighter control on the device. This is also
the name you need to use in the CD_command() function.
Parameters
None.
Returns
.T. the function always returns .T..
CD_bayclo() : Retracts the tray and closes the door bay (if
possible).
Syntax
CD_bayclo() .T.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
lSuccess .T. if device can eject the disc tray; otherwise it returns .F..
Parameters
None.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
szString command to be sent to the CD player.
Returns
.T. the function always returns .T..
Example
&& FWCD is the alias that was given to the CDAUDIO.
CD_command( "play FWCD from 2 to 6" )
Parameters
None.
Returns
szPosition position in TMSF format (track, minute, second, frame).
Returns
szTrack returns the current track number as a string.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
lCDAttached .T. if a CD is attached to computer; .F. otherwise.
Syntax
CD_LastError() szLastError
Parameters
None.
Returns
szLastError string describing the last error that occurred using the CD_*() functions.
Syntax
CD_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion if a string identifying the last version of the BMP functions. The string is similar to
"C:\Focus\5.0\MCI.C-Mon Oct 19 15:55:22 1998" .
Syntax
CD_loff() .T.
Parameters
None.
Syntax
CD_lon() .T.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
lMediaIsThere .T. if a disc is inserted in the disc tray and the door is closed; .F. if not.
Parameters
None.
Returns
szStatus current device status.
Not ready
Open
Paused
Playing
Seeking
Stopped
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Syntax
CD_off() .T.
Parameters
None.
Returns
.T. the function always returns .T..
Syntax
CD_on() .T.
Returns
.T. the function always returns .T..
Syntax
CD_open() lSuccess
Parameters
None.
Returns
lSuccess was the attempt to open the CDAUDIO device successful or not?
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
lSuccess .T. if CD ready to play; .F. if not.
Parameters
None.
Returns
.T. the function always returns .T..
Syntax
CD_roff() .T.
Parameters
None.
Returns
.T. the function always returns .T..
Syntax
CD_ron() .T.
Parameters
None.
Syntax
CD_seek( szObject ) .T.
Parameters
szObject object to move to. szObject is depending on the time format.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
lSuccess .T.. if the function is successful; .F. otherwise.
Parameters
None.
Returns
lSuccess .T.. if the function is successful; .F. otherwise.
Returns
szFormat current time format. Normally, the TMSF format is used all in all the CD_*() functions but this
default may be change via external services.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
szTime total length of the disc.
Parameters
None.
Returns
szTrackCount number of tracks (as a string).
Returns
szLength length of given track.
Parameters
szTrackNo given track.
Returns
szPosition position at which the given track starts.
Clipboard Functions
Syntax
CLP_CountFormats() nFormatCount
Parameters
None.
Returns
nFormatCount number of data formats available in the clipboard.
Example
IF ( CLP_CountFormats() == 0 )
? "No data available in the clipboard"
ENDIF
Parameters
None.
Returns
lSuccess .T. if operation was successful; .F. otherwise.
Syntax
CLP_GetText() szText
Parameters
None.
Returns
szText text that was stored into the Windows clipboard.
Syntax
CLP_IsFormatAvailable( nFormat ) lAvailable
Parameters
nFormat specifies a standard or registered clipboard format.
CF_TEXT 1 Text format. Each line ends with a carriage return/linefeed (CR-
LF) combination. A null character signals the end of the data. Use
this format for ANSI text.
CF_BITMAP 2 A handle to a bitmap (HBITMAP).
CF_METAFILEPICT 3 Handle of a metafile picture format as defined by the
METAFILEPICT structure.
CF_SYLK 4 Microsoft Symbolic Link (SYLK) format.
CF_DIF 5 Software Arts' Data Interchange Format.
CF_TIFF 6 Tagged-image file format.
CF_OEMTEXT 7
CF_DIB 8 A memory object containing a BITMAPINFO structure followed
by the bitmap bits.
CF_PALETTE 9 When displaying clipboard data, Windows clipboard always uses
as its current palette any object on the clipboard that is in the
CF_PALETTE format
CF_PENDATA 10 Data for the pen extensions to the Microsoft Windows for Pen
Computing.
CF_RIFF 11 Represents audio data more complex than can be represented in
a CF_WAVE standard wave format.
CF_WAVE 12 Represents audio data in one of the standard wave formats, such
as 11 kHz or 22 kHz pulse code modulation (PCM).
CF_UNICODETEXT 13 Windows NT only: Unicode text format. Each line ends with a
carriage return/linefeed (CR-LF) combination. A null character
signals the end of the data.
CF_ENHMETAFILE 14 A handle of an enhanced metafile (HENHMETAFILE).
CF_HDROP 15 A handle of type HDROP that identifies a list of files. An
application can retrieve information about the files by passing the
handle to the DragQueryFile functions.
CF_LOCALE 16 The data is a handle to the locale identifier associated with text
in the clipboard. When you close the clipboard, if it contains
CF_TEXT data but no CF_LOCALE data, the system automatically
sets the CF_LOCALE format to the current input locale. You can
use the CF_LOCALE format to associate a different locale with the
clipboard text. An application that pastes text from the clipboard
can retrieve this format to determine which character set was
used to generate the text. Note that the clipboard does not
support plain text in multiple character sets. To achieve this, use
a formatted text data type such as RTF instead. Windows NT:
The system uses the code page associated with CF_LOCALE to
implicitly convert from CF_TEXT to CF_UNICODETEXT. Therefore,
the correct code page table is used for the conversion.
Returns
lAvailable .T. if the specified format is available; .F. otherwise.
Syntax
CLP_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion if a string identifying the last version of the BMP functions. The string is similar to
"C:\Focus\5.0\CLP.C-Mon Oct 19 15:55:22 1998" .
Syntax
CLP_SetText( szText ) lSuccess
Parameters
szText text to store into the Windows clipboard.
Returns
lSuccess .T. successful operation; .F. if not.
COM Functions
Functions Synopsis
We are currently reworking the COM functions. They were once available in FOCUS.FLL for FoxPro 2.6 but were
removed in FOCUS.FLL for Visual FoxPro.
Please do not start working with these functions yet as we're not sure about their final implementation.
This is actually work in progress!
The most critical phase in serial communications programming is configuring the port settings. Usually this is
performed with a DCB (Device Control Block) structure. Initializing the DCB structure is a common problem and very
often, when the serial communication functions do not produce the expected results, the DCB structure comes in good
place to take a look at. With FOCUS.FLL COM functions though, the settings of the DCB structure are set
automatically for the sake of your convenience. Should the automatic settings not fit your needs, then please be aware
that FOCUS.FLL provides additional mechanisms to tighter control them.
A call to the CreateFile() Win32 API function opens a serial port with default port settings. Very often, the
application needs to change the defaults, something performed via a call to the SetCommState() function.
The SetCommState() function uses a DCB structure that you can first populate with the current status. Use the
GetCommState() function to retrieve the default settings and use the SetCommState() function to set new port
settings.
When the correct port settings are set, you're ready to read and write to the COM port.
FOCUS.FLL works the same way while providing a higher level of abstraction. Instead of using the CreateFile()
Win32 API function, you use the COM_open() function that opens the port for read and write operations. At this
stage, you can already decide to read and/or write from/to COM ports … if the default settings match your
requirements. Should these settings not be satisfactory, then use the COM_SetCommState() function to use your
own settings.
Once you're done with the port, you simply close it using the COM_close() function.
FOCUS.FLL COM functions use handles similarly to file functions. When a COM port is opened via the COM_Open()
function it is identified by a COM handle. In all subsequent COM calls, the handle of the COM port must be passed as a
key parameter to the function.
LOCAL nCOMHandle
nCOMHandle = COM_open( "COM1" )
IF ( nCOMHandle != -1 )
? "The COM port has been successfully opened for Read and Write operations"
COM_close( nCOMHandle )
ELSE
? "Cannot open COM1 (" + COM_LastError() + ")"
ENDIF
Examples
COM_LastError() : Returns an error string indicating the nature of the last error encountered.
Parameters
nCOMHandle handle to a communication device. This handle is typically returned by the COM_open()
function of FOCUS.FLL .
szControlString string that specifies device-control information. The string must have the same form as the
mode command's command-line arguments. For example, the following string specifies a baud
rate of 1200, no parity, 8 data bits, and 1 stop bit:
"baud=1200 parity=N data=8 stop"
Returns
lSuccess .T. if the DCB structure is filled successfully; .F. otherwise.
COM_close() : to be continued.
Syntax
Parameters
?? ????.
Returns
?? ????.
Syntax
COM_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion if a string identifying the last version of the BMP functions. The string is similar to
"C:\Focus\5.0\COM.C-Mon Oct 19 15:55:22 1998" .
Parameters
?? ????.
Returns
?? ????.
COM_read() : to be continued.
Syntax
Parameters
?? ????.
Returns
?? ????.
Syntax
COM_LastVersion() szLastVersion
Parameters
?? ????.
Returns
?? ????.
COM_write() : to be continued.
Syntax
Returns
?? ????.
Cursors Functions
Syntax
CUR_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\CURSOR.C-Mon Oct 19 15:55:22 1998" .
The file is specified by its name or by a system cursor identifier. The function returns a handle to the newly created
cursor. Files containing cursor data may be in either cursor (.CUR ) or animated cursor (.ANI) format.
Syntax
CUR_Load( szCursorFile ) lSuccess
Parameters
szCursorFile indicates the source of the file data to be used to create the cursor. The data in the file must be
in either .CUR or .ANI format.
Returns
lSuccess .T. if the cursor file is loaded successfully; .F. otherwise.
Example
CUR_Load( "C:\WINDOWS\CURSORS\MYHAND.CUR" )
Date Functions
Parameters
dDate date to convert.
Returns
dBOM date corresponding to the beginning of the month.
Example
? DAT_bom( {31/12/1998} ) && 01/12/1998
Parameters
dDate date to convert.
Returns
dBOY date corresponding to the beginning of the year.
Example
? DAT_boy( {31/12/1998} ) && 01/01/1998
Parameters
szDateTime datetime expression to convert. The format of the parameter is depending on the current date
setting (mm/dd/year hh:mm:ss).
Returns
tDateTime datetime corresponding to szDateTime .
Example
SET DATE TO AMERICAN
? DAT_ctot( "05/31/1999 18:15:30" ) && {05/31/1999 18:15:30}
SET DATE TO BRITISH
? DAT_ctot( "31/05/1999 18:15:30" ) && {31/05/1999 18:15:30}
Syntax
DAT_DateTime() szDateTime
Parameters
None.
Returns
szDateTime 20 characters string in the YYYY-MM-DD hh:mm:ss format (there are 2 spaces between the
date and the time).
Example
LOCAL szAlmostUnique
Parameters
dDate date to obtain the day of.
Returns
nDay day (from 1 to 31).
Example
? DAT_doy( {^1998-12-31} ) && 31
Parameters
dDate date to obtain the day of year of.
Returns
nDay day (from 1 to 366).
Parameters
dDate date to convert.
Returns
dEOM date corresponding to the end of the month. Leap years are supported.
Example
? DAT_eom( {01/02/2000} ) && 29/02/2000
Parameters
dDate date to convert.
Returns
dEOY date corresponding to the end of the year.
Example
? DAT_eoy( {01/01/1998} ) && 31/12/1998
Parameters
dDate date to process.
Returns
dEaster Easter date.
Example
? DAT_Easter( {31/12/1998} ) && 12/04/1998
Parameters
dDate date to determine if it belongs to a leap year.
Returns
lLeap .T. if dDate belongs to a leap year; .F. if not.
Example
? DAT_IsLeap( {18/09/2000} ) && .T.
? DAT_IsLeap( {18/09/1999} ) && .F.
Syntax
DAT_jtod( nJulian ) dDate
Parameters
nJulian the Julian date to convert.
Returns
dDate date expression of nJulian .
Example
? DAT_jtod( 2450813 ) && { 30-12-97 }
? DAT_jtod( DAT_num( DATE() ) ) && returns DATE()
? DAT_jtod( DAT_num( DATETIME() ) ) && returns DATE()
Syntax
DAT_LastVersion() szLastVersion
Parameters
None.
Parameters
dDate date to obtain the month of.
Returns
nMonth day (from 1 to 12).
Example
? DAT_month( {31/12/1998} ) && 12
Syntax
DAT_num( dDate|tDateTime ) nNumber
Parameters
dDate date to convert.
or...
Returns
nNumber number that represents the dDate parameter. This is also known as the Julian date.
Example
? DAT_num( { 30-12-97 } ) && 2450813
? DAT_num( { 31-12-97 } ) && 2450814
? DAT_num( DATE() ) && Strictly equivalent to ? SYS(11,DATE())
? DAT_num( DATE() ),DAT_num( DATETIME() ) && 2451312,0000 2451312,423981482000000
See also
DAT_jtod() .
Syntax
DAT_NumberOfDays( nMonth ) nDays
Parameters
nMonth month number (1, 2, ...,12).
Returns
nDays number of days in the nMonth month. Warning : the month of February always returns 28
days!
Example
? DAT_NumOfDays( 1 ) && 31
? DAT_NumOfDays( 2 ) && 28 (ALWAYS)
? DAT_NumOfDays( 3 ) && 31
? DAT_NumOfDays( 4 ) && 30
Parameters
szDate date string to convert.
Returns
dDate date corresponding to the szDate parameter.
Example
? DAT_stod( "19981231" ) && {31/12/1998}
Parameters
dDate date to obtain the year of.
Returns
nYear year.
Syntax
DAT_ymd( dDate,@nYear,@nMonth,@nDay ) .T.
Parameters
dDate date to split.
nYear variable in which the Year component will be stored. The parameter MUST be passed by
reference.
nMonth variable in which the Month component will be stored. The parameter MUST be passed by
reference.
nDay variable in which the Day component will be stored. The parameter MUST be passed by
reference.
Returns
.T. the function always returns .T. .
Example
LOCAL nYear,nMonth,nDay
nYear = 0
nMonth = 0
nDay = 0
DAT_ymd( {31/12/1998},@nYear,@nMonth,@nDay )
DBF Functions
Parameters
nHowMany number of records that must be added. Default is 1 record.
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
.T. the function always returns .T. .
Syntax
DBF_bot( [nWorkArea] ) lTableStatus
Parameters
nWorkArea optional work area number. When not passed, the function returns the table status for the
current work area (nWorkArea = -1).
Returns
lTableStatus .T. if table is at first record; .F. otherwise.
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
lSuccess .T. if COMMIT was successful; .F. otherwise.
Returns
lStatus .T. if empty table (no record); .F. otherwise.
Syntax
DBF_eot( [nWorkArea] ) lTableStatus
Parameters
nWorkArea optional work area number. When not passed, the function returns the table status for the
current work area (nWorkArea = -1).
Returns
lTableStatus .T. if table is at last record; .F. otherwise.
Syntax
DBF_exclu( [nWorkArea] ) lExclusive
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
lExclusive .T. if table opened exclusively; .F. otherwise.
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
See also
DBF_GoTop() , DBF_Skip() .
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
nRecord current record number.
See also
DBF_GoBottom() , DBF_Skip() .
Syntax
DBF_flockd( [nWorkArea] ) lFLocked
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
lFLocked .T. if table locked or opened exclusively; .F. otherwise.
Syntax
DBF_LastVersion() szLastVersion
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\DBF.C-Mon Oct 19 15:55:22 1998" .
Parameters
nLockMethod locking method (0 = RECORD , 1 = FILE ). Default is RECORD .
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
lSuccess .T. if lock is successful; .F. otherwise.
Syntax
DBF_readon( [nWorkArea] ) lReadOnly
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
lReadOnly .T. when table opened in READ ONLY mode (no write access); .F. otherwise.
Syntax
DBF_reccnt( [nWorkArea] ) nRecords
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Syntax
DBF_replac( szField,xValue ) lSuccessful
Parameters
szField field to be replaced with xValue .
Returns
lSuccessful .T. if REPLACE was successful; .F. otherwise.
Syntax
DBF_rlockd( [nWorkArea] ) lRLocked
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
lRLocked .T. if current record is locked, or if table is locked or if table is opened exclusively; .F.
otherwise.
Comment
This function operates on current work area only.
Syntax
DBF_seek( xValue ) lFound
Returns
lFound .T. if value FOUND() ; .F. otherwise.
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
nRecords optional number to skip. When not passed, the function skips 1 record forward in the table
(+1). Negative numbers can be used to skip backward.
Returns
nRecord current record number or a negative number if the function failed.
See also
DBF_GoTop() , DBF_GoBottom() .
Parameters
nWorkArea optional work area number. When not passed, the function operates on the current work area
(nWorkArea = -1 ).
Returns
nStatus DBF status.
Functions Synopsis
DDA_*() functions of FOCUS.FLL make it possible to write a small Visual FoxPro interpreter. It's very usual in the
Xbase world to see applications executing variable code, code maintained in data files, and the likes … even code that
modifies itself, a very powerful feature but also somewhat dangerous to put in use. No doubt that Artificial Intelligence
uses this kind of technique to create morphing objects.
With version 5.13 a set of new functions has been added to FOCUS.FLL that are really powerful but also a bit
dangerous: DDA_Aliases() , DDA_Argc() , DDA_Argv() , DDA_IsFunction() , DDA_FuncPtr() ,
DDA_SetExecPtr() , DDA_ExecFuncPtr() . In fact they are only dangerous through the use of the
DDA_ExecFuncPtr() function that really triggers the execution of the code pointed to by an internal code pointer.
These new functions are the core component of Artificial Intelligence routines that come within FOCUS but that are so
far kept completely invisible to you.
In the future, you might expect an application to dialog with another through FOCUS.FLL , exchanging information,
executing code in one another, etc.
Syntax
DDA_Aliases( szFunction ) szAliases
Parameters
szFunction function to look for in FOCUS.FLL . The function is case insensitive. Don’t include parenthesis in
the function name.
Returns
szAliases a string with all known aliases of a given function. Each alias is semi-colon separated from the
other. The return value is an empty string is the function is not found. The function name is also
listed in the aliases of the function.
Example
? DDA_Aliases( "MIS_Vers" ) && "MIS_VER;MIS_VERS;MIS_VERSION"
Syntax
DDA_Argc( szFunction ) nParams
Parameters
szFunction function to look for in FOCUS.FLL . The function is case insensitive. Don’t include parenthesis in
the function name.
Returns
nParams number of parameters or –1 if the function is not found.
Example
? DDA_Argc( "MIS_IsFunction" ) && 1
See also
DDA_Argv() , DDA_Syntax()
Parameters
szFunction function to look for in FOCUS.FLL . The function is case insensitive. Don’t include parenthesis in
the function name.
Returns
szParamTypes parameter types or an empty string is the function is not found. If the specified function does
not expect any parameter, DDA_Argv() also returns an empty string.
"" No parameter
"0" .NULL.
"?" Any type can be passed
"C" Character type
"D" Date type
"I" Integer type
"L" Logical type
"N" Numeric type
"R" Reference
"T" Datetime type
"Y" Currency type
Example
? DDA_Argv( "MIS_False" ) && ".?,.?,.?,.?,.?,.?,.?,.?,.?,.?"
Parameters
nReset resets the internal counter to nReset calls.
Returns
nCalls number of calls submitted to internal evaluation.
Example
LOCAL lResult
LOCAL xResult
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
IF ( lResult )
Var = 741
IF ( DDA_ExtendedError() != 0 )
? "Var is unknown"
ELSE
? "Var is equal to ",xResult
ENDIF
See also
DDA_ResetCounter()
Syntax
DDA_CloseLog() .T.
Parameters
None.
Returns
.T. the function always returns .T. .
Example
LOCAL szLogFile
szLogFile = "C:\MYDDA.LOG"
IF ( DDA_SetLog( szLogFile ) )
DDA_execute( "WAIT WINDOW ‘There is no error here’ NOWAIT" ) )
IF ( ! DDA_execute( "WAIT WINDOWBADABOUM ‘Error!’ NOWAIT" ) ) )
szLogFile = DDA_GetLog() && Get the name of the log file
DDA_CloseLog() && Close the log file now
MODIFY COMMAND ( szLogFile ) && Edit the log file
DDA_SetLog( szLogFile ) && Re-establish the log file
ENDIF
ENDIF
Syntax
DDA_error() nError
Parameters
None.
Returns
nError last operation internal error code.
Syntax
DDA_Evaluate( szExpr ) xValue
Parameters
szExpr expression to evaluate. You can evaluate command lines such as MyVar = 16 and hoping that
it will assign 16 to MyVar . It will evaluate the expression instead, trying to figure out if MyVar
is equal to 16. If you want to execute command lines, you should call the DDA_execute()
function.
Example
LOCAL lResult
LOCAL xResult
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
Var = 741
IF ( DDA_ExtendedError() != 0 )
? "Var is unknown"
ELSE
? "Var is equal to ",xResult
ENDIF
Caution
The DDA_FuncPtr() , DDA_SetExecPtr() and DDA_ExecFuncPtr() are very powerful functions with which you
can build amazing features such as code that modifies itself. However they are also very dangerous. It goes far
beyond macros and is also much quicker because it never implies a compilation process of any sort.
If the parameters that are passed to this function do not correspond to the ones that are expected by the
function pointed to by the internal code pointer, unpredictable results will happen, often terminating the
current application by causing an illegal operation.
Syntax
DDA_ExecFuncPtr( <parameters> ) xValue
Returns
xValue the return of the function obtained by DDA_SetExecPtr() .
Example
LOCAL FuncPtr
FuncPtr = DDA_FuncPtr("STR_mirror")
IF ( FuncPtr != -1 )
&& Set up the internal code pointer
DDA_SetExecPtr( FuncPtr )
&& Execute the function of FOCUS.FLL that's located at that place
&& This will correspond to STR_mirror( "Hello" ) !!!
? DDA_ExecFuncPtr( "Hello" ) && "olleH"
ENDIF
See also
DDA_SetExecPtr() , DDA_FuncPtr() .
Syntax
DDA_Execute( szCommand ) lSuccess
Parameters
szCommand Visual FoxPro instruction to execute.
Returns
lSuccess .T. if the command was successfully carried; .F. otherwise. If the command cannot be
executed, the FOCUS.FLL library does not raise any error! This feature can be extremely
powerful in applications that are essentially based on external code (code found in external
files, or placed in databases, etc.).
Example
? DDA_Execute( "WAIT WINDOW ‘Hello World’" ) && .T.
? DDA_Execute( "This command does not exist" ) && .F.
Syntax
DDA_ExecuteFile( szFile ) lSuccess
Returns
lSuccess .T. if the command file was successfully executed; .F. otherwise. It can be that the file
contained many execution faults, which does not influence the return of the function!
Example
IF ( ! DDA_ExecuteFile( "MYFILE.PGM" ) )
? "Cannot execute command file"
ENDIF
Caution
The DDA_ExecuteSnapIn() , function is very similar to the DDA_ExecuteFile() however, the execution file must
be tagged with a well-defined mark at the first line: "FW1.0" . This precaution was needed to be able to distinguish
between different interpreter engines.
Syntax
DDA_ExecuteSnapIn( szFile ) lSuccess
Parameters
szFile file to execute.
Returns
lSuccess .T. if the file was correctly executed; .F. if not.
See also
DDA_ExecuteFile()
Syntax
DDA_ExtendedError() nError
Returns
nError the Visual FoxPro error code or 0 if no error occurred.
Example
LOCAL lResult
LOCAL xResult
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
Var = 741
IF ( DDA_ExtendedError() != 0 )
? "Var is unknown"
ELSE
? "Var is equal to ",xResult
ENDIF
Syntax
DDA_ExtendedErrorMessage() szError
Parameters
None.
Returns
szError the Visual FoxPro error message or "" if no error occurred.
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
IF ( lResult )
IF ( DDA_ExtendedError() != 0 )
? "The following error has occurred : " + DDA_ExtendedErrorMessage()
ENDIF
ENDIF
Var = 741
IF ( DDA_ExtendedError() != 0 )
? "Var is unknown"
ELSE
? "Var is equal to ",xResult
ENDIF
Alias
DDA_GetLogFile(), GetDDALogFile(), GetDDALog()
Syntax
DDA_GetLog() szLogFile
Parameters
None.
Returns
szLogFile the DDA log file or an empty string if there is none.
Example
DDA_SetLog( "C:\MYDDA.LOG" )
Parameters
None.
Returns
szCurStopProc current Error Handler routine for DDA routines used if Error Handling strategy is set to 1.
Syntax
DDA_FuncPtr( szFunction ) nPointer
Parameters
szFunction function to look for in FOCUS.FLL or –1 if the function was not found.
Returns
nPointer code pointer within FOCUS.FLL .
Example
SET LIBRARY TO FOCUS.FLL
DISPLAY STATUS
&& You should have a list such as the one that follows:
BMP_BITS 10001490
BMP_COLORS 100014B0
BMP_HEADER 100014D0
BMP_HEIGHT 10001450
BMP_ISBMP 10001210
BMP_WIDTH 10001470
CD_BAYOPE 1000B860
CD_BAYCLO 1000B890
CD_CANEJE 1000BA40
CD_CANPLA 1000BAA0
<etc.>
? NUM_hexa( DDA_FuncPtr( "CD_CANPLA" ) ) && 1000BAA0
Syntax
DDA_IsFunction( szFunction ) lExist
Returns
lExist .T. if function szFunction exists; .F. otherwise.
Example
? DDA_IsFunction( "MIS_Vers" ) && .T.
Syntax
DDA_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\DDA.C-Mon Oct 19 15:55:22 1998" .
Syntax
DDA_ResetCounter() .T.
Parameters
None.
Returns
.T. the function always returns .T. .
See also
DDA_Count()
Syntax
DDA_SetExecPtr( nPointer ) .T.
Parameters
nPointer code pointer within FOCUS.FLL . Typically, the nPointer pointer is obtained via the
DDA_FuncPtr() function.
Returns
.T. the function always returns .T. .
Example
LOCAL FuncPtr
FuncPtr = DDA_FuncPtr("STR_mirror")
IF ( FuncPtr != -1 )
&& Set up the internal code pointer
DDA_SetExecPtr( FuncPtr )
&& Execute the function of FOCUS.FLL that's located at that place
&& This will correspond to STR_mirror( "Hello" ) !!!
? DDA_ExecFuncPtr( "Hello" ) && "olleH"
ENDIF
Alias
DDA_SetLogFile(), SetDDALogFile(), SetDDALog()
Syntax
DDA_SetLog( szLogFile ) lSuccess
Parameters
szLogFile the DDA log file to set. FOCUS.FLL accepts only once the setting of the log file: once it has
been set, it cannot be overwritten before another session of FOCUS.FLL .
Returns
lSuccess .T. if the DDA log file was successfully set; .F. otherwise.
Example
IF ( DDA_SetLog( "C:\MYDDA.LOG" ) )
? DDA_GetLog() && "C:\MYDDA.LOG"
Parameters
szProc procedure that must be executed when an error occurs in the FOCUS.FLL interpreter engine.
This procedure will only be executed if the Error Handling strategy is set to 1 (see
DDA_stop() ).
Returns
szCurProc current procedure.
Example
DDA_SetStop( "DO MyErrorHandler WITH DDA_ExtendedError()" ) )
DDA_stop( 1 ) && Use custom error handler
DDA_execute( "Mistake" ) && Should trigger MyErrorHandler!
Parameters
nStrategy strategy to follow:
Value Meaning
0 FOCUS.FLL continues execution
1 FOCUS.FLL should execute a given procedure
2 FOCUS.FLL should generate a VFP error
3 FOCUS.FLL should generate a custom error (not
supported yet)
This parameter is optional. When not passed, the function simply returns the current strategy
status. The default strategy used by FOCUS.FLL is 0: no stop!
Returns
nCurrentStrategy the current strategy used by FOCUS.FLL .
Functions Synopsis
FOCUS.FLL comes with several enhancements over the standard common dialogs. Common Dialog Boxes make it
simple for an application to call single functions rather than creating complex dialog box procedures with resource file,
etc.
FoxPro already provides such services through the well known GETFILE() , GETDIR() , GETFONT() functions.
However, we wanted to give the developer tighter control.
Each standard dialog is taken from the COMMDLG.DLL that provides a default procedure and template for each type
of common dialog box.
Syntax
DLG_color( nRGBInitColor,nFlags[,nHwnd] ) nRGBColor
Parameters
nRGBInitColor specifies the color initially selected when the dialog box is created.
When the dialog box is created, the system selects the nearest solid color available if the
CC_RGBINIT flag is specified in the Flags member and the value of this member is not among
the available colors. If this member is not valid, the color initially selected is black.
nHwnd optional owner window handle. By default, the DLG_color() function uses the main FoxPro
window handle.
Returns
nRGBColor RGB color, or -1 if Cancel was selected.
Example
* Init with color corresponding with RGB( 192,192,192 ) = 1
* Make it impossible to define new predefined colors = 4
* ---------------------------------------------------------
= 5
? DLG_color( RGB( 192,192,192),5 )
Syntax
DLG_font( nRGBInitColor,nMinSize,nMaxSize,nFlags ) szFont
nMinSize specifies the minimum point size a user can select. You must set the CF_LIMITSIZE flag
member.
nMaxSize specifies the maximum point size a user can select. You must set the CF_LIMITSIZE flag
member.
Returns
szFont font name, font size, font style.
Example
* 385 corresponds to CF_SCREENFONTS + CF_EFFECTS + CF_USESTYLE
? DLG_font( 0,0,0,385 ) && "Arial,10,Regular" for example!
Syntax
DLG_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\DLG.C-Mon Oct 19 15:55:22 1998" .
Filter expressions and filter patterns should be separated with NULL characters ( CHR(0) ).
OFN_ALLOWMULTISELECT Specifies that the File Name list box allows multiple
selections. (If the dialog box is created by using a private
template, the definition of the File Name list box must contain
the LBS_EXTENDEDSEL value.)
OFN_CREATEPROMPT Specifies that the dialog box function should ask whether the
user wants to create a file that does not currently exist. (This
flag automatically uses the OFN_PATHMUSTEXIST and
OFN_FILEMUSTEXIST flags.)
OFN_ENABLETEMPLATE Causes the operating system to create the dialog box by
using the dialog box template identified by hInstance and
lpTemplateName.
OFN_ENABLETEMPLATEHANDLE Indicates that hInstance identifies a data block that contains a
preloaded dialog box template. The operating system ignores
lpTemplateName if this flag is specified.
OFN_EXTENSIONDIFFERENT Specifies that the user typed a filename extension that differs
from the extension.
OFN_FILEMUSTEXIST Specifies that the user can type only names of existing files in
the File Name entry field. If this flag is specified and the user
enters an invalid name, the dialog box procedure displays a
warning in a message box. If this flag is specified, the
OFN_PATHMUSTEXIST flag is also used.
OFN_HIDEREADONLY Hides the Read Only check box
OFN_NOCHANGEDIR Causes the dialog box to set the current directory back to
what it was when the dialog box was called.
OFN_NONETWORKBUTTON Hides and disables the Network button.
OFN_NOREADONLYRETURN Specifies that the returned file does not have the Read Only
check box checked and is not in a write-protected directory.
Returns
szFile file(s) that has (have) been chosen.
Example
* Searching the C:\ directory (multiple file interface)
? DLG_save( "Wave files" + CHR(0) + "*.WAV" + CHR(0) + ;
"All files" + CHR(0) + "*.*" + CHR(0) + CHR(0), ;
"Save to...","C:\",0x00000200 )
Editor Functions
Functions Synopsis
FOCUS.FLL uses built-in editor capabilities of Visual FoxPro. All these functions are available through the C API of
Visual FoxPro. It makes it possible to write a very small Word Processor not to be compared to MS-Word capabilities
but it can beat Editbox features any time. RTF controls are more powerful but also more difficult to manage. Editor
functions can only process text files!
Parameters
nEditorHandle Editor Handle. This handle can be obtained by calling the EDI_Open() function.
lStatus .T. to ask Visual FoxPro to auto-indent lines in the editing window; .F. otherwise. If this
parameter is not passed, EDI_AutoIndent() simply returns the current status.
Returns
lCurStatus the current status. It is important to notice that if the lStatus parameter is passed, the
function returns the status before it sets it to something else.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
lStatus .T. to ask Visual FoxPro to make backup files; .F. otherwise. If this parameter is not passed,
EDI_Backup() simply returns the current status.
Returns
lCurStatus the current status. It is important to notice that if the lStatus parameter is passed, the
function returns the status before it sets it to something else.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
nErrorCode 1 if the file editing window was closed without saving; 0 if the file was saved and the window
was closed.
Returns
.T. the function always returns .T. .
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
lSuccess .T. if the function was successful; .F. otherwise.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
szFile name of the file that is currently edited; an empty string is returned when no file is currently
edited that corresponds to nEditorHandle .
Syntax
EDI_Dirty( nEditorHandle ) lChanged
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
lChanged .T.. if the file was changed; .F. otherwise.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
nOffset offset position in the file. If this parameter is not passed, the EDI_GetLineNum() function
retrieves the line number of the current offset position.
Returns
nLine the function always returns .T. .
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
nOffset offset of the first character of line nLine .
Syntax
EDI_GetPos( nEditorHandle ) nOffset
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
nOffset current offset position.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
lSyncPoint .T. to group separate actions as a single action for EDI_Undo() and EDI_Redo() ; .F. to
terminate grouping.
Returns
lSuccess .T. if the function was successful; .F. otherwise.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
lSuccess .T. if the szString insertion text was inserted; .F. otherwise.
Syntax
EDI_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\EDITOR.C-Mon Oct 19 15:55:22 1998" .
Syntax
EDI_Open( szFile ) nEditorHandle
Parameters
szFile file to open.
Returns
nEditorHandle editor Handle. This handle will be used in all subsequent Editor functions. If no handle can be
associated, EDI_Open() returns –1.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
.T. the function always returns .T. .
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
nOffset offset position in the file. If this parameter is not passed, the EDI_PosInView() function uses
the current offset position.
Returns
lVisible .T. if the offset position is visible in the current view of the editing window; .F. otherwise.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
.T. the function always returns .T. .
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
.T. the function always returns .T. .
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
lSuccess .T. if the function was successful; .F. otherwise.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
.T. the function always returns .T. .
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
lStatus .T. to ask for line and column display on the statusbar of Visual FoxPro; .F. otherwise. If this
parameter is not passed, EDI_StatusBar() simply returns the current status.
Returns
lCurStatus the current status. It is important to notice that if the lStatus parameter is passed, the
function returns the status before it sets it to something else.
Parameters
nEditorHandle editor Handle. This handle can be obtained by calling the EDI_Open() function.
Returns
.T. the function always returns .T. .
Event Functions
Functions Synopsis
In FOCUS.FLL for FoxPro (as opposed to Visual FoxPro), there were numerous Event functions. These were no longer
needed with the advent of Visual FoxPro ... until we wanted to grab more control over event processing. For example,
with the advanced event scheme of FOCUS.FLL it is now possible to detect idle time and to branch the execution of
the program to a certain routine (see EVE_OnIdleInterval() , EVE_OnIdleCommand() ,
EVE_GetIdleSince() ).
Parameters
nEvent event number. The following events are supported by VFP and FOCUS.FLL :
Returns
lSuccess .T. if the function is successful; .F. if not.
Remark
This function has been temporarily disabled for performance degradation. Please notice that the associated
command will only be fired at first null event.
Syntax
EVE_End() .T.
Parameters
None.
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 122
Event Functions
Returns
.T. the function always returns .T..
See Also
EVE_Start() .
Syntax
EVE_OnIdleSince() nMilliSeconds
Parameters
None.
Returns
nMilliSeconds tick count when the last event did happened.
See Also
EVE_OnIdleCommand() , EVE_OnIdleInterval()
Example
LOCAL szIdleInterval
LOCAL szIdleCommand
FUNCTION CheckIfTooLong()
LOCAL nMilliSeconds
RETURN ( VOID )
Parameters
None.
Returns
szLastError last error that occurred while using the EVE_*() functions.
Syntax
EVE_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set.
Syntax
EVE_OnIdleCommand( [szCommand] ) szCurrentCommand
Parameters
szCommand command to be executed at the next idle time.
Returns
szCurrentCommand current command executed when idle interval is elapsed.
Example
LOCAL szIdleInterval
LOCAL szIdleCommand
FUNCTION CheckIfTooLong()
LOCAL nMilliSeconds
RETURN ( VOID )
Syntax
EVE_OnIdleInterval( [nMilliSeconds] ) nInterval
Parameters
None.
Returns
nMilliSeconds number of milliseconds before executing the OnIdleCommand .
See Also
EVE_OnIdleCommand() .
FUNCTION CheckIfTooLong()
LOCAL nMilliSeconds
RETURN ( VOID )
Alias
ResetIdleSince()
Syntax
EVE_ResetIdleSince() .T.
Parameters
None.
Returns
.T. always.
Example
PROCEDURE DoTopic( nChannel,szAction,szItem,szData,szFormat,nAdvise )
LOCAL lResult
LOCAL szToPoke && Whatever needs to be fetched
lResult = .F.
DO CASE
CASE ( szAction == "INITIATE" )
lResult = .T.
oApp.DDE.ConnectionCounter = oApp.DDE.ConnectionCounter + 1
EVE_ResetIdleSince()
CASE ( szAction == "EXECUTE" )
lResult = ProcessDDEExecute( nChannel , ;
szAction , ;
szItem , ;
szData , ;
szFormat , ;
nAdvise )
IF ( lResult )
EVE_ResetIdleSince()
ENDIF
CASE ( szAction == "REQUEST" )
lResult = ProcessDDERequest( nChannel , ;
szAction , ;
szItem , ;
szData , ;
szFormat , ;
nAdvise , ;
@szToPoke )
IF ( lResult )
DDEPoke( nChannel,szItem,szToPoke )
EVE_ResetIdleSince()
ENDIF
CASE ( szAction == "TERMINATE" )
lResult = .T.
oApp.DDE.ConnectionCounter = oApp.DDE.ConnectionCounter - 1
IF ( oApp.DDE.ConnectionCounter < 0 )
oApp.DDE.ConnectionCounter = 0
ENDIF
EVE_ResetIdleSince()
ENDCASE
RETURN ( lResult )
Syntax
EVE_SetUserDefinedAtNullCommand( [szCommand] ) szCurrentCommand
Parameters
szCommand the command that must be carried out when a null event is encountered (when the application
has nothing to do).
Returns
szCurrentCommand the current command. As soon as the command has been carried on, it is removed and won't
be executed again unless it is once again fetched in the queue of FOCUS.FLL .
Example
&& A typical example of what has been said is the case where the client
&& wants the server to display its About dialog box (assuming that this is
&& a modal process).
&& Imagine that the server receives a demand of execution of the "ABOUT"
&& item, and that it must execute the oApp.AboutBox() in respond for it.
&& The proper way for it would be to execute the following command then:
SetUserDefinedAtNullCommand( "oApp.AboutBox()" )
Parameters
None.
Returns
.T. the function always returns .T..
See Also
EVE_End() .
Functions Synopsis
FOCUS.FLL provides now basic data file functions known as FDB_*() functions. You might ask why FOCUS.FLL has
such functions when it is mostly entirely written for Visual FoxPro, an unsurpassed database engine for the PC. Well,
that was needed to create Artificial Intelligence knowledge bases that FOCUS.FLL will address in future versions
without depending on external resources.
From within the C code the library will store information about what you do with it, how you use it, etc. For example,
imagine a function that tries to determine where a given application is located, MS-Word for example. When it is
found, FOCUS.FLL may decide to store this information for later retrieval and possibly pass this information to other
instances of FOCUS.FLL and FOCUS.VCX . If multiple paths are to be considered, FOCUS.FLL may decide to store
them all so that it can try locate the same application where it found it one day.
This information is actually stored in knowledge bases which are nothing else but FDB files.
This is the first version of FDB files. A first version usually means unstable and incomplete. FDB files face the same
problem as any computer product so don't expect too much from it in their current state. For example there is no
SEARCH nor INDEX capabilities; you cannot replace a single field with a value, etc.
Parameters
nHandle handle to the FDB file.
Returns
nRecords number of records contained in the FDB file after the insertion.
Parameters
szFile name of the FDB file to create.
szStructure the file structure. Each field contains 4 tokens : a fieldname, a field type, a field length, and a
field description. Each token is separated by a semicolon. Each field is separated by a
semicolon.
Returns
lSuccess .T. if the FDB file is successfully created; .F. if not.
Syntax
FDB_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\FDB.C-Mon Oct 19 15:55:22 1998" .
File Functions
Functions Synopsis
It is claimed that the applications created with Visual FoxPro are compliant with Windows 95 and Windows NT. That
certainly means that, from this point, you'll have to deal with new file concerns.
The way Windows 95 and Windows NT handle files is very much different from what we used to know. Both operating
systems largely extended the file capabilities. They can even deal with different file systems simultaneously.
While it was quite usual to talk about the FAT, today we have to consider additional file systems such as NTFS, CDFS,
and HPFS in addition to the FAT system.
There is no doubt that the FAT system, even though less powerful, will still be the most frequently used system;
certainly for the users that need a flexible way to boot their system. Please note that the FAT system is the only
suitable one for floppies.
HPFS was originally created for the OS/2 platform. Windows NT recognizes the format for "backward compatibility"
with OS/2 (backward compatibility from the Microsoft stand point of view).
NTFS is the File System of Windows NT. NTFS uses the international Unicode convention to store the filenames.
FAT is the old File System we all used. Windows 95 has extended this File System to support the long names
convention.
With NTFS, the File System distinguishes between upper and lower case filenames. This was mandatory in order to
preserve a certain compatibility with POSIX (Jeffrey Richter, Développer sous Windows 95 et Windows NT, Microsoft
Press).
The FOCUS library provides the SYS_volume() function to determine with which file system your program is actually
dealing:
You can also use the SYS_volume( <szRoot>,2 ) (obtain volume serial number) service of FOCUS to track down
disk changes. Since MS-DOS 4.0, the FORMAT command puts a serial number on each formatted disk.
SYS_volume( <szRoot>,3 ) (or SYS_MaxFileLength() ) can be used to exactly determine the maximum
filename length of a given system. You should use this function instead of hardcoding filename lengths in your
program:
LOCAL szFile
When developing business applications, always keep in mind that the user can now mix these four basic file systems
(FAT, NTFS, CDFS and HPFS). In addition, more file systems will probably exist in the future.
Another thing to pay attention to is Unicode, that's the reason why we provide the SYS_IsUnicodeOnDisk()
function! Only the NTFS and FAT file systems store filenames under the Unicode form. Should you need paths, and
filenames, the system will take in charge all the necessary conversions, but it's up to you to reserve enough space.
Starting with version 5.13 of FOCUS.FLL , a brand new set of File functions have appeared: FIL_open() ,
FIL_create() , FIL_tell() , FIL_seek() , etc. In fact these functions have always existed in FOCUS.FLL but
they were kept hidden. What these functions have to offer is really immense when you compare them to low-level
native FoxPro file functions. The most obvious advantage is their ability to open a file in a SHARED mode, both for
reading and for writing. But they go far beyond that when you use them in conjunction with the
FIL_SetOpenStrategy() function. Indeed, by the FIL_SetOpenStrategy() you control how the functions are
to operate, either working directly with the Win32 API or mimicking Visual FoxPro. Of course, as you may guess, you
better use the Win32 API that provides tighter control over a number of features.
I do not want to take you on a tour of all these features now but just consider what streams can do in the NTFS
format. Streams can be incredibly useful in many situations where you need to store many different data of variable
length within the same file. How do you specify a stream? By simply specifying a colon after the file name, and then
followed by the name of the stream. For example, when issued on a NTFS partition, the following code will create a
stream named MyStream in the file MYFILE.TXT:
#define WIN32API_STRATEGY 1
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
FIL_SetOpenStrategy( WIN32API_STRATEGY )
nHandle = FIL_create( "C:\MYFILE.TXT:MyStream",GENERIC_READ+GENERIC_WRITE )
FIL_write( nHandle,REPLICATE( "Hello",100 ) )
FIL_close( nHandle )
What this code does is simple: it creates a file called MYFILE.TXT and within that file it creates a stream: MyStream .
Now, when you attempt to open the file, thanks to an application such as NOTEPAD.EXE, what really seems to be
incredible is that the file seems to be empty. Even the length reported by the Explorer is 0! However, you have well
written a string of 500 bytes to it (100 * length of "Hello"). I would say that Streams seem to be files within files! Well,
Visual FoxPro does not permit to create streams where FOCUS.FLL does.
Parameters
None.
Returns
lANSI .T. if the set of Win32 file functions is using the ANSI code page; .F. if the set of Win32 file
functions is using the OEM code page.
Syntax
FIL_BrowseForComputer( szMessage ) szComputer
Parameters
szMessage message that is displayed above the tree view control in the dialog box. This message can be
used to specify instructions to the user.
Returns
szComputer computer that was chosen or an empty string if no computer was selected.
Example
LOCAL szComputer
IF ( ! EMPTY( szComputer ) )
? "Computer:",szComputer
ENDIF
Syntax
FIL_BrowseForFolder( szMessage ) szFolder
Returns
szFolder folder that was chosen or an empty string if no folder was selected.
Example
&& Old fashioned code :
LOCAL szDir
m.szDir = GETDIR()
IF ( ! EMPTY( m.szDir ) )
? "Directory:",m.szDir
ENDIF
IF ( ! EMPTY( m.szDir ) )
? "Directory:",m.szDir
ENDIF
Syntax
FIL_BrowseForPrinter( szMessage ) szPrinter
Parameters
szMessage message that is displayed above the tree view control in the dialog box. This message can be
used to specify instructions to the user.
Returns
szPrinter printer that was chosen or an empty string if no printer was selected.
Example
LOCAL szPrinter
IF ( ! EMPTY( szPrinter ) )
? "Printer:",szPrinter
ENDIF
Returns
szCanonPath canonicalized path.
Example
? FIL_canonicalize("..\SPOT2100\BITMAPS\..\BITMAPS" ) && "\SPOT2100\BITMAPS"
Syntax
FIL_chdir( szPath ) lSuccess
Parameters
szPath new default path to set.
Returns
lSuccess .T. if operation was successful, .F. otherwise.
Example
IF ( ! FIL_chdir( "C:\DVL\FOX" ) )
? "Attempt to change directory failed"
ENDIF
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Handles that are returned by the FIL_close() function when the Win32 API has been selected cannot be used by
low-level functions of FoxPro.
Syntax
FIL_close( nHandle ) lSuccess
Parameters
nHandle file handle.
Returns
lSuccess file closed successfully?
It is important to notice that buffers are a basic switch in speeding up PC operations when it comes to read and write
disks because the information can be accessed again later without having to actually read it from disk.
FIL_commit() is identical to FFLUSH() of Visual FoxPro. The function has been created to allow flushing data from
within FOCUS.FLL . Because it was available internally, we have decided to expose this function publicly.
FIL_commit() differs from FIL_FlushAll() in the sense that FIL_FlushAll() operates on streams.
Syntax
FIL_commit( nHandle ) lSuccess
Parameters
nHandle file handle.
Returns
lSuccess file flushed successfully? .T. if operation was successful, .F. otherwise.
Example
LOCAL nHandle
IF ( nHandle > 0 )
FWRITE( nHandle,"This is a test" )
IF ( ! FIL_commit( nHandle ) )
? "The file couldn't be flushed"
ENDIF
FCLOSE( nHandle )
ENDIF
See also
FIL_FlushAll() .
Syntax
FIL_Common( szPath1,szPath2 ) szCommon
Parameters
szPath1 path to be compared with szPath2 .
szPath2 path to be compared with szPath1 .
Returns
szCommon common prefix.
Example
? FIL_common("C:\SPOT2100","C:\SPOT2100\MEMBERS") && " C:\SPOT2100"
Alias
FileComp()
Syntax
FIL_comp( szFile1,szFile2 ) nDiff
Parameters
szFile1 file szFile1 will be compared to szFile2 .
Returns
nDiff 0 if both files are identical. Otherwise nDiff indicates the first offset at which both files differ.
Parameters
szFile1 first file.
nStructure which structure should be examined. Time stamp type: 1 = LastWrite, 2 = LastAccess, 3 =
Creation
Returns
nResult can be 0, -1 or 1.
Value Meaning
-1 szFile1 is older than szFile2 .
0 szFile1 is equal to szFile2 .
1 szFile2 is older than szFile1 .
Example
* Comparing one file with itself will obviously result in 0
* (time is identical)
? FIL_CompareTime( "BOOKS.H","BOOKS.H",1 ) && 0
The Win32 environment is now proposing a basic service called CopyFile() (simple enough...). Unfortunately, this
basic Win32 service does not provide an empty slot for a callback process so that there is no means to inform the
calling application of the file copy progression. The FIL_copy() function of FOCUS gives you the ability to use one or
the other method. Should you want to have a very quick copy (even in a kind of asynchronous mode), then we
recommend you to pass the FIL_copy() function an additional parameter: .T. . Should you feel that it's much
important to inform the user about the progression, then simply omit the fourth parameter of FIL_copy() .
Because, there is no way to determine whether you would prefer the target file date and time stamps to be related to
the copy or to the file source attributes, the FOCUS library does not use the date and time stamps of the source file. If
you want to keep these values, please use the FIL_gdate() , FIL_gtime() before copying and FIL_sdate() and
FIL_stime() functions after.
We have created two sample files: one is creating a progress bar of our own; the other uses the standard progress bar
of Windows 95. If you want to use the standard progress bar of Windows (which is by far the recommended method),
you can also use the additional service FIL_copyTimes() which will determine in advance how many times the
callback process is about to be triggered. The value returned by the FIL_copyTimes() function can then be used to
set the Max property of the progress bar. The second sample we have provided uses this method.
Alias
FCopy(), CopyFile(), FileCopy()
Syntax
FIL_copy( szFileIn,szFileOut[,szUDF[,lImmediate]] ) nSuccess
Parameters
szFileIn source file to be copied.
szUDF function to activate between each copy of a block. It is necessary to precede the function name
with a equal sign ("="). Do not include opening and closing parentheses. The function is passed
two parameters : the total number of blocks that must be copied and the current block number.
Optional parameter. Please notice that a copy without UDF is much faster than when mentioning
a function to execute.
lImmediate uses Windows to perform the copy (quickest way). Optional parameter.
Returns
nSuccess was the copy successful or not? 0 indicates a successful copy, -3 indicates that the source file
does not exist; -2 indicates that FIL_copy() was unable to open the source file, -1 indicates
that it was impossible to create the destination file.
Example
* Very quick copy (using WIN32 CopyFile())
* Notice how the third parameter is passed with an empty string
? FIL_copy( "MYFILE.TXT","YOURFILE.TXT","",.T.)
*----------------------------------------------------------------------*
LOCAL oFocus
IF ( oFocus.Load() )
=RunCopy()
ENDIF
*----------------------------------------------------------------------*
FLLName = ""
Name = "FLL"
This.FLLName = cFLL
ENDPROC
*------------------------------------------------------------------*
PROCEDURE IsLoaded()
ENDPROC
*------------------------------------------------------------------*
IF ( PARAMETERS() == 0 )
lAdditive = .F.
ENDIF
IF ( This.IsLoaded() )
RETU ( .T. )
ENDIF
ELSE
This.FLLName = cFLL
IF ( lAdditive )
ELSE
ENDIF
RETU ( .T. )
ENDIF
ENDPROC
*------------------------------------------------------------------*
ENDDEFINE
*----------------------------------------------------------------------*
FUNCTION RunCopy()
RETURN ( NIL )
*----------------------------------------------------------------------*
Top = 104
Left = 40
Height = 98
Width = 480
DoCreate = .T.
BackColor = RGB( 192,192,192 )
Caption = "The Technology DVL Group (File copy sample)"
Icon = "devil.ico"
Name = "Form1"
PROCEDURE Activate()
LOCAL nTimes
IF ( nTimes > 0 )
ThisForm.ProgressBar.Max = nTimes
ELSE
ENDIF
ENDPROC
PROCEDURE Destroy()
ThisForm.Release
CLEAR EVENTS
ENDPROC
PROCEDURE ProgressBar.NextValue
ThisForm.ProgressBar.Value = ThisForm.ProgressBar.Value + 1
ENDIF
ENDPROC
ENDDEFINE
*----------------------------------------------------------------------*
oForm.ProgressBar.NextValue()
RETURN ( NIL )
See also
FIL_copyTimes()
Parameters
szFileIn Source file to be copied.
Returns
nTimes Number of times the callback function of FIL_copy() is about to be called. A positive number
indicates that FIL_copy() can be called. In this case the callback process of FIL_copy() will
be called nTimes ; -3 indicates that the source file does not exist; -2 indicates that
FIL_copyTimes() was unable to open the source file.
See also
FIL_copy()
Syntax
FIL_count( szFileSpec ) nFiles
Parameters
szFileSpec file specification. Ex. : "C:\MYDIR\*.*" . The function returns the number of files and
directories that match szFileSpec . The entries "." and ".." are disregarded by the
function.
Returns
nFiles Number of files that match the specification.
Example
FUNCTION IsEmptyDir( szDir )
RETURN ( FIL_count( szDir + "\*.*" ) == 0 )
By placing a colon after the file name followed by a stream, this function makes it possible to access streams.
Alias
CreateFile(), FileCreate()
Syntax
FIL_create( szFile[,nAttributes[,nShareMode[,nFlags]]] ) nHandle
Parameters
szFile file name to be created.
Value Description
FoxPro API.
0 Read-Write
1 Read-Only
2 Hidden
3 Read-Only/Hidden
4 System
5 Read-Only/System
6 System/Hidden
7 Read-Only/Hidden/System
Win32 API
0x80000000 GENERIC_READ
0x40000000 GENERIC_WRITE
nShareMode share mode. This parameter is disregarded when the function is used in conjunction with the
FoxPro API.
Value Description
0x00000001 FILE_SHARE_READ
0x00000002 FILE_SHARE_WRITE
0x00000004 FILE_SHARE_DELETE
nFlags flags and attributes. This parameter is disregarded when the function is used in conjunction with
the FoxPro API.
Value Description
0x00000001 FILE_ATTRIBUTE_READONLY
0x00000002 FILE_ATTRIBUTE_HIDDEN
0x00000004 FILE_ATTRIBUTE_SYSTEM
0x00000010 FILE_ATTRIBUTE_DIRECTORY
0x00000020 FILE_ATTRIBUTE_ARCHIVE
0x00000080 FILE_ATTRIBUTE_NORMAL
0x00000100 FILE_ATTRIBUTE_TEMPORARY
0x00000800 FILE_ATTRIBUTE_COMPRESSED
0x00001000 FILE_ATTRIBUTE_OFFLINE
Returns
nHandle file handle.
Example
#define WIN32_API 1
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
LOCAL szFile
LOCAL hFile
LOCAL OldStrategy
IF ( hFile != -1 )
FIL_write( hFile,"This string won't appear in the file, but will in the stream" )
FIL_close( hFile )
ENDIF
FIL_SetOpenStrategy( OldStrategy )
Remark
You can use the FIL_CreateHardLink() function to create hard links. A hard link is an NTFS-based link to a given
file. When you create a hard link to a file on an NTFS volume, NTFS adds a directory entry for the hard link without
duplicating the original file. By creating hard links, you can:
Create hard links that use the same file name as the original file but appear in different folders.
Create hard links that use different file names from the original file but appear in the same folder.
Create hard links that use different file names from the original file and appear in different folders.
Because a hard link is a directory entry for a file, an application can modify a file by using any of its hard links.
Applications that use any other hard link can detect the changes. However, directory entries for hard links are updated
only when a user accesses a file by using the hard link. For example, if a user opens and modifies a file by using its
hard link, and the size of the original file changes, the hard link that is used to access the file also shows the new size.
Syntax
FIL_CreateHardLink( szNewFile,szExistingFile ) lSuccess
Parameters
szNewFile new link to create
Returns
nHandle file handle.
Example
* This example shows how you can refer to FOCUS.FLL with
* a common "Shared" version: this is the hard link
&& If the shared file does not exist ... create it!
IF ( ! FILE("D:\MY_SHARE_FOCUS.FLL" ) )
ENDIF
ENDIF
Alias
FIL_scramble()
Syntax
FIL_crypt( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn file to be encrypted.
Returns
lSuccess file encrypted successfully?
Example
LOCAL nHandle
IF ( FIL_crypt( "d:\manage2100\images2100\MYFILE.TXT", ;
"d:\manage2100\images2100\MYFILE.CRYPT" ) )
? "The file was successfully crypted"
ENDIF
See also
FIL_decrypt()
Syntax
FIL_decrypt( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn file to be decrypted.
Returns
lSuccess file decrypted successfully?
See also
FIL_crypt()
Syntax
FIL_del( szFile ) lSuccess
Parameters
szFile file or directory to delete.
Returns
lSuccess file or directory successfully deleted?
Example
IF ( ! FIL_del( "C:\MYFILE.TXT" ) )
? "Attempt to delete file failed"
ENDIF
Syntax
FIL_DeleteAll( szFileSpec ) nDeleted
Parameters
szFileSpec file specification. Ex. : "C:\MYDIR\*.MSG" . Directories will not be deleted.
Returns
nDeleted number of files deleted.
Example
IF ( ! FIL_DeleteAll( "C:\MYDIR\*.TXT" ) )
? "Cannot delete all files"
ENDIF
Returns
szDrive drive qualifier.
Example
? FIL_drive( "C:\DVL\FOX\FOCUS.FLL" ) && "C:"
Alias
FIL_ExeName(), ExeName()
Syntax
FIL_exenam() szExeName
Parameters
None.
Returns
szExeName name of the current executable.
Example
? FIL_exenam()
? SYS_exenam()
? SYS( 16,0 )
Alternatives
Try SYS(16,0) to get the real .EXE name.
See also
SYS_exenam() .
Syntax
FIL_expand( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn source file to be expanded.
Returns
lSuccess .T. if operation was successful; .F. if not.
Example
IF ( ! FIL_expand( "A:\NC_CORE.EX$","F:\NC_CORE.EXE" )
WAIT WINDOW "Error" NOWAIT
ENDIF
While FIL_explore( "Desktop" ) perfectly works with Windows 95, it does not work as it under Windows NT.
Syntax
FIL_Explore( cFolder ) nError
Parameters
cFolder folder to explore.
Returns
nError if the function succeeds, the return value is the instance handle of the application that was run,
or the handle of a DDE server application.
If the function fails, the return value is then less than or equal to 32.
Example
? FIL_Explore( "Desktop" )
? FIL_Explore( "C:\" )
See also
SYS_WinExec() , SYS_ShellExecute()
Syntax
FIL_ext( szPath ) szFileExt
Parameters
szPath path to extract file extension from.
Returns
szFileExt file extension.
Example
? FIL_ext( "C:\DVL\FOX\FOCUS.FLL" ) && "FLL"
Parameters
szFileSpec file specification string.
Returns
szFile first file that matches szFileSpec . Long filenames are returned by FIL_first() and
FIL_next() .
Example
szFile = FIL_first( "*.PRG" )
IF ( ! EMPTY( szFile ) )
DO WHILE ( ! EMPTY( szFile ) )
? szFile
szFile = FIL_next()
ENDDO
ENDIF
Parameters
None.
See also
FIL_commit() .
Syntax
FIL_fndexe( szFile,szDir ) szPath
Parameters
szFile filename. This file MUST exist.
Returns
szPath path in which the given executable was found.
Example
&& This example will determine what is the program associated to a PRG file
? FIL_FndExe( GETFILE("PRG"),"" ) && "d:\microsoft visual studio\vfp98\vfp6.exe"
Comment
If the full path name specifies parent directories
"C:\SAMPLES\ORGANIZE\..\FCOPY\..\ORGANIZE\CDROM.BMP" , by applying the FIL_FullName() function, it
will become ... "C:\SAMPLES\ORGANIZE\CDROM.BMP" .
Alias
FIL_LongName(), FIL_FullPath()
Syntax
FIL_FullName( szFile ) szFullPath
Parameters
szFile a file name.
Returns
szFullPath full pathname.
Syntax
FIL_gdate( szFile,[nType] ) szDate
Parameters
szFile file whose date stamp has to be determined.
nType date stamp type : 1 = LastWrite, 2 = LastAccess, 3 = Creation. This parameter is optional. If
not specified FOCUS takes by default the LastWrite structure.
Returns
szDate file date stamp in the "YYYYMMDD" format. Use the DAT_stod() function to obtain a FoxPro
date.
Example
? FIL_gdate( "FOCUS.FLL" ) && "19950728"
See also
FIL_sdate(), FIL_gtime(), FIL_stime()
Syntax
FIL_get( szFileSpec,szWinTitle,szInitialDir,nFlags ) szFile
Parameters
szFileSpec pairs of null-terminated filter strings. The first string in each pair describes a filter (for example,
"Text Files" ), and the second specifies the filter pattern (for example, "*.TXT" ). Multiple
filters can be specified for a single item by separating the filter pattern strings with a semicolon
(for example, "*.TXT;*.DOC;*.BAK" ). The last string in the buffer must be terminated by
two NULL characters (CHR(0) ).
Filter expressions and filter patterns should be separated with NULL characters ( CHR(0) ).
OFN_ALLOWMULTISELECT Specifies that the File Name list box allows multiple
selections. (If the dialog box is created by using a private
template, the definition of the File Name list box must contain
the LBS_EXTENDEDSEL value.)
OFN_CREATEPROMPT Specifies that the dialog box function should ask whether the
user wants to create a file that does not currently exist. (This
flag automatically uses the OFN_PATHMUSTEXIST and
OFN_FILEMUSTEXIST flags.)
OFN_ENABLEHOOK Enables the hook function specified in the lpfnHook member.
OFN_ENABLETEMPLATE Causes the operating system to create the dialog box by
using the dialog box template identified by hInstance and
lpTemplateName.
OFN_ENABLETEMPLATEHANDLE Indicates that hInstance identifies a data block that contains a
preloaded dialog box template. The operating system ignores
lpTemplateName if this flag is specified.
OFN_EXTENSIONDIFFERENT Specifies that the user typed a filename extension that differs
from the extension specified by lpstrDefExt. The function does
not use this flag if lpstrDefExt is NULL.
OFN_FILEMUSTEXIST Specifies that the user can type only names of existing files in
the File Name entry field. If this flag is specified and the user
enters an invalid name, the dialog box procedure displays a
warning in a message box. If this flag is specified, the
OFN_PATHMUSTEXIST flag is also used.
OFN_HIDEREADONLY Hides the Read Only check box
OFN_NOCHANGEDIR Causes the dialog box to set the current directory back to
what it was when the dialog box was called.
OFN_NONETWORKBUTTON Hides and disables the Network button.
OFN_NOREADONLYRETURN Specifies that the returned file does not have the Read Only
check box checked and is not in a write-protected directory.
OFN_NOTESTFILECREATE Specifies that the file is not created before the dialog box is
closed. This flag should be specified if the application saves
the file on a create-nonmodify network sharepoint. When an
application specifies this flag, the library does not check for
write protection, a full disk, an open drive door, or network
protection. Applications using this flag must perform file
operations carefully, because a file cannot be reopened once
it is closed.
OFN_NOVALIDATE Specifies that the common dialog boxes allow invalid
characters in the returned filename. Typically, the calling
application uses a hook function that checks the filename by
using the FILEOKSTRING message. If the text box in the edit
control is empty or contains nothing but spaces, the lists of
files and directories are updated. If the text box in the edit
control contains anything else, nFileOffset and nFileExtension
are set to values generated by parsing the text. No default
extension is added to the text, nor is text copied to the buffer
specified by lpstrFileTitle.
Returns
szFile file(s) that has (have) been chosen.
Example
* Searching the current directory (normal interface)
? FIL_get( "Wave files" + CHR(0) + "*.WAV" + CHR(0) + ;
"All files" + CHR(0) + "*.*" + CHR(0) + CHR(0), ;
"FIL_get() interface" , ;
"." , ;
0 )
IF ( ! EMPTY( m.szFiles ) )
&& If multiple files have been selected, then we have a string that
&& is tokenized (" " being the separator).
&& The first token of the string is the directory from which the files
&& where selected. All the other tokens are the real files. Please
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 158
File Functions
&& notice that the function returns short filenames => a space
&& cannot occur in the middle of a name ... otherwise we would be
&& confused trying to extract each file with our token functions
m.szOldSep = STR_SetSep( " " )
Parameters
szFile file whose attribute has to be changed.
Returns
nAttribute file attribute or -1 if error. Attribute values can be mixed.
If function returns a value of 3, that means that the file is READ-ONLY ( 1) and is HIDDEN (2)
because 1 + 2 = 3
File system directories that the shell uses for specific purposes are also considered special folders. Examples include
the Programs folder (which contains the user's program groups) and the desktop directory (which is used to physically
store files that have been copied to the desktop folder). The locations of special file system folders are stored in the
registry under the HKEY_CURRENT_USER\Software\
Microsoft\Windows\CurrentVersion\Explorer\Shell Folders key.
You can use the SHGetSpecialFolderLocation() function to retrieve the location of a special folder, which can
be virtual or part of the file system. The function returns a PIDL, which the application must eventually free using the
shell's allocator. If the folder is part of the file system, you can convert the PIDL to a file system path by using the
SHGetPathFromIDList() function. The SHGetPathFromIDList() function converts an item identifier list to a file
system path :
WINSHELLAPI BOOL WINAPI SHGetPathFromIDList( LPCITEMIDLIST pidl ,
LPSTR pszPath
);
Parameters
pidl Pointer to an item identifier list that specifies a file or directory location relative to the root of the name
space (the desktop).
PszPath Pointer to a buffer that receives the file system path. The size of this buffer is assumed to be MAX_PATH
bytes.
Return Value
Returns TRUE if successful or FALSE if an error occurs, for example, if the location specified by the pidl parameter is
not part of the file system.
To display a dialog box that enables the user to browse for a folder, you can use the SHBrowseForFolder()
function. An application might use this function to prompt the user for a directory or remote computer. This function
can also be used to browse for network printers, even though printers are not considered folders. An application can
specify the root folder to browse from. For example, to prompt the user for a program group, you might call
SHBrowseForFolder() specifying the PIDL for the Programs folder as the root.
This function is the one you should use in order to locate the Recycle bin !
Syntax
FIL_GetFolderLocation( nFolderType ) szFullPath
Parameters
nFolderType folder type.
Returns
szFullPath full pathname.
Example
? FIL_GetFolderLocation(2) && C:\WINDOWS\Start Menu\Programs
? FIL_GetFolderLocation(5) && C:\My Documents
Syntax
FIL_gets( nHandle,nBytes ) szLine
Parameters
nHandle file handle.
nBytes optional number of bytes to read per line. By default, this parameter is set to 254.
Returns
szLine the line of text as it was read from the file.
Syntax
FIL_GetStdin( nChars ) szString
Parameters
nChars number of characters to read from the standard input device. If there is no more character to
read from stdin BEFORE the function has read nChars characters, the function stops.
Returns
szString the characters read from stdin
See also
FIL_PutStdout()
The specified integer can be nonzero, in which case, the function creates the filename but does not create the file. If
you specify zero for the integer, the function creates a unique filename and creates the file in the specified directory.
Syntax
FIL_GetTempFileName( szPathName , ;
szPrefixString, ;
nUnique ) szTempFileName
Parameters
szPathName points to a null-terminated string that specifies the directory path for the filename. This string
must consist of characters in the ANSI character set. Applications typically specify a period (.)
or the path where Windows is supposed to store temporary files.
szPrefixString points to a null-terminated prefix string. The function uses the first three characters of this
string as the prefix of the filename. This string must consist of characters in the ANSI character
set.
nUnique specifies an unsigned integer that the function converts to a hexadecimal string for use in
creating the temporary filename.
If nUnique is zero, the function uses a hexadecimal string derived from the current system
time. In this case, the function uses different values until it finds a unique filename, and then it
creates the file in the szPathName directory.
Component Meaning
path Path specified by the szPathName parameter
pre First three letters of the cPrefixString string
uuuu Hexadecimal value of nUnique
When Windows shuts down, temporary files whose names have been created by this
function are not automatically deleted.
Returns
szTempFileName if the function succeeds, the return value is the name of the temporary file. Otherwise, the
function returns an empty string.
Remark
The string that is returned expresses the fullpath specification when tried on Windows 95. It returns a relative pathway
when it ran on Windows NT 4.0:
"D:\MEGA32\PAT8390.TMP" on Win95
".\PAT8390.TMP" on Win NT
Example
? FIL_GetTempFileName( ".","PAT",0 ) && "D:\MEGA32\PAT8390.TMP"
Alias
FIL_UniversalName(), GetUniversalName(), UniversalName(), NET_GetUniversalName(),
NET_GetConnection()
Syntax
FIL_GetUniversalName( szDrive ) szUniversal
Parameters
szDrive a mapped drive.
Returns
szUniversal universal resource name.
Example
&& Imagine for example that on the WebServer computer (machine name) there is
&& a SRCServer directory that is shared and accessible via the SRCServer Share Name.
&& Imagine this resource to be mapped to the E:\ drive. Then the FIL_GetUniversalName()
Syntax
FIL_gtime( szFile,[nType] ) cTime
Parameters
szFile file whose time stamp has to be determined.
nType time stamp type: 1 = LastWrite (default), 2 = LastAccess, 3 = Creation. This parameter is
optional. If not specified FOCUS takes by default the LastWrite structure.
Returns
cTime file time stamp.
Example
? FIL_gtime( "FOCUS.FLL" ) && "12:40:52"
See also
FIL_stime(), FIL_gdate(), FIL_sdate()
Syntax
FIL_hleft() nFiles
Parameters
None.
Returns
nFiles remaining free handles.
Syntax
FIL_i?time() nTime
Parameters
None.
Returns
nTime the time is mentioned as Universal Coordinated Time. Make a call to either TIM_gmT() or
TIM_localT() to get a string result like "12:03:34"
Example
IF ( FIL_info( "AUTOEXEC.BAT" ) )
? "Creation time : ",TIM_localT( FIL_ictime() )
ENDIF
Caution
You first have to make a call to FIL_info() for this function to work properly.
Parameters
szSource existing file to be copied to szTarget .
lFailIfExist flag for operation if file exists. If this parameter is .T. and the new file already exists, the
function fails. If this parameter is .F. and the new file already exists, the function overwrites
the existing file and succeeds.
Returns
lSuccess .T. if copy is successful; .F. if not.
Parameters
szFile file for which you want to get information.
Upon return, an internal structure of FOCUS is updated. You can query information from this
structure with other functions like FIL_isize() , FIL_imtime() , FIL_iatime() , and
FIL_ictime() .
Example
IF ( FIL_info( "AUTOEXEC.BAT" ) )
? "Creation time : ",FIL_ictime()
? "Last modification time : ",FIL_imtime()
? "File size : ",FIL_isize()
ENDIF
Parameters
szFile file name.
Returns
lStatus .T. if file is archived; .F. otherwise.
Parameters
nHandle file handle.
Returns
lStatus is the given file at Begin Of File position?
Example
LOCAL nHandle
Parameters
szFile file name.
Returns
lStatus .T. if file is a compressed file; .F. otherwise.
Parameters
szFile the directory to check for existence.
Returns
lIsDir .T. if file is marked with directory flag; .F. otherwise.
Syntax
FIL_iseof( nHandle ) lStatus
Parameters
nHandle file handle.
Returns
lStatus is the given file at End Of File position?
Example
LOCAL nHandle
Parameters
szFile the file whose existence has to be checked.
Returns
lSuccess .T. if file exists; .F. if not.
Parameters
szFile file name.
Returns
lStatus .T. if file is hidden; .F. otherwise.
Parameters
None.
Returns
nSize file size in bytes.
Example
IF ( FIL_info( "AUTOEXEC.BAT" ) )
? "File size : ",FIL_isize(),"bytes"
ENDIF
Caution
You first have to make a call to FIL_info() for this function to work properly.
Returns
lStatus .T. if file is normal; .F. otherwise.
Parameters
szFile file name.
Returns
lStatus .T. if file is the read only mode; .F. otherwise.
Syntax
FIL_IsShared( szDir ) lStatus
Parameters
szDir directory name.
Returns
lStatus .T. if file is a shared directory; .F. otherwise.
Example
? FIL_IsShared( "D:\INVOICES" ) && .F.
? FIL_IsShared( "C:\" ) && .T.
Parameters
szFile file object name.
Returns
lShortcut .T. if file is a shortcut; .F. otherwise.
Parameters
szFile file name.
Returns
lStatus .T. if file is a system file; .F. otherwise.
Parameters
szFile file name.
Returns
lStatus .T. if file is a temporary file; .F. otherwise.
Parameters
szPath path to consider.
Returns
lIsUNC .T. if szPath is a valid UNC path; .F. otherwise.
Syntax
FIL_LastVersion() szLastVersion
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\FILES.C-Mon Oct 19 15:55:22 1998" .
Handles that are returned by the FIL_open() function when the Win32 API has been selected cannot be used by
low-level functions of FoxPro such as FWRITE() , FCLOSE() and the likes.
FIL_len() and FIL_size() are identical from the functionality point of view although they're using very different
methods to determine a file's size. The first one operates on a handle, while the second one operates with a filename.
Syntax
FIL_len( nHandle ) nSize
Parameters
nHandle file handle.
Returns
nSize size of file in bytes.
Example
LOCAL nHandle
LOCAL OldStrategy
OldStrategy = FIL_SetOpenStrategy( 2 )
nHandle = FOPEN( "C:\TEST.PRG" )
? FIL_len( nHandle )
FCLOSE( nHandle )
FIL_SetOpenStrategy( OldStrategy )
See also
FIL_size() .
Syntax
FIL_LenCompressed( szFile ) nLength
Parameters
szFile file name to determine the length of.
Returns
nLength length of the file.
Example
IF ( ! FIL_SetCompression( "MYFILE.TXT",.T. ) )
WAIT WINDOW "Cannot compress file"
ELSE
&& Displays the length of the file (compressed size)
? FIL_LenCompressed( "MYFILE.TXT" )
ENDIF
See also
FIL_IsCompressed(), FIL_SetCompression(), FIL_len()
Parameters
szDir directory to create.
Returns
lSuccess .T. if operation was successful, .F. otherwise.
Example
IF ( ! FIL_mkdir( "Hello World" ) )
? "Directory creation failed."
ENDIF
Returns
szFile file name.
Example
? FIL_name( "C:\DVL\FOX\FOCUS.FLL" ) && "FOCUS"
Parameters
None.
Returns
szFile next instance. Long filenames are returned by FIL_first() and FIL_next() .
Example
szFile = FIL_first( "*.PRG" )
IF ( ! EMPTY( szFile ) )
DO WHILE ( ! EMPTY( szFile ) )
? szFile
szFile = FIL_next()
ENDDO
ENDIF
FIL_now() makes it very easy to get a filename that is most likely to be unique (although strictly speaking a file with
the same name might already be existing) and that can be used to store sequential information. For example, each
time that a log file is internally compressed by the LOG_*() functions of FOCUS, the resulting file is named by a call
to FIL_now() .
FIL_now() does not create any file but the FIL_CreateNow() does!
Alias
FIL_CreateNow(), TIM_now(), DAT_now(), STR_now(), Now()
Syntax
FIL_now() szFile
FIL_CreateNow( szDir ) szFile
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 173
File Functions
Parameters
szDir FIL_now() takes no parameter but its alias FIL_CreateNow() does. szDir indicates the
directory where the NOW file has to be created. In the case of the FIL_CreateNow()
function/alias, the file is also created under the szDir directory. It should be noted that the
FIL_CreateNow() always adds a backslash at the end of szDir before concatenating it with
szFile .
Returns
szFile resulting filename. The FIL_CreateNow() function gets the full path spec or an empty string
if the file couldn't be created. If the file was already existing, it is overwritten.
Example
? FIL_now() && "199810291721330030346194"
? FIL_CreateNow( "C:"
Handles that are returned by the FIL_open() function when the Win32 API has been selected cannot be used by
low-level functions of FoxPro.
By placing a colon after the file name followed by a stream, this function makes it possible to access streams.
Alias
OpenFile(), FileOpen()
Syntax
FIL_open( szFile,nFlag,nShareMode ) nHandle
Parameters
szFile file name to be opened.
nFlag the meaning of this parameter is different based on the API that's about to be used.
Value Description
FoxPro API.
0 Read Only
1 Write Only
2 Read Write
Win32 API
0x80000000 GENERIC_READ
0x40000000 GENERIC_WRITE
nShareMode this parameter is disregarded when used in conjunction with the FoxPro API.
Value Description
Returns
nHandle file handle.
With this function you can actually test if there is a reasonable chance to open a file in SHARED mode. If there is, you
can then try to open it with USE <dbf> . Of course, nothing is preventing other programs from opening the file in
EXCLUSIVE mode between the moment you issue the FIL_OpenFile() function and the moment you will execute
the USE <dbf> command. That's the reason why we speak about a reasonable chance.
Syntax
FIL_OpenFile( szFile ) lSuccess
Parameters
szFile file to open in SHARED mode (SHARED read, and SHARED write).
Returns
lSuccess .T. if we successfully opened the file; .F. if not.
Example
IF ( FIL_OpenFile( "C:\DATA\MY.DBF" ) )
USE "C:\DATA\MY.DBF" SHARED
ELSE
? "Cannot open C:\DATA\MY.DBF"
ENDIF
Syntax
FIL_Owner( szFile ) szOwner
Parameters
szFile file to consider.
Returns
szOwner owner of the file.
IF ( ! EMPTY( m.szOwner ) )
? "The owner of the file is",m.szOwner
ELSE
? "Cannot obtain owner name:",FIL_LastError()
ENDIF
Parameters
szPath the full path to extract the pathname from.
Returns
szPath path.
Example
? FIL_path( "C:\DVL\FOX\FOCUS.FLL" ) && "C:\DVL\FOX"
Syntax
FIL_puts( nHandle,szString ) nBytes
Parameters
nHandle file handle.
Returns
nBytes number of bytes written to the file.
Syntax
FIL_PutStdout( szString ) lSuccess
Parameters
szString the string to output to the standard output device.
Returns
lSuccess .T. if szString was successfully output to the standard output; .F. if not.
See also
FIL_GetStdin()
Syntax
FIL_read( nHandle,nBytes ) szData
Parameters
nHandle file handle.
Returns
szData the data as it was read from the file. If the file couldn't be read, the function returns an empty
string.
Syntax
FIL_ReadAllSections( szIniFile ) szSections
Returns
szSections all sections of the .INI file. Sections are separated by each other with a semicolon (";").
See also
FIL_sectio()
Syntax
FIL_ReadSub( nHandle,nStart,nBytes ) szData
Parameters
nHandle file handle.
nStart starting position to read from. The first position in the file is 1.
Returns
szData the data as it was read from the file. If the file couldn't be read, the function returns an empty
string.
Parameters
None.
Returns
szSections a buffer with all sections separated with a ";" .
Syntax
FIL_reaini( szSection,szEntry,szIniFile ) szValue
Parameters
szSection section of .INI file.
Returns
szValue string pertaining to entry.
Example
IF ( FIL_reaini( "SECRET","PassWord","MY.INI" ) != szPassWord )
? "Wrong password !"
ENDIF
Syntax
FIL_rename( szSource,szTarget ) lSuccess
Parameters
szSource file name to rename.
Returns
lSuccess operation successful or not?
Example
&& Under Windows 95 this code will change the case
&& of the file. If the exact filename was "Test.c", it will
&& now be changed to "TEST.C"
IF ( FIL_rename( "C:\TEST.C","C:\TEST.C") )
? "File renamed successfully"
ELSE
? "Operation failed"
ENDIF
Parameters
szSource file name or directory name to be renamed.
Returns
lSuccess operation successful or not?
Example
IF ( FILE( szToBeSaved ) )
? "This file already exists. Do you want to rename it?"
m.lAnswer = MIS_yesno()
IF ( m.lAnswer )
ACCEPT "Enter new file name" TO szNewName
IF ( ! FIL_rendir( szToBeSaved,szNewname ) )
? "Attempt to rename file failed !"
ENDIF
ENDIF
ENDIF
See also
FIL_del() , FIL_rename() , FIL_rmdir() .
Parameters
szPath directory to be removed.
Returns
lSuccess operation successful or not?
Example
IF ( ! FIL_rmdir( "C:\DVL" ) )
? "Cannot remove directory. Check if empty."
ENDIF
See also
FIL_del() , FIL_rename() , FIL_rendir() .
Parameters
szFile pairs of null-terminated filter strings. The first string in each pair describes a filter (for example,
"Text Files" ), and the second specifies the filter pattern (for example, "*.TXT" ). Multiple
filters can be specified for a single item by separating the filter pattern strings with a semicolon
(for example, "*.TXT;*.DOC;*.BAK" ). The last string in the buffer must be terminated by
two NULL characters (CHR(0) ).
Filter expressions and filter patterns should be separated with NULL characters ( CHR(0) ).
nFlags dialog box flags. Please refer to the values described for the FIL_get() function.
Returns
szFile file that has been chosen.
Example
* Saving a file
? FIL_save( "Wave files" + CHR(0) + "*.WAV" + CHR(0) + ;
"All files" + CHR(0) + "*.*" + CHR(0) + CHR(0), ;
"Mention your file" , ;
"." , ;
0 )
Syntax
FIL_sdate( szFile,szDate,[nType] ) lSuccess
Parameters
szFile file whose date stamp has to be set.
nType date stamp type: 1 = LastWrite, 2 = LastAccess, 3 = Creation. This parameter is optional. If not
specified FOCUS takes by default the LastWrite structure.
Returns
lSuccess .T. if operation was successful, .F. otherwise.
Example
? FIL_sdate( "MYFILE.TXT",DTOS( DATE() ),1 ) && .T.
See also
FIL_gdate(), FIL_gtime(), FIL_stime()
Parameters
szSection section to read.
Returns
szEntries all entries for given section. Up to 1024 bytes. Each entry is separated by a ";".
Example
? "Wallpaper settings",FIL_sectio( "wallpaper","myapp.ini" )
See also
FIL_ReadAllSections()
Syntax
FIL_seek( nHandle,nOffset,nStrategy ) nPosition
Parameters
nHandle file handle as returned by the FIL_open() function..
Value Description
0 The pointer is moved relative to the beginning of the file
1 The pointer is moved relative to the current position in the file.
2 The pointer is moved relative to the end of the file
Returns
nPosition number of bytes the file pointer is positioned from the beginning of the file.
See also
FIL_IsEOF() , FIL_IsBOF() , FIL_SetOpenStrategy()
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Example
Here is an example for hiding a file
FIL_setatt( "MYFILE.CFG",2 )
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Comment
The FIL_sethan() function is not necessary under the Windows NT implementation of Win32.
The FIL_sethan() function may be necessary under other implementations of Win32, such as Win32s, in order to
increase the default number of available file handles. Under Win32s, this default is 20.
Internal Call
SetHandleCount()
Syntax
FIL_sethan( nHandles ) nHandlesSet
Returns
nHandlesSet under Win32s, the return value specifies the number of file handles actually available to the
application. It may be fewer than the number specified by the nHandles parameter.
Example
IF ( FIL_sethan( 65 ) < 65 )
? "You must free file handles to run this application."
ENDIF
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Syntax
FIL_SetCompression( szFile,lCompression ) lSuccess
Parameters
szFile file name.
Example
IF ( ! FIL_SetCompression( "MYFILE.TXT",.T. ) )
WAIT WINDOW "Cannot compress file"
ELSE
&& Displays the length of the file (compressed size)
? FIL_LenCompressed( "MYFILE.TXT" )
ENDIF
See also
FIL_IsCompressed(), FIL_LenCompressed(), FIL_len()
Syntax
FIL_SetOpenStrategy( [nStrategy] ) nCurrentStrategy
Parameters
nStrategy strategy to use (1=Win32 API; 2=FoxPro API). This parameter is optional. When it is not
passed, the function simply returns the current status. When you use the
FIL_GetOpenStrategy() , this parameter may not be passed along.
Returns
nCurrentStrategy current strategy as it was set prior to enter in the function.
Example
LOCAL nHandle
LOCAL nStrategy
******************************************************************
* The following example opens a file thanks to the Win32 API, and
* reads each line of text and displays it.
******************************************************************
#define STRA_WIN32API 1
#define STRA_FOXPROAPI 2
#define INVALID_HANDLE -1
IF ( nHandle != INVALID_HANDLE )
DO WHILE ( ! FIL_iseof( nHandle ) )
? FIL_gets( nHandle )
ENDDO
FIL_close( nHandle )
&& Restore the Strategy to what it was prior entering this function
FIL_SetOpenStrategy( nStrategy )
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile file whose attribute has to be changed.
Returns
lSuccess function successful or not?
Parameters
szFile long filename to be transformed.
Example
&& We emphasized in bold the long pathname part
szPath = "D:\CSERVE\DOWNLOAD\MICROSOFT FORUMS\FORUMS.TXT"
Syntax
FIL_size( szFile ) nSize
Parameters
szFile file name.
Returns
nSize size of file in bytes.
See also
FIL_len() .
Parameters
szFile file to cut into smaller slices.
Returns
nSlices number of slices used (= FileSize / nSliceSize + 1 ). The output files are named
OUTPUT.1 , OUPUT.2 , ... up to OUTPUT.<nSlices> . These OUPUT files are created in the
current directory. The function is very useful when you need to cut a file to be duplicated on
several floppy disks.
Example
&& This example is supposed to divide the BIGFILE.ZIP file
&& into different smaller files, each of 200000 bytes, except
&& the last one that may be smaller (rest of the file)
FOR i = 1 TO nSlices
? FILE( "OUTPUT." + ALLTRIM( STR( i ) ) )
NEXT
Syntax
FIL_split( szFile,nComponent ) szComponent
Parameters
szFile filename to split.
Value Description
1 Drive
2 Directory
3 Filename without the extension
4 Extension including the dot separator
Returns
szComponent appropriate file component.
Example
? FIL_split( "C:\DVL\FOCUS.FLL",1 ) && "C:"
? FIL_split( "C:\DVL\FOCUS.FLL",2 ) && "\DVL\"
? FIL_split( "C:\DVL\FOCUS.FLL",3 ) && "FOCUS"
? FIL_split( "C:\DVL\FOCUS.FLL",4 ) && ".FLL"
Syntax
FIL_stime( szFile,szTime,[nType] ) lSuccess
Parameters
szFile file whose time stamp has to be set.
nType time stamp type: 1 = LastWrite, 2 = LastAccess, 3 = Creation. This parameter is optional. If not
specified FOCUS.FLL takes by default the LastWrite structure.
Returns
lSuccess .T. if operation was successful, .F. otherwise.
See also
FIL_sdate(), FIL_gdate(), FIL_gtime()
Parameters
szFile file in which will be written (the file is ALWAYS created).
Returns
lSuccess .T. if operation was successful, .F. otherwise.
Example
&& Example #1
? FIL_StringToFile( "C:\MYFILE.TXT","This is the text" )
&& Example #2
LOCAL szWeb
LOCAL szNum
LOCAL szExt
&& This example will extract an image from FastWrite's web site. The image is
&& returned as a string. Then, the string is saved to a file thanks to
&& FIL_StringToFile() and finally, the background picture of VFP is set to the
&& newly created image file
szWeb = "http://www.fastwrite.com/products/focus/Banners/Banner"
szNum = "001"
szExt = ".jpg"
szPath = "O:\SPOT2000"
Syntax
FIL_tell( nHandle ) nCurrentPos
Returns
nCurrentPos current position of file pointer.
Example
LOCAL nCurrent
LOCAL nEnd
LOCAL nHandle
<...>
nCurrent = FIL_tell( nHandle ) && Save current file pointer
&& position
nEnd = FIL_seek( nHandle,0,2 ) && set file pointer at EOF
Parameters
szDisk disk whose directory tree is to be returned.
nBufferLength indicates which space should be reserved to store the resulting string.
Requesting a disk tree is a time consuming process. This function may need dozens of seconds
to complete. Also the returning string may be huge. Therefore, it's the programmer's
responsibility to mention the memory he's keen to reserve for the operation.
Returns
szTree a string in the form of:
"J:\RECYCLED;J:\FAILSAFE.DRV;J:\FAILSAFE.DRV\FAILSAFE;J:\FAILSAFE.DRV\
COMMAND;J:\FAILSAFE.DRV\WINDOWS;J:\FAILSAFE.DRV\DRV;"
Example
? FIL_Tree( "J:",5000 )
Syntax
FIL_type( szFile ) nType
Parameters
szFile file name.
Value Description
0 The type of the specified file is
unknown
1 The specified file is a disk file
2 The specified file is a character file,
typically an LPT device or a console
3 The specified file is either a named or
anonymous pipe
-1 Cannot open the given file
Example
? FIL_type( "LPT1" ) && 2
Syntax
FIL_unzip( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn the file to be uncompressed.
Returns
lSuccess .T. indicates that the file was uncompressed successfully; .F. otherwise.
Example
IF ( ! FIL_unzip( "MYFILE.CMP","MYFILE.TXT" ) )
? "An error occurred while uncompressing the file"
ENDIF
See also
FIL_zip().
Syntax
FIL_where( szFile,szEnvironment ) szFullPath
szEnvironment environment variable. Pay attention to the fact that environment variables are case
sensitive!
Returns
szFullPath full path where szFile was found. If szFile isn’t found in the directory set specified in the
szEnvironment ... environment variable, a null string is returned.
Example
LOCAL szExcel
IF ( EMPTY( m.szExcel ) )
&& Consider using FIL_get() rather than GETFILE()
&& in Visual FoxPro
m.szExcel = GETFILE( "EXE","Where is EXCEL.EXE?","Browse",1 )
ENDIF
Syntax
FIL_wipe( szFile ) lSuccess
Parameters
szFile file to wipe out.
Returns
lSuccess .T. if the whole file was written; .F. if not.
Example
&& If you're trying to cheat
IF ( lCheating )
FIL_wipe( "myconfig.dll" )
ENDIF
Parameters
szSection section of WIN.INI.
Returns
szString string pertaining to entry.
Example
IF ( FIL_wreain( "MYAPP","PassWord" ) <> cPassWord )
? "Wrong password !"
ENDIF
Syntax
FIL_wriini( szSection,szEntry.NULL.,szString.NULL.,szIniFile ) lSuccess
Parameters
szSection section of the .INI file to write to.
szEntry key name that appears under the section name. If this parameter is a .NULL. , the section is
deleted from the .INI file.
szString string to write to .INI file. If this parameter is a .NULL. , the entry is deleted from the .INI
file.
Returns
lSuccess .T. if writing is successful; .F. if not.
Example
IF ( ! FIL_wriini( "WALLPAPER" , ;
"Fill file" , ;
"FILLER.BMP", ;
"MYAPP.INI" ;
) ;
)
? ".INI update failed"
ENDIF
Syntax
FIL_write( nHandle,szString[,nBytes] ) nWritten
Parameters
nHandle file handle.
nBytes number of bytes to write. This parameter is optional. When not passed, the entire string is
written to the file.
Returns
nWritten number of bytes actually written to the file
Parameters
szSection section to read.
Returns
cEntries all entries for given section.
Example
? "Printer list",FIL_wsecti( "devices" )
Parameters
szSection section of WIN.INI.
Example
IF ( ! FIL_wwriin( "MYAPP" , ;
"Desktop" , ;
"640 480 256" ;
) ;
)
? ".INI update failed"
ENDIF
Syntax
FIL_zip( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn the file to be compressed.
Returns
lSuccess .T. indicates that the file was compressed successfully; .F. otherwise.
Example
IF ( ! FIL_zip( "MYFILE.TXT","MYFILE.CMP" ) )
? "An error occurred while compressing the file"
ENDIF
See also
FIL_unzip().
Parameters
None.
Returns
szLastError last error that occurred when using FIL_zip() or FIL_unzip() .
FTP Functions
Functions Synopsis
The Internet has changed the way we build applications. Internet technologies and techniques are still in their infancy
but they promise to dramatically affect our applications in general ... NOW. This is not a question of Internet Browsers
but much more deeply a way we will need to interact with resources. This world of connected computers require to get
tools that make it possible to access databases, tables and files anywhere. As such, FOCUS.FLL needed to give the
Visual FoxPro developer the tools to keep in touch with the natural evolution of modern software. That's why we have
made this FTP2 category of functions available to you, the Visual FoxPro Developer.
FTP is another member of the TCP/IP family whose sole purpose was to make it possible to transfer files between
different computer types and different formats. That's why a common protocol such as FTP was born.
FTP functions of FOCUS.FLL are very similar to File functions and you will feel very comfortable with them
FTP Basics
FTP Servers ask for a user login and password. This login information (username + password) is assigned to you by
the Administrator of the FTP Server. Anonymous login is also possible. It provides access to directories of the server to
the public. Anonymous FTP access is performed with .NULL. values in FOCUS.FLL (See the FTP_OpenSession()
function).
Once connected to a FTP site, you need to navigate directories in order to locate the file you want to download. Once
the file has been located, you usually set the transfer mode, either binary or ASCII. With FOCUS.FLL , there is no
need to do this since the binary mode is automatically used as it can be used for ASCII files as well.
In between these 2 starting and ending calls , you simply use all the operations you are acquainted with:
directory creation, renaming, deletion
All FTP functions of FOCUS.FLL are built on the Synchronous model for the sake of convenience. Although more
powerful, asynchronous operations are also much more complex to deal with. Therefore, we have taken the decision to
first introduce synchronous operations ONLY.
FTP Sessions are separate processes. Therefore you cannot use one session with another, even though both sessions
are pointing to the same FTP site. For your convenience, FOCUS.FLL can deal with 10 simultaneous FTP sessions.
So ... for example, if you open an FTP session with the following parameters, you should have access to a specific
directory on our server:
IF ( nFTPHandle >= 0 )
<... more FTP operations here>
FTP_CloseSession( nFTPHandle )
ENDIF
2
File Transfer Protocol
IF ( nFTPHandle >= 0 )
<... more FTP operations here>
FTP_CloseSession( nFTPHandle )
ENDIF
IF ( nFTPHandle >= 0 )
? "Current FTP dir:", FTP_GetCurrentDirectory( nFTPHandle )
FTP_CloseSession( nFTPHandle )
ENDIF
3. Creating a directory
IF ( nFTPHandle >= 0 )
IF ( ! FTP_CreateDirectory( nFTPHandle,"MyDir" ) )
? "Cannot create directory",FTP_LastError()
ELSE
? "Directory successfully created"
ENDIF
FTP_CloseSession( nFTPHandle )
ENDIF
IF ( nFTPHandle >= 0 )
IF ( ! FTP_GetFile( nFTPHandle,"index.htm","c:\myNewIndex.htm" )
? "Cannot retrieve file",FTP_LastError()
ELSE
? "File successfully downloaded"
ENDIF
FTP_CloseSession( nFTPHandle )
ENDIF
IF ( nFTPHandle >= 0 )
IF ( ! FTP_PutFile( nFTPHandle,"C:\MYLOCALFILE.TXT","PUBLICFILE.TXT" )
? "Cannot upload file",FTP_LastError()
ELSE
? "File successfully uploaded"
ENDIF
FTP_CloseSession( nFTPHandle )
ENDIF
Parameters
None.
Returns
lSuccess .T. if all active sessions are closed successfully; .F. otherwise.
Example
LOCAL nFTP1
LOCAL nFTP2
IF ( ! FTP_CloseAllSessions() )
? "Some FTP sessions could not be closed"
ENDIF
Parameters
nFTPHandle FTP session handle.
Returns
lSuccess .T. if the session is successfully closed; .F. otherwise.
Example
nFTPHandle = FTP_OpenSession( "ftp.fastwrite.com","focusfll","ftpfunctions" )
FTP_CloseSession( nFTPHandle )
Parameters
nFTPHandle FTP session handle.
Returns
lSuccess .T. if szDirectory was successfully created; .F. otherwise.
Parameters
nFTPHandle FTP session handle.
Returns
lSuccess .T. if the file has been successfully deleted; .F. otherwise.
Syntax
FTP_GetCurrentDirectory( nFTPHandle ) szDirectory
Parameters
nFTPHandle FTP session handle.
Returns
szDirectory current directory.
Parameters
nFTPHandle FTP session handle.
Returns
lSuccess .T. if szSource has successfully retrieved and stored locally; .F. otherwise.
Parameters
nFTPHandle FTP session handle.
szSpec string that specifies a valid directory path or file name for the FTP server's file system. The
string can contain wildcards, but no blank spaces are allowed.
Returns
szFile the name of the first file in the directory of the FTP site or an empty string ( "") if no file can be
found.
Example
nFTPHandle = FTP_OpenSession( "ftp.fastwrite.com","focusfll","ftpfunctions" )
szFile = FTP_FindFirstFile( nFTPHandle,"*.*" )
FTP_CloseSession( nFTPHandle )
Parameters
nFTPHandle FTP session handle.
Returns
szFile the name of the next file in the directory of the FTP site or an empty string ( "") if no file can be
found.
Example
nFTPHandle = FTP_OpenSession( "ftp.fastwrite.com","focusfll","ftpfunctions" )
szFile = FTP_FindFirstFile( nFTPHandle,"*.*" )
FTP_CloseSession( nFTPHandle )
Syntax
FTP_HandlesCount() nFTPHandles
Parameters
None.
Returns
nFTPHandles maximum number of FTP handles.
Parameters
None.
Returns
szLastError last error that occurred while using the FTP_*() functions.
Syntax
FTP_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"D:\Focus\6.0\ftp.c-Sun Aug 13 15:25:06 2000".
Example
? FTP_LastVersion()
Parameters
None.
Returns
nFTPHandle highest potential handle.
Example
nFTPHandle = FTP_OpenSession( "ftp.fastwrite.com","focusfll","ftpfunctions" )
FTP_CloseSession( nFTPHandle )
Parameters
None.
Returns
nFTPHandle lowest potential handle.
Example
nFTPHandle = FTP_OpenSession( "ftp.fastwrite.com","focusfll","ftpfunctions" )
FTP_CloseSession( nFTPHandle )
Parameters
szFTPSite FTP session server: a string that forms a valid IP address or a valid host name.
Returns
nFTPHandle FTP session handle. This number MUST be greater or equal to than FTP_MinHandle() and
less than or equal to FTP_MaxHandle() . Error situations:
Value Description
-1 No FTP handle left
-2 No FTP connection. Use FTP_LastError() to have a more precise idea of
the error type.
-3 No Internet connection. Use FTP_LastError() to have a more precise idea
of the error type.
-4 Invalid szUserName parameter
-5 Invalid szPassword parameter
Example
nFTPHandle = FTP_OpenSession( "ftp.fastwrite.com","focusfll","ftpfunctions" )
FTP_CloseSession( nFTPHandle )
Parameters
nFTPHandle FTP session handle.
Returns
lSuccess .T. if the file has been successfully uploaded; .F. otherwise.
Syntax
FTP_RemoveDirectory( nFTPHandle,szDir ) lSuccess
Parameters
nFTPHandle FTP session handle.
Returns
lSuccess .T. if the directory has been successfully removed; .F. otherwise.
Syntax
FTP_RenameFile( nFTPHandle,szSource,szTarget ) lSuccess
Parameters
nFTPHandle FTP session handle.
szSource name of the file that will have its name changed on the remote FTP site.
Returns
lSuccess .T. if the file has been successfully renamed; .F. otherwise.
Syntax
FTP_SetCurrentDirectory( nFTPHandle,szDir ) lSuccess
Parameters
nFTPHandle FTP session handle.
szDir name of the directory to change to on the remote system. This can be either a fully qualified
path or a name relative to the current directory.
Returns
lSuccess .T. if the function was successful; .F. otherwise.
Graphical/GDI Functions
Functions Synopsis
FOCUS.FLL provides some useful GDI functions (Graphic Device Interface) which are not provided by Visual FoxPro,
even though accessible via the Win32 API. A companion OCX also exists: FOCUSGDI that is distributed separately.
In particular, FOCUS.FLL makes it possible to create outstanding splash screens thanks to the Region functions. In
the following documentation, the user will find real examples that we did program for our own needs.
Parameters
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
nRight specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
Please notice that for the region to take effect, you must attach it to the form with
GDI_SetWindowRegion() .
Returns
hRegion the handle to a GDI region if the function is successful; 0 if the function failed.
Example
LOCAL nTop, nLeft, nBottom, nRight
&& Obtain the window handle and assign it to a property that we have defined
.hWnd = WIN_hwnd( This.caption )
&& The width of the form is EXACTLY the width of the image
.Width = .imgBackground.Width
&& The height of the form is EXACTLY the height of the image
.Height = .imgBackground.Height
DODEFAULT()
ENDWITH
The example of above creates the an elliptical form. The elliptical form is created thanks to a to the
GDI_CreateEllipticRegion() function; then the region is attached to the form ( GDI_SetWindowRegion() ).
To beautify the presentation of the form, we have created a JPG file that fills perfectly the ellipse.
Syntax
GDI_CreatePolygonalRegion( @aPoints,nMode ) hRegion
Parameters
aPoints an array of x,y coordinates.
nMode specifies the filling mode of the polygon: 1 for alternate; 2 for winding.
Please notice that for the region to take effect, you must attach it to the form with
GDI_SetWindowRegion() .
Returns
hRegion the handle to a GDI region if the function is successful; 0 if the function failed.
Example
&& INIT event of the form ===============================================================
LOCAL hRegion1
LOCAL hRegion2
LOCAL nTop
LOCAL nLeft
LOCAL nBottom
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 211
Graphical Functions
LOCAL nRight
LOCAL ARRAY aPoints[7,2]
#define RGN_AND 1
#define RGN_OR 2
#define RGN_XOR 3
#define RGN_DIFF 4
#define RGN_COPY 5
WITH ThisForm
.Width = .imgBackground.Width
.Height = .imgBackground.Height
DODEFAULT()
m.nTop = 0
m.nLeft = 0
m.nBottom = .Top + .Height
m.nRight = .Left + .Width
aPoints[1,1] = 81 && x1
aPoints[1,2] = 115 && y1
aPoints[2,1] = 132 && x2
aPoints[2,2] = 85 && y2
aPoints[3,1] = 151 && x3
aPoints[3,2] = 0 && y3
aPoints[4,1] = 194 && x4
aPoints[4,2] = 16 && y4
aPoints[5,1] = 237 && x5
aPoints[5,2] = 0 && y5
aPoints[6,1] = 255 && x6
aPoints[6,2] = 85 && y6
aPoints[7,1] = 310 && x7
aPoints[7,2] = 115 && y7
aPoints[1,1] = 76 && x1
aPoints[1,2] = 145 && y1
aPoints[2,1] = 196 && x2
aPoints[2,2] = 186 && y2
aPoints[3,1] = 312 && x3
aPoints[3,2] = 145 && y3
aPoints[4,1] = 253 && x4
aPoints[4,2] = 254 && y4
aPoints[5,1] = 134 && x5
aPoints[5,2] = 254 && y5
&& And combine this regions with the region we already have
.hRegion = GDI_CombineRegions( .hRegion,m.hRegion2,RGN_OR )
IF ( .hRegion != 0 )
ENDIF
ENDIF
ENDWITH
CLEAR EVENTS
The example of above creates a form that is based on several regions. To beautify the presentation of the form, we
have created a JPG file that fills perfectly the combination of regions: our own spy, with a green background! We have
moved this image over some C code of FOCUS.FLL so that you can see that the form has some transparent regions.
Parameters
hRegion handle to a GDI region. This handle is typically given by a previous call to
GDI_CreateRectangleRegion() , GDI_CreateEllipticRegion() , etc.
Returns
lSuccess .T. if the function was successful; .F. if not.
Example
LOCAL nTop, nLeft, nBottom, nRight
&& Obtain the window handle and assign it to a property that we have defined
.hWnd = WIN_hwnd( This.caption )
&& The width of the form is EXACTLY the width of the image
.Width = .imgBackground.Width
&& The height of the form is EXACTLY the height of the image
.Height = .imgBackground.Height
DODEFAULT()
ENDWITH
Parameters
hRegion1 the handle to the first GDI region if the function is successful.
hRegion2 the handle to the second GDI region if the function is successful.
nMode combination mode. The following modes can be used:
RGN_AND 1
RGN_OR 2
RGN_XOR 3
RGN_DIFF 4
RGN_COPY 5
Example
LOCAL hRegion1, hRegion2
LOCAL nTop, nLeft, nBottom, nRight
LOCAL nRandom
#define RGN_AND 1
#define RGN_OR 2
#define RGN_XOR 3
#define RGN_DIFF 4
#define RGN_COPY 5
WITH ThisForm
.Width = 150
.Height = 150
DODEFAULT()
m.nTop = 0
m.nLeft = 0
m.nBottom = 100
m.nRight = 100
&& Use a specific JPG file to fill the TWO rectangular regions
.imgBackground.picture = "multiregions.jpg"
ELSE
&& If lower half of the random range
&& Create TWO circles, and combine them together later
m.hRegion1 = GDI_CreateEllipticRegion( m.nTop , ;
m.nLeft , ;
m.nBottom, ;
m.nRight )
ENDWITH
The example of above creates a form with irregular shape: either two circles combined together or two rectangles
combined together.
To beautify the presentation of the form, we have created two JPG files that fill perfectly the combination of regions.
Parameters
nTop specifies the logical y-coordinate of the upper-left corner of the rectangle.
nLeft specifies the logical x-coordinate of the upper-left corner of the rectangle.
nBottom specifies the logical y-coordinate of the lower-right corner of the rectangle.
nRight specifies the logical x-coordinate of the lower-right corner of the rectangle.
Please notice that for the region to take effect, you must attach it to the form with
GDI_SetWindowRegion() .
Returns
hRegion the handle to a GDI region if the function is successful; 0 if the function failed.
Example
LOCAL hRegion1, hRegion2
LOCAL nTop, nLeft, nBottom, nRight
LOCAL nRandom
#define RGN_AND 1
#define RGN_OR 2
#define RGN_XOR 3
#define RGN_DIFF 4
WITH ThisForm
.Width = 150
.Height = 150
DODEFAULT()
m.nTop = 0
m.nLeft = 0
m.nBottom = 100
m.nRight = 100
&& Use a specific JPG file to fill the TWO rectangular regions
.imgBackground.picture = "multiregions.jpg"
ELSE
&& If lower half of the random range
&& Create TWO circles, and combine them together later
m.hRegion1 = GDI_CreateEllipticRegion( m.nTop , ;
m.nLeft , ;
m.nBottom, ;
m.nRight )
ENDWITH
The example of above creates a form with irregular shape: either two circles combined together or two rectangles
combined together.
To beautify the presentation of the form, we have created two JPG files that fill perfectly the combination of regions.
Parameters
nHDC handle to device context.
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
nRight specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
Returns
lSuccess .T. if the function was successful; .F. if not.
Example
LOCAL hWnd
LOCAL hDC
LOCAL nTop
LOCAL nLeft
LOCAL nBottom
LOCAL nRight
LOCAL nWidth
LOCAL nHeight
LOCAL nWidth2
LOCAL nHeight2
m.nLeft = 150
m.nTop = 100
m.nRight = 400
m.nBottom = 125
m.nWidth = 30
m.nHeight = 30
m.nWidth2 = 55
m.nHeight2 = 55
GDI_RoundRectangle( hDC , ;
m.nTop , ;
m.nLeft , ;
m.nBottom , ;
m.nRight , ;
m.nWidth , ;
GDI_Rectangle( hDC , ;
m.nBottom+5 , ;
m.nLeft , ;
m.nBottom+5+25, ;
m.nRight )
GDI_Ellipse( hDC , ;
m.nTop , ;
m.nLeft-60 , ;
m.nTop+m.nHeight2, ;
m.nLeft-60+m.nWidth2 )
WIN_ReleaseDC( m.hWnd,m.hDC )
The example of above creates the following output. Please notice that GDI function calls might need to be re-
created in the paint() event of your forms to have a persistent effect.
Syntax
GDI_LastVersion() szLastVersion
GRA_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\GRAPHIC.C-Mon Oct 19 15:55:22 1998" .
Parameters
nHDC handle to device context.
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
nRight specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
nWidth specifies the width of ellipse.
nHeight specifies the height of ellipse.
Returns
lSuccess .T. if the function was successful; .F. if not.
Example
LOCAL hWnd
LOCAL hDC
LOCAL nTop
LOCAL nLeft
LOCAL nBottom
LOCAL nRight
LOCAL nWidth
LOCAL nHeight
LOCAL nWidth2
LOCAL nHeight2
m.nLeft = 150
m.nTop = 100
m.nRight = 400
m.nBottom = 125
m.nWidth = 30
m.nHeight = 30
m.nWidth2 = 55
m.nHeight2 = 55
GDI_RoundRectangle( hDC , ;
m.nTop , ;
m.nLeft , ;
m.nBottom , ;
m.nRight , ;
m.nWidth , ;
m.nHeight )
GDI_Rectangle( hDC , ;
m.nBottom+5 , ;
m.nLeft , ;
m.nBottom+5+25, ;
m.nRight )
GDI_Ellipse( hDC , ;
m.nTop , ;
m.nLeft-60 , ;
m.nTop+m.nHeight2, ;
m.nLeft-60+m.nWidth2 )
WIN_ReleaseDC( m.hWnd,m.hDC )
The example of above creates the following output. Please notice that GDI function calls might need to be re-
created in the paint() event of your forms to have a persistent effect.
Parameters
nHDC handle to device context.
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
nRight specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
nWidth specifies the width of ellipse.
nHeight specifies the height of ellipse.
Returns
lSuccess .T. if the round rectangle was drawn; .F. if not.
Example
LOCAL hWnd
LOCAL hDC
LOCAL nTop
LOCAL nLeft
LOCAL nBottom
LOCAL nRight
LOCAL nWidth
LOCAL nHeight
LOCAL nWidth2
LOCAL nHeight2
m.nLeft = 150
m.nTop = 100
m.nRight = 400
m.nBottom = 125
m.nWidth = 30
m.nHeight = 30
m.nWidth2 = 55
m.nHeight2 = 55
GDI_RoundRectangle( hDC , ;
m.nTop , ;
GDI_Rectangle( hDC , ;
m.nBottom+5 , ;
m.nLeft , ;
m.nBottom+5+25, ;
m.nRight )
GDI_Ellipse( hDC , ;
m.nTop , ;
m.nLeft-60 , ;
m.nTop+m.nHeight2, ;
m.nLeft-60+m.nWidth2 )
WIN_ReleaseDC( m.hWnd,m.hDC )
The example of above creates the following output. Please notice that GDI function calls might need to be re-
created in the paint() event of your forms to have a persistent effect.
Parameters
hWnd Handle to the window whose client area will be used for the conversion.
x X of the screen coordinates to be converted. Must be passed by reference.
y X of the screen coordinates to be converted. Must be passed by reference.
Returns
.T. the function always returns .T.
Parameters
hWnd Handle to the window whose client area will be used for the conversion.
x X of the client coordinates to be converted. Must be passed by reference.
y Y of the client coordinates to be converted. Must be passed by reference.
Returns
.T. the function always returns .T.
ALL THE GDI FUNCTIONS THAT FOLLOW ARE STILL UNDER DEVELOPMENT AND TESTING. WE DO
RECOMMEND NOT USING THEM YET BECAUSE THEIR USAGE CAN STILL CHANGE, ESPECIALLY THE ORDER
OF THE PARAMETERS!
Syntax
GDI_Arc( nHDC,nLeft,nTop,nRight,nBottom,nXStart,nYStart,nXEnd,nYEnd ) -> lSuccess
Parameters
nHDC handle to device context.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
Windows 95/98: The sum of nLeft plus nRight must be less than 32768 .
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
Windows 95/98: The sum of nTop plus nBottom must be less than 32768 .
nRight Specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
Windows 95/98: The sum of nLeft plus nRight must be less than 32768 .
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
Windows 95/98: The sum of nTop plus nBottom must be less than 32768 .
nXStart specifies the logical x-coordinate of the ending point of the radial line defining the starting point
of the arc.
nYStart specifies the logical y-coordinate of the ending point of the radial line defining the starting point
of the arc.
nXEnd specifies the logical x-coordinate of the ending point of the radial line defining the ending point
of the arc.
nYEnd specifies the logical y-coordinate of the ending point of the radial line defining the ending point
of the arc.
Returns
lSuccess the function returns an object handle. The cursor position is not updated.
Syntax
ArcTo( nHDC,nLeft,nTop,nRight,nBottom,nXStart,nYStart,nXEnd,nYEnd ) -> nObject
Parameters
nHDC handle to device context.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle. Windows
95/98: The sum of nLeft plus nRight must be less than 32768 .
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle. Windows
95/98: The sum of nTop plus nBottom must be less than 32768 .
nRight specifies the logical x-coordinate of the lower-right corner of the bounding rectangle. Windows
95/98: The sum of nLeft plus nRight must be less than 32768 .
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle. Windows
95/98: The sum of nTop plus nBottom must be less than 32768 .
nXStart specifies the logical x-coordinate of the ending point of the radial line defining the starting point
of the arc.
nYStart specifies the logical y-coordinate of the ending point of the radial line defining the starting point
of the arc.
nXEnd specifies the logical x-coordinate of the ending point of the radial line defining the ending point
of the arc.
nYEnd specifies the logical y-coordinate of the ending point of the radial line defining the ending point
of the arc.
Returns
nObject the function returns an object handle.
Parameters
nStyle specifies the hatch style of the brush. This parameter can be one of the following values:
Value Description
0 Solid
1 Diagonal
2 Cross
3 Diagonal cross
4 Diagonal
5 Horizontal
6 Vertical
The curve of the chord is defined by an ellipse that fits the specified bounding rectangle. The curve begins at the point
where the ellipse intersects the first radial and extends counterclockwise to the point where the ellipse intersects the
second radial. The chord is closed by drawing a line from the intersection of the first radial and the curve to the
intersection of the second radial and the curve.
If the starting point and ending point of the curve are the same, a complete ellipse is drawn.
Syntax
GDI_Chord( nHDC,nLeft,nTop,nRight,nBottom,nXStart,nYStart,nXEnd,nYEnd ) -> nObject
Parameters
nHDC handle to device context.
nLeft specifies the logical x-coordinate of the upper-left corner of the bounding rectangle.
nTop specifies the logical y-coordinate of the upper-left corner of the bounding rectangle.
nRight specifies the logical x-coordinate of the lower-right corner of the bounding rectangle.
nBottom specifies the logical y-coordinate of the lower-right corner of the bounding rectangle.
nXStart specifies the x-coordinate of the endpoint of the radial defining the beginning of the chord.
nYStart specifies the y-coordinate of the endpoint of the radial defining the beginning of the chord.
nXEnd specifies the x-coordinate of the endpoint of the radial defining the end of the chord.
nYEnd specifies the y-coordinate of the endpoint of the radial defining the end of the chord.
Returns
nObject the function returns an object handle.
Syntax
GDI_circle( n1,n2,n3,n4 ) .T.
Parameters
n1 ???
n2 ???
n3 ???
n4 ???
Returns
.T. the function always returns .T. .
Syntax
GRA_line( n1,n2,n3,n4,n5,n6,n7,n8,n9 ) .T.
Parameters
n1 ???
n2 ???
n3 ???
n4 ???
n5 ???
n6 ???
n7 ???
n8 ???
n9 ???
Returns
.T. the function always returns .T. .
Parameters
nHDC handle to device context.
nX X-coordinate of pixel.
nY Y-coordinate of pixel
nRed red component of RGB color.
nGreen green component of RGB color.
nBlue blue component of RGB color.
Returns
lSuccess .T. if the pixel was drawn; .F. if not.
Syntax
GRA_carve( nTop,nLeft,nBottom,nRight ) nCode
Parameters
nTop top of rectangle
Returns
nCode 0 if function is successful
HTML/HTTP Functions
Functions Synopsis
The Internet has changed the way we build applications. Internet technologies and techniques are still in their infancy
but they promised to dramatically affect our applications in general. This is not a question of Internet Browsers but
much more deeply a way we will need to interact with resources. This world of connected computers require to get
tools that make it possible to access databases, tables and files anywhere. As such, FOCUS.FLL needed to give the
Visual FoxPro developer the tools to keep in touch with the natural evolution of modern software.
With version 7.85 of FOCUS.FLL we have built our very first Internet functions. Many of the internals of FOCUS.FLL
will change in the future while preserving your existing code. More will come as time goes by.
Syntax
HTTP_Decode( szHtml] ) szString
Parameters
szHTML the resulting encoded string.
Returns
szString the string to HTML encode.
Example
? HTML_Decode(HTML_Encode( ["Ce bel été"] )) && "Ce bel été"
If the text string to be displayed already contains HTML encoding, do not use the HTML_Encode() function. For
example, suppose a product description field contains HTML-encoded text such as "The <I>Classic Diner
Clock</I> brings the age of the "Golden Oldies" to your kitchen." . This string
uses the <I> tag to format italic text and the " sequence to display quotation marks when displayed by the
client browser. Because the string is already coded in HTML, you do not need to encode it again. Double-encoding
the string would produce incorrect results.
From To From To
"&" "&" "Ò" "&Ograv;"
"<" "<" "Ó" "Ó"
">" ">" "Ô" "Ô"
""" """ "Õ" "Õ"
"°" "°" "à" "à"
"²" "²" "á" "á"
"³" "³" "â" "â"
"¶" "¶" "ã" "ã"
"±" "±" "Ö" "ö"
"©" "©" "÷" "÷"
"«" "«" "ù" "ù"
"®" "®" "ú" "ú"
"»" "»" "û" "û"
"¼" "¼" "ü" "ü"
"½" "½" "æ" "æ"
"¾" "¾" "é" "é"
"À" "À" "ê" "ê"
"Á" "Á" "ë" "ë"
Caution
The internal buffer used by the HTML_Encode() function cannot contain more than 4096 characters.
Syntax
HTTP_Encode( szString] ) szHTML
Parameters
szString the string to HTML encode.
Returns
szHTML the resulting encoded string.
Example
? HTML_Encode( ["Ce bel été"] ) && "Ce bel été"
Syntax
HTML_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set.
Parameters
None.
Returns
lSuccess .T. if the connection has been made; .F. if not.
Example
IF ( ! HTTP_AttemptConnect() )
IF ( HTTP_InternetDial( "MyDialUp" ) )
? "You're connected to the Internet"
ENDIF
ENDIF
If HTTP_CanonicalizeURL() is used on the canonicalized URL, the escape sequence "%25" would be converted
into the escape sequence "%2525" , which would not work properly.
Do not use the HTTP_CanonicalizeURL() to encode HTML text: use the HTML_Encode() function instead.
Syntax
HTTP_CanonicalizeURL( szURL] ) szComponent
Parameters
szURL the URL to canonicalize.
Returns
szComponent the resulting canonicalized URL.
Example
? HTTP_canonicalizeURL( "http://www.fastwrite.com/does not exist/index.htm" )
&& http://www.fastwrite.com/does%20not%20exist/index.htm
See Also
HTTP_URLEncode() ,HTTP_URLDecode() .
Parameters
szURL the base URL to access.
Value Description
0 Host name (domain)
1 Path
2 Host name (domain) + Path
Returns
szComponent the desired component.
Example
LOCAL szDomain
LOCAL szPath
LOCAL szStatus
#define HTTP_QUERY_STATUS_CODE 19
&& Let's split the URL into a domain name and a path
&& For example, http://www.fastwrite.com/images/BannerVFP.jpg is the complete URL
&& Now ... let's ask FOCUS.FLL whether that resource exist
szStatus = HTTP_IsURL( szDomain,szPath,HTTP_QUERY_STATUS_CODE )
&& "200" means OK; 404 means page not found; 403 means Forbidden ... these codes
&& are the same as the ones used in Internet Explorer
IF ( szStatus != "200" )
? "Resource exists!"
ENDIF
Parameters
szBaseURL the base URL to access.
Returns
szURL the combined URL.
&& In this example you see that the space is converted to a %XX sequence
? HTTP_CombineURL( "http://www.fastwrite.com","focus /vcx" )
&& http://www.fastwrite.com/focus%20/vcx
Parameters
szQueryString the query string to decode.
Returns
szDecodedString the decoded query string, or an empty string if an error occurred.
You can use the DD to decode query string sent to a web application server. If for example you request a URL with
some parameters, this function will be very handy:
"http://www.fastwrite.com/products/dynafox/01.fxp?Name=Pat%20Boens&action=Change%20password" can
be turned to "Name=Pat Boens&action=Change password" .
Parameters
szCode code to obtain a descriptive text for.
100 Continue
101 Switching Protocols
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy
307 Temporary Redirect
400 Bad Request
401 Unauthorized
402 Payment Required
Returns
szDesc description.
Example
? HTTP_GetCodeText( "500" ) && "Internal Server Error"
? HTTP_GetCodeText( "200" ) && "OK"
? HTTP_GetCodeText( "404" ) && "Not Found"
Parameters
None
Returns
szBrowser full path to browser application or empty string ("") in case of error.
Example
LOCAL nChoice
LOCAL szBrowser
LOCAL szURL
LOCAL szCmd
LOCAL oIE
LOCAL szClass
#define CH_GO_WEB 1
ELSE
m.oIE = CREATEOBJECT( m.szClass ) && Create an Internet Explorer
&& object
Syntax
HTTP_GetURL( szURL[,nMemory] ) szStream
Parameters
szURL the URL to access.
nMemory optional parameter. If not passed, FOCUS.FLL will freeze some memory space for you. The
function operates quicker if you pass the memory to reserve to retrieve the Internet stream (a
page, a sound, an image, ...).
Returns
szStream Internet stream.
Example
&& Example #1
* This example copies the homepage of ORACLE into the clipboard
_CLIPTEXT = HTTP_GetURL( "http://www.oracle.com" )
<SCRIPT LANGUAGE="JavaScript">
// Catch some browser error conditions
if (parseInt(navigator.appVersion.charAt(0) <= 3)) top.location.href =
"/admin/errors/version.html"
&& Example #2
LOCAL szWeb
LOCAL szNum
LOCAL szExt
&& This example will extract an image from FastWrite's web site. The image is
&& returned as a string. Then, the string is saved to a file thanks to
&& FIL_StringToFile() and finally, the background picture of VFP is set to the
&& newly created image file.
szWeb = "http://www.fastwrite.com/products/focus/Banners/Banner"
szNum = "001"
szExt = ".jpg"
szPath = "O:\SPOT2000"
See Also
HTTP_GetURL2() ., HTTP_PostURL()
Syntax
HTTP_GetURL2( szURL[,nMemory] ) szStream
Parameters
szURL the URL to access.
Returns
szStream Internet stream.
Example
&& Example #1
* This example copies the homepage of FastWrire into the clipboard
_CLIPTEXT = HTTP_GetURL2( "http://www.fastwrite.com" )
imgBranchOpen.src = "http://www.fastwrite.com/Images/BranchesOpen2.jpg";
imgBranchClose.src = "http://www.fastwrite.com/Images/BranchesClose2.jpg";
// document.write( window.location.pathname );
function DisplayMenu()
{
// When the left menu is ON, then the login form shouldn't show up.
// When the left menu is OFF, then the login form should be displayed
// document.all.LogonSection.style.display = "none";
document.all.SideMenu.style.display = "block";
return ( true );
}
function HideMenu()
{
// When the left menu is ON, then the login form shouldn't show up.
// When the left menu is OFF, then the login form sgould be displayed
document.all.LogonSection.style.display = "block";
document.all.SideMenu.style.display = "none";
return ( true );
}
function DoNothing()
{
return ( false );
}
if ( TheStyle.display == "block" )
{
TheStyle.display = "none";
TheImage = eval( "document.img" + szStyle );
TheImage.src = imgBranchClose.src;
}
else
{
TheStyle.display = "block";
TheImage = eval( "document.img" + szStyle );
TheImage.src = imgBranchOpen.src;
}
return ( false );
}
else
{
return ( true );
}
}
return ( false );
return ( false );
}
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",20)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=60
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=15
else if (window.highlighting)
clearInterval(highlighting)
}
-->
</script>
<script language="JavaScript">
<!--
function OpenWindow( theURL,winName,features )
{
window.open(theURL,winName,features);
}
//-->
</script>
</HEAD>
<script language="JavaScript"><!--
window.defaultStatus="FastWrite"
<span ID="Menu1">
<font size="-2"> </font><a href="http://www.fastwrite.com/Products/Manage/Manage.cfm"
onmouseover="return overlib('All software that we have built to manage domestic
needs...',FGCOLOR,'#A5A6D8',BGCOLOR,'White',TEXTCOLOR,'White');" onmouseout="return nd();"><span
class="MenuItem2">«I Manage...»</span></a><br />
</span>
<!-- NavMenu : Choice 1 / products -->
<a href="" onClick="toggleStyle( 'Menu2' ); return false;"><IMG
SRC="http://www.fastwrite.com/Images/BranchesClose2.jpg" BORDER="0" NAME="imgMenu2"><span
class="MenuItem">Services</span></a><br />
<!-- Popup with overLIB
<a href="http://www.fastwrite.com/Products/Services.cfm"
onmouseover="return overlib('<a href=\'http://www.microsoft.com\'>Microsoft</a><br><a
href=\'http://www.oracle.com\'>Oracle</a>',FGCOLOR,'#A5A6D8',BGCOLOR,'White',TEXTCOLOR,'White',STICK
Y);" onmouseout="return nd();">
<span class="MenuItem2">Introduction</span></a><br />
-->
<span ID="Menu2">
<font size="-2"> </font><a href="http://www.fastwrite.com/Products/Services.cfm"
onmouseover="return overlib('Company Background, types of
services, ...',FGCOLOR,'#A5A6D8',BGCOLOR,'White',TEXTCOLOR,'White');" onmouseout="return
nd();"><span class="MenuItem2">Introduction</span></a><br />
<font size="-2"> </font><a
href="http://www.fastwrite.com/Products/maintenance.cfm"><span class="MenuItem2">Hardware
Maintenance</span></a><br />
<font size="-2"> </font><a
href="http://www.fastwrite.com/Products/maintenance.cfm"><span class="MenuItem2">Software
Maintenance</span></a><br />
</span>
<!-- NavMenu : Choice 2 / Services -->
<a href="" onClick="toggleStyle( 'Menu3' ); return false;"><IMG
SRC="http://www.fastwrite.com/Images/BranchesClose2.jpg" BORDER="0" NAME="imgMenu3"><span
class="MenuItem">Tech Support</span></a><br />
<span ID="Menu3">
<font size="-2"> </font><a href="http://www.fastwrite.com/TechSupp/Manage.cfm"
onmouseover="return overlib('Our collection of software for home: manage your CDs, your
books, your video tapes, your budget, your invoices, your
images, ....',FGCOLOR,'#A5A6D8',BGCOLOR,'White',TEXTCOLOR,'White');" onmouseout="return nd();"><span
class="MenuItem2">I Manage</span></a><br />
<font size="-2"> </font><a
href="http://www.fastwrite.com/DvlOnly/general/downloadsonly.cfm" onmouseover="return
overlib('Resources to download from FastWrite\'s web
site',FGCOLOR,'#A5A6D8',BGCOLOR,'White',TEXTCOLOR,'White');" onmouseout="return nd();"><span
class="MenuItem2">Downloads</span></a><br />
</span>
<!-- NavMenu : Choice 9 / DevOnly -->
<a href="" onClick="toggleStyle( 'Menu10' ); return false;"><IMG
SRC="http://www.fastwrite.com/Images/BranchesClose2.jpg" BORDER="0" NAME="imgMenu10"><span
class="MenuItem">About us</span></a><br />
<span ID="Menu10">
<font size="-2"> </font><a href="http://www.fastwrite.com/AboutUs/Belgium.cfm"><span
class="MenuItem2">Belgium</span></a><br />
<!---
<font size="-2"> </font><a href="http://www.fastwrite.com/AboutUs/Thailand.cfm"><span
class="MenuItem2">Thailand</span></a><br />
--->
</span>
<!-- NavMenu : Choice 10 / About Us --><!-- Page inclusion in AfterNavMenu :
http://www.fastwrite.com/NewsInBrief.cfm?Type=Public -->
<BR>
<BR>
<br></FONT>
</TD></TR></TABLE></TD></TR></TABLE>
<BR>
</DIV><!-- End of DIV NavMenu --></TD><TD VALIGN="top" BGCOLOR="#9A97C7" BACKGROUND=""><DIV
ID="Body"><!-- Body is MsgNo : 37 --><script type="text/javascript"
src="http://www.fastwrite.com/scripts/snow.js"></script>
<p class="SubTitle0">Welcome</p>
We have promised to release the sources of <span class="File">FOCUS.FLL</span> before New Year.
Unfortunately, we are still busy making modifications to the sources of <span
class="File">FOCUS.FLL</span>, <strong>version 8.04</strong>! Therefore, we kindly ask you to wait a
little bit. Thank you.
</p></p>
<!---
<div align="center">
<IMG SRC="http://www.fastwrite.com/Images/focus_ad.gif" ALIGN="center">
</div>
--->
</TD>
</TR>
</table>
Some other functions related to the NT File System will appear also. For example the ability to
create a logical link to a file and refer to that link later on (similar to UNIX): it makes it a lot
easier to "share" files between instances of your applications. Well ... and more. Stay tuned.<br
/><br />
</p>
<p class="descExpanded">
<b><span class="File">FOCUS.FLL</span> 8.03</b> is available. It contains a number of bug fixes as
well as about 12 new functions.<br /><br />
<p class="descExpanded">
1. <span class= "SrcCode">LOG_Append()</span>: internal bug fixed when strategy set to "Reduce
to Half Size".<br /><br />
2. <span class= "SrcCode">EnumWindows()</span>: this was an internal alias of <span class=
"SrcCode">WIN_EnumChildren()</span>. This is no longer the case as it became the alias of <span
class= "SrcCode">WIN_EnumWindows()</span>. Potential code impact.<br /><br />
3. <span class= "SrcCode">GetWindows()</span>: this was an internal alias of <span class=
"SrcCode">WIN_GetChildren()</span>. This is no longer the case as it became the alias of <span
class= "SrcCode">WIN_GetWindows()</span>. Potential code impact.<br /><br />
4. <span class= "SrcCode">WIN_EnumWindows()</span>: new function. No code impact. Initiates the
retrieval of a list of top-level windows of Windows.<br /><br />
5. <span class= "SrcCode">WIN_GetWindows()</span>: new function. No code impact. Completes the
retrieval of the list of the top-level windows started via <span class=
"SrcCode">WIN_EnumWindows()</span>.<br /><br />
<p class="descExpanded">
For sure you came across the need to maintain some data hidden from your users, either because you
really want to protected them against messing up with your appication, or simply because you keep
some keys secret.<br /><br />
Sounds familiar? You bet! What we do usually is to encrypt the contents of the file, hide it in a
place known by us, and access this file whenever we have to.<br /><br />
Well ... <strong>on NTFS drives</strong> ... there is a better alternative: "Named
Streams"<br /><br />
We confess that this possibility has been around from some time, but it has been downplayed by
Microsoft. This is unfortunate because streams can be incredibly useful in many situations. And
streams are easy to use!<br /><br />
As a first attempt, let's create a stream in a command shell (you'll see how easy it is):</p>
<pre class="SrcCode">
D:\>echo "Hello FOCUS" > MYFILE.TXT:MYSTREAM
D:\>dir *.txt
Volume in drive D is CONSTELLATION_D
Volume Serial Number is E44E-4E1A
Directory of D:\
<pre class="SrcCode">
D:\>MORE < MYFILE.TXT
</pre>
<p class="descExpanded">
Nothing is reported!
</p>
<pre class="SrcCode">
D:\>MORE < MYFILE.TXT:MYSTREAM
"Hello FOCUS"
</pre>
<p class="descExpanded">
The first attempt with <span class="SrcCode">MORE < MYFILE.TXT</span> didn't render what was
stored in the file. However, the second attempt, <span class="SrcCode">MORE <
MYFILE.TXT:MYSTREAM</span>, did! Woaw!<br /><br />
Is there any way to do this in a programmatic way? <b>YES</b>! ... with <span
class="File">FOCUS.FLL</span>! Try the following code ... it will just do the same:</p>
<pre class="SrcCode">
#define WIN32API_STRATEGY 1
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
LOCAL nHandle
FIL_SetOpenStrategy( WIN32API_STRATEGY )
m.nHandle = FIL_create( "D:\MYFILE.TXT:MYSTREAM",GENERIC_READ+GENERIC_WRITE )
FIL_write( m.nHandle,["Hello FOCUS"] )
FIL_close( m.nHandle )
</pre>
<p class="descExpanded">
Even the Explorer will report a length of 0 bytes!<br /><br />
I think that you have the idea, now. Simply use the powerful File functions of <span
class="File">FOCUS.FLL</span> to play with NTFS to its fullest potential.<br /><br />
For those of you that want to know more about Data Streams, they can follow this link:
<a href ="http://www.microsoft.com/technet/treeview/default.asp?
url=/technet/prodtechnol/winxppro/reskit/prkc_fil_xurt.asp">Microsoft</a>
</p></DIV><!-- End of DIV Body --></TD></TR><DIV ID="FWPageFooter"><TR><TD WIDTH="160" VALIGN="top"
BGCOLOR="#A5A6D8"> </TD><TD><TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR><TD
HEIGHT="3"></TD></TR><TR><TD
BACKGROUND="http://www.fastwrite.com/Images/Orange.png"></TD></TR><TR><TD ALIGN="RIGHT"
BGCOLOR="#9A97C7" HEIGHT="17" VALIGN="middle"><P CLASS="Normal"><A
HREF="http://www.fastwrite.com"><IMG SRC="http://www.fastwrite.com/Images/LittleFW2.jpg" BORDER="0"
ALT="Design by FastWrite" WIDTH="77" HEIGHT="21" ALIGN="LEFT"></A><IMG
SRC="http://www.fastwrite.com/Images/frv.png" BORDER="0" ALT="Not yet active" WIDTH="21" HEIGHT="21"
ALIGN="LEFT"><IMG SRC="http://www.fastwrite.com/Images/nlv.png" BORDER="0" ALT="Not yet active"
WIDTH="21" HEIGHT="21" ALIGN="LEFT"><IMG SRC="http://www.fastwrite.com/Images/env.png" BORDER="0"
ALT="Not yet active" WIDTH="21" HEIGHT="21" ALIGN="LEFT"><IMG
SRC="http://www.fastwrite.com/Images/dev.png" BORDER="0" ALT="Not yet active" WIDTH="21" HEIGHT="21"
ALIGN="LEFT"><A HREF="http://www.fastwrite.com"><font face="verdana" size="-2">Home</font></A> - <A
HREF="http://www.fastwrite.com/comments.cfm"><font face="verdana" size="-2">Comments</font></A> - <A
HREF="http://www.fastwrite.com/Legal/Legal.cfm"><font face="verdana" size="-2">Copyright © 2000 -
All Rights Reserved.</font></A> <A HREF="mailto:info@fastwrite.com"><IMG
SRC="http://www.fastwrite.com/Images/envelope.gif" BORDER="0" ALT="Quick touch with
us"></A></P></TD></TR><TR><TD
BACKGROUND="http://www.fastwrite.com/Images/Orange.png"></TD></TD></TR></DIV></TABLE><!-- Generation
End: {ts '2003-02-01 18:44:36'} --></BODY></HTML>
See Also
HTTP_GetURL() ., HTTP_PostURL()
Parameters
szDialUp dial-up connection to use.
dwFlags optional parameter. Unsigned long integer value that contains the flags to use. This can be one
of the following values: INTERNET_AUTODIAL_FORCE_ONLINE (0x0001) = Forces an online
connection. INTERNET_AUTODIAL_FORCE_UNATTENDED (0x0002) = Forces an unattended
Internet dial-up. If user intervention is required, the function will fail.
INTERNET_DIAL_FORCE_PROMPT = Ignores the "dial automatically" setting and forces the
dialing user interface to be displayed. INTERNET_DIAL_UNATTENDED (0x8000) = Connects to
the Internet through a modem, without displaying a user interface, if possible. Otherwise, the
function will wait for user input. INTERNET_DIAL_SHOW_OFFLINE = Shows the Work Offline
button instead of Cancel button in the dialing user interface.
Returns
dwConnection connection handle or 0 if the function failed.
Example
IF ( HTTP_InternetDial( "Yucom" ) )
szHome = HTTP_GetURL( "http://www.oracle.com" )
ENDIF
Syntax
HTTP_IsURL( szDomain,szPath[,nType] ) szStatus
Parameters
szDomain the base host name (use HTTP_CrackURL() to split a URL into a domain and a path).
szPath the path (use HTTP_CrackURL() to split a URL into a domain and a path).
The following list contains the values and corresponding constants for the HTTP status codes
returned by servers on the Internet
Returns
szStatus request status.
Example
LOCAL szDomain
LOCAL szPath
LOCAL szStatus
#define HTTP_QUERY_STATUS_CODE 19
&& Let's split the URL into a domain name and a path
&& For example, http://www.fastwrite.com/images/BannerVFP.jpg is the complete URL
&& Now ... let's ask FOCUS.FLL whether that resource exist
szStatus = HTTP_IsURL( szDomain,szPath,HTTP_QUERY_STATUS_CODE )
&& "200" means OK; 404 means page not found; 403 means Forbidden ... these codes
&& are the same as the ones used in Internet Explorer
IF ( szStatus != "200" )
? "Resource exists!"
ENDIF
Parameters
None.
Returns
szLastError last error that occurred while using the HTTP_*() functions.
Example
IF ( EMPTY( HTTP_GetURL( "http://www.fastwrite.com" ) ) )
? "Cannot open FastWrite home page.",HTTP_LastError()
ENDIF
Parameters
None.
Returns
nMilliSeconds time of the last HTTP_GetURL() in milliseconds.
Example
* This example attempts to retrieve homepages for Oracle, Sybase and Microsoft
* Then ... based on the number of bytes sent over and the time taken for the
* operation to complete, it establishes the transfer rate:
szOracle = HTTP_GetURL("http://www.oracle.com" )
nOracle = HTTP_LastGetURLTime()
szSybase = HTTP_GetURL("http://www.sybase.com" )
nSybase = HTTP_LastGetURLTime()
szMS = HTTP_GetURL("http://www.microsoft.com" )
nMS = HTTP_LastGetURLTime()
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set.
Parameters
szURL the URL to access.
Returns
szStream Internet stream.
Example
LOCAL szUserName
LOCAL szPassword
LOCAL szPost
See Also
HTTP_GetURL() .
Parameters
szFunc the new callback function. This function should return a logical value, .T. or .F.. If it returns
.F., the current download initiated by HTTP_GetURL() or HTTP_GetURL2() is aborted.
Example
LOCAL szCallback
<... here you would have code that calls the HTTP_GetURL() function >
FUNCTION HTTPCallback()
LOCAL lRetVal
RETURN ( m.lRetVal )
Parameters
nMilliSeconds the new timeout in milliseconds. This parameter is optional.
Returns
nCurMilliSeconds the current setting in milliseconds.
Example
LOCAL nMilli
LOCAL szHTML
IF ( EMPTY( m.szHTML ) )
? "The server is not responding"
ENDIF
Syntax
HTTP_URLDecode( szURL ) szDecodedURL
Returns
szDecodedURL the decoded URL.
Example
? HTTP_URLEncode( "http://www.fastwrite.com/dynafox.fxp?active=True&pattern=this is a test" )
&& Result ...
&& http%3a%2f%2fwww.fastwrite.com%2fdynafox.fxp%3factive%3dTrue%26pattern%3dthis+is+a+test
See Also
HTTP_URLEncode() , HTTP_canonicalizeURL() .
Syntax
HTTP_URLEncode( szURL[,lStrict] ) szEncodedURL
Parameters
szURL URL to encode.
lStrict Optional parameter. .T. by default. If passed and set to .F. , then the following characters are
replicated as they are in the original stream: ':', '/', '?', '&', and '=' .
Returns
szEncodedURL the encoded URL.
Example
? HTTP_URLEncode( "http://www.fastwrite.com/dynafox.fxp?active=True&pattern=this is a test" )
&& Result ...
&& http%3a%2f%2fwww.fastwrite.com%2fdynafox.fxp%3factive%3dTrue%26pattern%3dthis+is+a+test
See Also
HTTP_URLDecode() , HTTP_canonicalizeURL() .
Functions Synopsis
We decided to assign aliases to INI functions for the sake of convenience. All these functions are in fact available
under the File category of FOCUS.
As LANs become increasingly popular, programmers need to ensure their applications will run properly in a network
environment. In order to do this, they’ll have to consider their applications shared by multiple users, each of them
wanting to preserve personal preferences.
Many applications use configuration files in the same directory as the executable file to retain settings that were used
from one program session to another.
In a network application, it is highly recommended to use INI files instead. Windows comes with a set of profile
functions whose goal is to store user-specific information. The profile functions create initialization files in one user’s
private Windows directory. These functions fall into two categories : those that access the WIN.INI file and those that
access other .INI files.
FOCUS provides few functions to read and write both the WIN.INI or any other .INI file.
READ WRITE
WIN.INI GetProfileString() WriteProfileString()
*.INI GetPrivateProfileString() WritePrivateProfileString()
In addition to these basic services, FOCUS makes it also possible to read an entire .INI section :
WIN.INI GetProfileSection()
*.INI GetPrivateProfileSection()
Alias
FIL_reaini(), FIL_ReadIni() .
Syntax
GetPrivateProfileString( szSection,szEntry,szINIFile ) szString
Parameters
szSection section of .INI file.
Returns
szString string pertaining to entry.
Example
IF ( GetPrivateProfileString( "SECRET" , ;
"PassWord" , ;
"MY.INI" ;
) != cPassWord ;
)
? "Wrong password !"
ENDIF
Parameters
szSection section to read.
Returns
cEntries all entries for given section. Up to 1024 bytes.
Example
? "Wallpaper settings",GetPrivateProfileSection( "wallpaper","myapp.ini" )
Parameters
szSection section to read.
Example
? "Printer list",GetProfileSection( "devices" )
Parameters
szSection section of WIN.INI.
Returns
szString string pertaining to entry.
Example
IF ( GetProfileString( "MYAPP","PassWord" ) <> cPassWord )
? "Wrong password !"
ENDIF
Syntax
WritePrivateProfileString( szSection,szEntry.NULL.,szString.NULL.,szINIFile ) lSuccess
Parameters
szSection section of the .INI file to write to.
szEntry key name that appears under the section name. If this parameter is an empty string ( "") or a
.NULL. , the section is deleted from the .INI file.
szString string to write to .INI file. If this parameter is an empty string ( "") or a .NULL. , the entry is
deleted from the .INI file.
Returns
lSuccess .T. if writing is successful; .F. if not.
Example
IF ( ! WritePrivateProfileString( "WALLPAPER" , ;
"Fill file" , ;
"FILLER.BMP", ;
Parameters
szSection section of WIN.INI.
Returns
lSuccess .T. if writing is successful; .F. if not.
Example
IF ( ! WriteProfileString( "MYAPP","Desktop","640 480 256" ) )
? ".INI update failed"
ENDIF
IP Functions
Syntax
IP_GetAddress() szAddresses
Parameters
None.
Returns
szAddresses a tokenized string of addresses. Only the first token is meaningful.
Example
? IP_GetAddress() && 169.254.90.109^0.0.0.0^0.0.0.0^0.0.0.0^0.0.0.0^
Syntax
IP_GetIP( szDomain ) szIP
Parameters
szDomain the domain for which the IP addresses should be returned.
Returns
szIP a tokenized string of IP addresses corresponding to the szDomain domain name. Each IP
address is separated by a caret (^).
Example
? IP_GetIP( "www.microsoft.com" ) && 207.191.213.230^
? IP_GetIP( "orion" ) && 192.168.254.2 (machine on local network)
Parameters
None.
Syntax
IP_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\IP.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
szIP a string that forms a valid IP address
or
Example
? IP_ping( "217.136.220.21" ) && .T.
? IP_ping( "www.fastwrite.com" ) && .T.
? IP_ping( "www.fastwrite.cof" ) && .F. (domain name error)
? IP_ping( "http://www.fastwrite.com" ) && .F. (no http in front!)
Keyboard Functions
Syntax
KEY_CodePage() nCodePage
Parameters
None.
Returns
nCodePage OEM code-page identifier, or it is the default identifier if the registry value is not readable.
Following are the OEM code-page identifiers:
Identifier Meaning
437 MS-DOS United States
850 MS-DOS Multilingual (Latin I)
852 MS-DOS Slavic (Latin II)
855 IBM Cyrillic (primarily Russian)
857 IBM Turkish
860 MS-DOS Portuguese
861 MS-DOS Icelandic
863 MS-DOS Canadian-French
865 MS-DOS Nordic
866 MS-DOS Russian (former USSR)
869 IBM Modern Greek
Parameters
None.
Returns
.T. the function always returns a logical .T..
Example
IF ( FIL_reaini( "KEYBOARD","Speed","MYAPP.INI" ) = "FAST" )
KEY_fast()
ENDIF
Parameters
None
Returns
nFnctKeys indicates the number of function keys on the keyboard.
Example
IF ( KEY_fmax() < 12 )
? "Enhanced keyboard required"
ENDIF
Parameters
None.
Returns
cLayout keyboard layout name.
Example
? KEY_GetLayoutName() && 000080c
Syntax
KEY_HookF12( [szCmd] ) lSuccess
Parameters
szCmd The command that must be executed whenever the F12 is pressed. This parameter is optional.
Returns
lSuccess .T. if the F12 key is successfully captured; .F. if not.
IF ( KEY_HookF12() )
? "Each time you press the F12 key, the 'Hello' message will be displayed"
ENDIF
&& Example #2
IF ( KEY_HookF12( "WAIT WINDOW 'Bonjour' NOWAIT" ) )
? "Each time you press the F12 key, the 'Bonjour' message will be displayed"
ENDIF
Syntax
KEY_HookF12Proc( szCmd ) .T.
Parameters
None.
Returns
.T. always.
Example
&& Example #1
KEY_HookF12Proc( "WAIT WINDOW 'Hello' NOWAIT" )
IF ( KEY_HookF12() )
? "Each time you press the F12 key, the 'Hello' message will be displayed"
ENDIF
&& Example #2
&& This will show you how to use the KEY_HookF12() key
&& to interrupt a code intensive loop
PRIVATE lStopScanning
m.lStopScanning = .F.
USE myBigFile
PROCEDURE StopScanning()
m.lStopScanning = .T.
RETURN
Syntax
KEY_HookPrtScr( [szCmd] ) lSuccess
Parameters
szCmd The command that must be executed whenever the PrintScreen is pressed. This parameter is
optional.
Returns
lSuccess .T. if the PrintScreen key is successfully captured; .F. if not.
Example
&& Example #1
KEY_HookPrtScrProc( "WAIT WINDOW 'Hello' NOWAIT" )
IF ( KEY_HookPrtScr() )
? "Each time you press the PrintScreen key, the 'Hello' message will be displayed"
ENDIF
&& Example #2
IF ( KEY_HookPrtScr( "WAIT WINDOW 'Bonjour' NOWAIT" ) )
? "Each time you press the PrintScreen key, the 'Bonjour' message will be displayed"
ENDIF
Syntax
KEY_HookPrtScrProc( szCmd ) .T.
Parameters
None.
Returns
.T. always.
Example
KEY_HookPrtScrProc( "WAIT WINDOW 'Hello' NOWAIT" )
IF ( KEY_HookPrtScr() )
? "Each time you press the PrintScreen key, the 'Hello' message will be displayed"
ENDIF
Parameters
None.
Returns
lStatus .T. if CapsLock ON; .F. if OFF.
Parameters
None.
Returns
lStatus .T. if Shift key down; .F. if not.
Parameters
None.
Returns
lStatus .T. if Left Shift key down; .F. if not.
Parameters
None.
Parameters
None.
Returns
lStatus .T. if Ctrl key down; .F. if not.
Parameters
None.
Returns
lStatus .T. if Left Ctrl key down; .F. if not.
Parameters
None.
Returns
lStatus .T. if Right Ctrl key down; .F. if not.
Returns
lStatus .T. if Alt key down; .F. if not.
Parameters
None.
Returns
lStatus .T. if Left Alt key down; .F. if not.
Parameters
None.
Returns
lStatus .T. if Right Alt key down; .F. if not.
Parameters
None.
Returns
lStatus .T. if Ins ON; .F. if OFF.
Returns
lStatus .T. if NumLock ON; .F. if OFF.
Parameters
None.
Returns
lStatus .T. if ScrollLock ON; .F. if OFF.
Syntax
KEY_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\KEYBOARD.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
.T. the function always returns a logical .T..
Parameters
lSetting .T. to set the CapsLock ON; .F. to turn it off.
Returns
.T. the function always returns a logical .T..
Parameters
lSetting .T. to set the NumLock key ON; .F. to turn it off.
Returns
.T. the function always returns a logical .T..
Parameters
lSetting .T. to set the ScrollLock key ON; .F. to turn it off.
Returns
.T. the function always returns a logical .T..
Parameters
None.
Example
IF ( FIL_reaini( "KEYBOARD","Speed","APP.INI" ) = "VERY SLOW" )
KEY_slow()
ENDIF
Parameters
nSetting specifies the type of keyboard information to be retrieved.
Value Meaning
0 Keyboard type
1 Keyboard subtype
2 Number of function keys on the keyboard
Returns
nKBDInfo if the function succeeds, the return value specifies the requested information. If the function
fails, the return value is zero.
SubType
Identifier Meaning
1 IBM® PC/XT® ( ) or compatible (83-key) keyboard
2 Olivetti® "ICO" (102-key) keyboard
3 IBM PC/AT® (84-key) or similar keyboard
4 IBM enhanced (101- or 102-key) keyboard
5 Nokia® 1050 and similar keyboards
6 Nokia 9140 and similar keyboards
7 Japanese keyboard
Function keys
Identifier Meaning
1 10
2 12 (sometimes 18)
3 10
4 12
5 10
6 24
7 Hardware dependent and specified by the OEM
Returns
.T. always.
Parameters
None.
Returns
.T. always.
Kernel Functions
Functions Synopsis
The kernel functions are related to the KERNEL.DLL Dynamic Linked Library of FOCUS.FLL . This DLL, provides some
cross-language facilities in FOCUS.FLL .
Many services of FOCUS.FLL do come from the kernel and as time goes by, we intend to place more and more
functions in the kernel so that they would be callable from any language that has an access to DLLs.
Parameters
None.
Returns
nMajor major version number.
Parameters
None.
Returns
nMinor minor version number.
Parameters
None.
Returns
szVersion version number identifier.
Example
? MIS_knlvers() && "KERNEL.DLL - Pat Boens - 17 June 1998 18:45-v3.0"
Syntax
LNG_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\LANGUAGE.C-Mon Oct 19 15:55:22 1998" .
Parameters
nPrimary primary language ID.
LANG_NEUTRAL 0x00
LANG_AFRIKAANS 0x36
LANG_ALBANIAN 0x1c
LANG_ARABIC 0x01
LANG_BASQUE 0x2d
LANG_BELARUSIAN 0x23
LANG_BULGARIAN 0x02
LANG_CATALAN 0x03
LANG_CHINESE 0x04
LANG_CROATIAN 0x1a
LANG_CZECH 0x05
LANG_DANISH 0x06
LANG_DUTCH 0x13
LANG_ENGLISH 0x09
LANG_ESTONIAN 0x25
LANG_FAEROESE 0x38
LANG_FARSI 0x29
LANG_FINNISH 0x0b
LANG_FRENCH 0x0c
LANG_GERMAN 0x07
LANG_GREEK 0x08
LANG_HEBREW 0x0d
LANG_HUNGARIAN 0x0e
LANG_ICELANDIC 0x0f
LANG_INDONESIAN 0x21
LANG_ITALIAN 0x10
LANG_JAPANESE 0x11
LANG_KOREAN 0x12
LANG_LATVIAN 0x26
LANG_LITHUANIAN 0x27
LANG_NORWEGIAN 0x14
LANG_POLISH 0x15
LANG_PORTUGUESE 0x16
LANG_ROMANIAN 0x18
LANG_RUSSIAN 0x19
LANG_SERBIAN 0x1a
LANG_SLOVAK 0x1b
LANG_SLOVENIAN 0x24
Example
&& Forming a Belgian Dutch language identifier
? LNG_MakeLangID( 0x13,2 ) && 2067
&& Forming a Belgian French language identifier
? LNG_MakeLangID( 0x12,2 ) && 2060
Parameters
nLngCode internal language code.
Returns
nCurLngCode the current internal language code.
Example
#define NIL .NULL.
FUNCTION InitApp()
=LNG_set( 1 )
<any other code that is to placed in the init stage>
RETURN ( NIL )
FUNCTION Example()
LOCAL nLng
LOCAL cMessage
nLng = LNG_set()
DO CASE
CASE ( nLng == 1 )
cMessage = "Hello World"
CASE ( nLng == 2 )
cMessage = "Bonjour tout le monde"
CASE <etc.>
<other code>
ENDCASE
RETURN
Locale Settings
Alias
EnumSystemLocales() .
Syntax
LOC_EnumSystemLocales() lSuccess
Parameters
None.
Returns
lSuccess .T. if the function succeeds; .F. otherwise.
Example
IF ( LOC_EnumSystemLocales() )
? "Installed locales:",LOC_GetSystemLocales()
ENDIF
Parameters
nLCType information type.
Returns
szSetting locale setting.
Example
? LOC_GetLocaleSetting( 2 ) && "French (Belgian)"
? LOC_GetLocaleSetting( 6 ) && "Belgium"
? LOC_GetLocaleSetting( 8 ) && "Belgique"
Alias
GetSystemLocales() .
Syntax
LOC_GetSystemLocales() szLocales
Parameters
None.
Returns
szLocales a string of installed locales.
Example
IF ( LOC_EnumSystemLocales() )
? "Installed locales:",LOC_GetSystemLocales()
ENDIF
Parameters
None.
Returns
nLanguage current language.
Example
IF ( LOC_GetUserDefaultLanguage() == 2060 )
? "Belgian French. Correct?"
ENDIF
or ...
LOCAL nLanguage
nLanguage = LOC_GetUserDefaultLanguage()
Parameters
nLanguage language identifier to extract the primary identifier from. This parameter is optional. If it's not
passed, the LOC_GetUserPrimaryLanguage() function uses the default user language
identifier.
LANG_NEUTRAL 0x00
LANG_AFRIKAANS 0x36
LANG_ALBANIAN 0x1c
LANG_ARABIC 0x01
LANG_BASQUE 0x2d
LANG_BELARUSIAN 0x23
LANG_BULGARIAN 0x02
LANG_CATALAN 0x03
LANG_CHINESE 0x04
LANG_CROATIAN 0x1a
LANG_CZECH 0x05
LANG_DANISH 0x06
LANG_DUTCH 0x13
LANG_ENGLISH 0x09
LANG_ESTONIAN 0x25
LANG_FAEROESE 0x38
LANG_FARSI 0x29
LANG_FINNISH 0x0b
LANG_FRENCH 0x0c
LANG_GERMAN 0x07
LANG_GREEK 0x08
LANG_HEBREW 0x0d
LANG_HUNGARIAN 0x0e
LANG_ICELANDIC 0x0f
LANG_INDONESIAN 0x21
LANG_ITALIAN 0x10
LANG_JAPANESE 0x11
LANG_KOREAN 0x12
LANG_LATVIAN 0x26
LANG_LITHUANIAN 0x27
LANG_NORWEGIAN 0x14
LANG_POLISH 0x15
LANG_PORTUGUESE 0x16
LANG_ROMANIAN 0x18
LANG_RUSSIAN 0x19
LANG_SERBIAN 0x1a
LANG_SLOVAK 0x1b
LANG_SLOVENIAN 0x24
LANG_SPANISH 0x0a
LANG_SWEDISH 0x1d
LANG_THAI 0x1e
LANG_TURKISH 0x1f
LANG_UKRAINIAN 0x22
LANG_VIETNAMESE 0x2a
Example
#define LANG_FRENCH 0x0c
IF ( LOC_GetUserPrimaryLanguage() == LANG_FRENCH )
? "Le message est en Français"
ELSE
? "The message is in English"
ENDIF
Parameters
nLanguage language identifier to extract the sub identifier from. This parameter is optional. If it's not
passed, the LOC_GetUserSubLanguage() function uses the default user language identifier.
Returns
nSubLanguage sublanguage identifier. This is one of the following values :
Example
#define LANG_DUTCH 0x13
#define SUBLANG_DUTCH_BELGIAN 0x02
IF ( LOC_GetUserPrimaryLanguage() == LANG_DUTCH )
IF ( LOC_GetUserSubLanguage() == SUBLANG_DUTCH_BELGIAN )
? "Zeker en vast"
ELSE
Syntax
LOC_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\LOCALE.C-Mon Oct 19 15:55:22 1998" .
Log Functions
Functions Synopsis
FOCUS.FLL provides basic services to write log files, files that you want to write information to for tracing purposes. A
good example of a log is a file in which an application stores "secret" information such as user actions, choices,
decisions, mistakes, etc.
FOCUS.FLL supports up to 15 simultaneous logs. When FOCUS.FLL is unloaded from memory it ensures that all log
files still opened are closed properly. In the future FOCUS.VCX will use the capabilities of FOCUS.FLL to handle the
application log file.
You might expect the log functions to be improved in a very near future to accommodate needs like encrypting a log
file, compressing a log file, reading a log file, reducing a log file, etc., all functions that already exist in FOCUS.FLL
but which are still to be implemented with log files.
Using log file functions usually starts with the following calls :
Play around with LOG_*() functions and report what are the functions that are missing according to your needs.
Parameters
nLog log file handle given by LOG_Set() .
Returns
lSuccess .T. indicates that the line was successfully added at the end of the log file; .F. otherwise.
Example
&& Test whether we still have a log file available
IF ( LOG_FindFirstLog() != -1 )
&& Set a log file. If the file does not exist, it is automatically
&& created. If it exists, it is merely opened in SHARE mode, both
&& for read and write operations (which is a major advantage over
&& Visual FoxPro functions
nHandle = LOG_Set( "C:\MYLOG.LOG",1000000 )
&& If we got a valid handle
IF ( nHandle != -1 )
LOG_Append( nHandle,"This is a line of text" )
&& When the log file is no longer needed, you can close it
LOG_Close( nHandle )
ENDIF
ENDIF
Parameters
nLog log file handle given by LOG_Set() . All log files are closed automatically when FOCUS.FLL is
removed from memory.
Returns
lSuccess .T. indicates that the file was successfully closed; .F. otherwise.
Example
&& Test whether we still have a log file available
IF ( LOG_FindFirstLog() != -1 )
&& Set a log file. If the file does not exist, it is automatically
&& created. If it exists, it is merely opened in SHARE mode, both
&& for read and write operations (which is a major advantage over
&& Visual FoxPro functions
nHandle = LOG_Set( "C:\MYLOG.LOG",1000000 )
&& If we got a valid handle
IF ( nHandle != -1 )
LOG_Append( nHandle,"This is a line of text" )
&& When the log file is no longer needed, you can close it
IF ( ! LOG_Close( nHandle ) )
? "Log file cannot be closed"
ENDIF
ENDIF
ENDIF
Parameters
None.
Returns
nLog log file handle or –1 if not handle left.
Example
&& Test whether we still have a log file available
IF ( LOG_FindFirstLog() != -1 )
&& Set a log file. If the file does not exist, it is automatically
&& created. If it exists, it is merely opened in SHARE mode, both
&& for read and write operations (which is a major advantage over
&& Visual FoxPro functions
nHandle = LOG_Set( "C:\MYLOG.LOG",1000000 )
&& If we got a valid handle
IF ( nHandle != -1 )
LOG_Append( nHandle,"This is a line of text" )
&& When the log file is no longer needed, you can close it
IF ( ! LOG_Close( nHandle ) )
? "Log file cannot be closed"
ENDIF
ENDIF
ENDIF
Syntax
LOG_LastError() szErrorCode
Parameters
nLog log file handle given by LOG_Set() . All log files are closed automatically when FOCUS.FLL is
removed from memory.
Returns
szErrorCode message describing the last error that occurred within the LOG_*() functions, or "The
command completed successfully" if everything was OK.
Example
&& Test whether we still have a log file available
IF ( LOG_FindFirstLog() != -1 )
&& Set a log file. If the file does not exist, it is automatically
&& created. If it exists, it is merely opened in SHARE mode, both
&& for read and write operations (which is a major advantage over
&& Visual FoxPro functions
nHandle = LOG_Set( "C:\MYLOG.LOG",1000000,2 )
&& If we got a valid handle
IF ( nHandle != -1 )
LOG_Append( nHandle,"This is a line of text" )
&& When the log file is no longer needed, you can close it
Syntax
LOG_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\LOG.C-Mon Oct 19 15:55:22 1998" .
Parameters
szFile name of the file in which the information will be logged.
nMaximumLength maximum size of the log file. This parameter is ignored for the moment.
Returns
nLog log file handle or –1 if a log handle wasn't assigned. Don't use this handle with low-level
functions of FOCUS.FLL such as FIL_Open() or with functions of Visual FoxPro such as
FOPEN() . Log handles are special handles of FOCUS.FLL that have nothing to do with file
handles in general.
Example
&& Test whether we still have a log file available
IF ( LOG_FindFirstLog() != -1 )
&& Set a log file. If the file does not exist, it is automatically
&& created. If it exists, it is merely opened in SHARE mode, both
&& for read and write operations (which is a major advantage over
&& Visual FoxPro functions
nHandle = LOG_Set( "C:\MYLOG.LOG",1000000,2 )
&& If we got a valid handle
IF ( nHandle != -1 )
LOG_Append( nHandle,"This is a line of text" )
&& When the log file is no longer needed, you can close it
IF ( ! LOG_Close( nHandle ) )
Parameters
None.
Returns
szConstant "The command completed successfully".
Example
&& Test whether we still have a log file available
IF ( LOG_FindFirstLog() != -1 )
&& Set a log file. If the file does not exist, it is automatically
&& created. If it exists, it is merely opened in SHARE mode, both
&& for read and write operations (which is a major advantage over
&& Visual FoxPro functions
nHandle = LOG_Set( "C:\MYLOG.LOG",1000000 )
&& If we got a valid handle
IF ( LOG_LastError() == LOG_Successful() )
LOG_Append( nHandle,"This is a line of text" )
&& When the log file is no longer needed, you can close it
IF ( ! LOG_Close( nHandle ) )
? "Log file cannot be closed"
ENDIF
ENDIF
ENDIF
LZH Functions
Syntax
LZH_encode( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn the file to be compressed.
Returns
lSuccess .T. indicates that the file was compressed successfully; .F. otherwise.
Example
IF ( ! LZH_encode( "MYFILE.TXT","MYFILE.LZH" ) )
? "An error occurred while compressing the file"
ENDIF
Syntax
LZH_decode( szFileIn,szFileOut ) lSuccess
Parameters
szFileIn the file to be uncompressed.
Returns
lSuccess .T. indicates that the file was uncompressed successfully; .F. otherwise.
Example
IF ( ! LZH_decode( "MYFILE.LZH","MYFILE.TXT" ) )
? "An error occurred while decompressing the file"
ENDIF
MAPI Functions
Functions Synopsis
Back to early versions of FOCUS.FLL we have created a library dedicated to MAPI services: FOCUMAPI.DLL . We
have decided to include these services in FOCUS.FLL directly.
Mail can be supported in many different network configurations and topologies. Mail is Network Operating Systems
(NOS) independent and can run on single local area networks, bridged LANs, wide area networks, and on many more
corporate backbone networks. Mail itself can connect to foreign systems and can backbone through a foreign system.
By backboning systems, messages can be routed from one Mail system through a foreign mail system to another Mail
system.
The MS-Mail program and API fits a larger picture : Workgroup computing. Sharing information and resources with a
workgroup of connected computers provides a more efficient work environment in which to use the PC.
As stated earlier, this training session will make full use of simple MAPI which is only a subset of the powerful function
group known as MAPI. However, it might be important to draw up few lines that'll make you understand the the larger
picture I was talking about.
In addition to MAPI, Microsoft has also designed FFAPI (File Format Application Program Interface) which is a group of
programs you can make use of in order to exchange electronic mail between Microsoft Mail and other mail systems or
applications. Armed with the appropriate expertise you'll learn how to access the Mail data files from within your
application. In that sense, FFAPI is the primary layer you can make use of.
Gateway FFAPI
Application FFAPI
Use gateway FFAPI to build a gateway to connect to Microsoft Mail with another electronic messaging system. This is
pretty advanced !
Use Application FFAPI to create a custom application that uses Microsoft Mail to transport information. With a modified
version of Application FFAPI, Application Remote FFAPI, you can also create applications for remote use.
Transport of information is the corner stone of the larger picture. Because it is not limited to messages in general but
rather opened to all types of data (order forms, objects, etc.) it can be used in a wide variety of situations where
communication between two or more workstations is exactly what is required. Getting acquainted with the Mail
transport layer simply opens your applications to a broad set of professional features.
THIS PART OF THE DOCUMENTATION MUST BE CONTINUED. MAPI FUNCTIONS ARE NOT YET OPERATIONAL
With simple MAPI you can easily add messaging to any Windows application. Some MAPI functions include a user
interface (a dialog box), but you can also call MAPI functions without generating user interface concerns.
Function Description
MAPILogon Begins a session with the messaging system.
MAPIFindNext Returns the ID of the next (or first) mail message of a specified type.
MAPIReadMail Reads a mail message.
MAPISaveMail Saves a mail message.
MAPIDeleteMail Deletes a mail message.
MAPISendMail Sends a mail message, allowing greater flexibility than
MAPISendDocuments in message generation.
MAPISendDocuments Sends a standard mail message using a dialog box.
MAPIAddress Addresses a mail message.
MAPIResolveName Displays a dialog box to resolve an ambiguous recipent name.
MAPIDetails Displays a recipient details dialog box.
MAPIFreeBuffer Frees memory allocated by the messaging system.
MAPILogoff Ends a session with the messaging system.
Structure Description
MapiFileDesc Contains file attachment information.
MapiMessage Contains message information.
MapiRecipDesc Contains recipient information.
MapiFileDesc
typedef struct {
ULONG ulReserved ; // Reserved for future use. Must be 0
ULONG flFlags ; // Flags
ULONG nPosition ; // Attachment position in message body
LPSTR lpszPathName ; // Full path name of attached file
LPSTR lpszFileName ; // Original filename (optional)
LPVOID lpFileType ; // Attachment file type (reserved)
} MapiFileDesc, *lpMapiFileDesc;
MapiMessage
typedef struct {
ULONG ulReserved ; // Reserved for future use. Must be 0
LPSTR lpszSubject ; // Message subject
LPSTR lpszNoteText ; // Message text
LPSTR lpszMessage Type ; // Message class
LPSTR lpszDateReceived ; // In YYYY/MM/DD HH:MM format
LPSTR lpszConversationID ; // Conversation tread ID
ULONG flFlags ; // Unread, return receipt
lpMapiRecipDesc lpOriginator; // Originator descriptor
ULONG nRecipCount ; // Number of recipients
lpMapiRecipDesc lpRecips ; // Recipient descriptors
ULONG nFileCount ; // Number of file attachments
lpMapiFileDesc lpFiles ; // Attachment descriptors
} MapiMessage, *lpMapiMessage;
Even if it is not really important to know all these functions and structures in a very detailed manner, it gives you a
good insight of what's possible and what's not.
Although very simple in its principle, this strategy imposes to be able to read *.INI files and to rely on the user
maturity (having a mail section in the WIN.INI file does not imply that the MAPI.DLL file is physically present on the
workstation : this file might have been deleted or removed to a non appropriate place). You'll see later how we came
to an acceptable solution to this problem.
Because we want to step logically into MAPI, we won't go along the usual alphabetical order. Therefore, before actually
wondering whether MAPI is available or not, we'll consider that MAPI is properly installed, up and ... not running.
Logon/logoff process
It is pretty straightforward that we'll have to deal with MAPILogon and MAPILogoff services in order to start and stop a
Mail session.
Logon
MAPILogon() begins a session with the messaging system. You can sign in to the messaging system in 2 ways :
Implicitly sign in
Explicitely sign in
Implicit log on
Any MAPI function call made outside of an established MAPI session generates a sign-in dialog box. We won't cover
these techniques.
Explicit log on
If you want to maintain a session over a number of simple MAPI calls, you can use the MAPILogon() function to
provide a session handle to the messaging system. This handle can be used in subsequent MAPI calls to explicitly
provide user credentials to the messaging system.
The code of such a function is coming up (However it is not our definite code yet) :
MAPILogon() prototype
ULONG MAPILogon( ULONG ulUIParam , // Parent window handle
LPSTR lpszName , // Client account-name string
LPSTR lpszPassword, // Credential string
ULONG flFlags , // Flags to start the session with
ULONG ulReserved , // Reserved for future use
LHANDLE *lphSession ) // Pointer to a session handle
case 1:_initparc(1);
Name = _parc(1); // User name
}
Logoff
MAPILogoff() prototype
ULONG MAPILogoff( LHANDLE lphSession, // Session handle
ULONG ulUIParam , // Parent window handle
ULONG flFlags , // Reserved for future use. Must be 0
ULONG ulReserved ) // Reserved for future use. Must be 0
MAPILogoff() returns
return 0;
}
At this point we can already start a session, and later on, cancel this session any time from within the FoxPro code. It
is not exactly all we want to be able to do, but it's a good start. Let's now focus on messages that are going to be sent
across the mail system.
This function sends a standard mail message. It can prompt for user input with a dialog box or proceed without any
user interaction.
MAPISendMail() returns
MAPISendDocuments() returns
Manifest constant Value Description
MAPI_E_ATTACHMENT_OPEN_FAILURE 12 One or more files in the lpszFilePaths parameter could not be
located.
MAPI_E_DISK_FULL 4 Disk was full.
MAPI_E_FAILURE 2 One or more unspecified errors occurred while sending the mail.
MAPI_E_INSUFFICIENT_MEMORY 5 Not enough memory to proceed.
MAPI_E_LOGIN_FAILURE 3 No default sign-in and the user failed to sign-in successfully.
MAPI_E_USER_ABORT 1 The user cancelled the process from the dialog box.
SUCCESS_SUCCESS 0 OK.
_initparc(1); _initparc(2);
Source = _parc(1); Target = _parc(2);
_deinitparc(1); _deinitparc(2);
MAPIReadMail() returns
Manifest constant Value Description
MAPI_E_ATTACHMENT_WRITE_FAILURE 13 An attachment could not be written to a temporary file.
MAPI_E_DISK_FULL 4 Disk was full.
MAPI_E_FAILURE 2 One or more unspecified errors occurred while reading the mail.
MAPI_E_INSUFFICIENT_MEMORY 5 Not enough memory to proceed.
MAPI_E_INVALID_MESSAGE 3 The message ID was invalid.
MAPI_E_INVALID_SESSION 19 An invalid session handle was used for the lhSession parameter.
MAPI_E_NOT_SUPPORTED 26 The operation was not supported by the messaging system.
MAPI_E_TOO_MANY_FILES 9 There were too many file attachments.
MAPI_E_TOO_MANY_RECIPIENTS 10 There were too many recipients specified.
SUCCESS_SUCCESS 0 OK.
if ( ! MAILShouldMark )
flFlags |= MAPI_PEEK;
if ( MsgAvailable )
{
lppMessage = (lpMapiMessage FAR *) &lpMessage; // Pointer to structure
nResult = (long ) MAPIReadMail( hMAPISession ,
FOXWINDOW() ,
lpszMessageID ,
flFlags ,
0L ,
lppMessage
);
if ( nResult != SUCCESS_SUCCESS )
goto Failure;
if ( cFWText == NULL )
cFWText = _xgrab( 4097,&mhcFWText );
if ( lpMessage->lpOriginator->lpszName != NULL )
_fstrncat( (LPSTR) cFWFrom,lpMessage->lpOriginator->lpszName,40 );
if ( lpMessage->lpszDateReceived )
_fstrncat( (LPSTR) cFWDate,lpMessage->lpszDateReceived ,40 );
if ( lpMessage->lpszSubject != NULL )
_fstrncat( (LPSTR) cFWSubject,lpMessage->lpszSubject ,100 );
if ( lpMessage->lpszNoteText != NULL )
_fstrncat( (LPSTR) cFWText,lpMessage->lpszNoteText ,4095 );
Failure:
_retni( nResult );
return 0;
}
As you can see, the MAI_read() function only retrieves message information from the C structures and store it to
temporary buffers. Later on, thanks to additional services we'll have to construct, we will definitely be able to pass the
informations to FoxPro.
Additional services
You can only call these services when a prior call to MAI_read() returned SUCCESS_SUCCESS.
return 0;
}
MAPIFindNext() returns
Manifest constant Value Description
MAPI_E_FAILURE 2 One or more unspecified errors occurred while looking for messages.
MAPI_E_INSUFFICIENT_MEMORY 5 Not enough memory to proceed.
MAPI_E_INVALID_MESSAGE 17 The message ID of lpszSeedMessageID was invalid.
MAPI_E_INVALID_SESSION 19 An invalid session handle was used for the lhSession parameter.
MAPI_E_NO_MESSAGES 16 MAPIFindNext couldn't find a matching message
MAPI_E_USER_ABORT 1 The user cancelled the process.
SUCCESS_SUCCESS 0 OK.
if ( iFindFirst )
{
*lpszSeedMessageID = '\0';
iFindFirst = FALSE;
}
else
_fstrcpy( lpszSeedMessageID,lpszMessageID );
if ( MAILUnReadOnly )
flFlags = MAPI_UNREAD_ONLY;
else
flFlags = 0L;
if ( ulResult != SUCCESS_SUCCESS )
MsgAvailable = FALSE;
else
MsgAvailable = TRUE;
return 0;
}
HANDLE hMAPILibrary;
HANDLE hSCHEDULELibrary;
LHANDLE hMAPISession;
LHANDLE hSPLUSSession;
// Function prototypes
FOCUSFNC InitMAIL( void );
FOCUSFNC DeInitMAIL( void );
FOCUSFNC MAPIStarting()
/*-------------------*/
{
InitMAIL();
return 0;
}
FOCUSFNC MAPIEnding()
/*-----------------*/
{
DeInitMAIL();
return 0;
}
FOCUSFNC FW_MAI_ismapi()
/*--------------------*/
{
_retl( MAILAvailable );
return 0;
}
FOCUSFNC FW_SCH_issche()
/*--------------------*/
{
_retl( SCHEDULEAvailable );
return 0;
}
FOCUSFNC InitMAIL()
szSeedMessageID[0] = 0;
szMessageID[0] = 0;
szSubject[0] = 0;
szNoteText[0] = 0;
InitMessage( &mmMapiMessage );
SetErrorMode( OldErrorMode ); // Setup error mode at what it was prior to enter this function
MAILAvailable = TRUE;
// Loading MAPI functions. If an error occurs loading one of these functions, there is no need for us to make MAPI
// available. Since Schedule+ heavily relies on MAPI, by making MAPI not available, we'll also make Schedule+ not
// available !
// Loading Schedule+ ! If we came around here, it means that everything was OK. Now, we'll have to check
// out whether Schedule+ can load properly.
FOCUSFNC DeInitMAIL()
/*-----------------*/
{
// Seek first message
iFindFirst = TRUE;
// Free MAPI.DLL
if ( MAILAvailable )
FreeLibrary( hMAPILibrary );
// Free SPLUS.DLL
if ( SCHEDULEAvailable )
FreeLibrary( hSCHEDULELibrary );
// NULL pointers
lpfnMAPILogon = NULL;
lpfnMAPILogoff = NULL;
lpfnMAPISendMail = NULL;
lpfnMAPISendDocuments = NULL;
lpfnMAPIFindNext = NULL;
lpfnMAPIReadMail = NULL;
lpfnMAPISaveMail = NULL;
lpfnMAPIDeleteMail = NULL;
lpfnMAPIFreeBuffer = NULL;
lpfnMAPIAddress = NULL;
lpfnMAPIDetails = NULL;
lpfnMAPIResolveName = NULL;
return(0);
}
To determine whether MAPI is available at run time, check for the MAPI variable in the [Mail] section of WIN.INI. If
this variable is present and nonzero, it indicates that a MAPI.DLL library is available. If the MAPI variable is not present
or is 0, then you cannot call the MAPI functions, and you should not enable applications for mail.
I agree saying that Mail system will only run if [MAIL] section exists in the WIN.INI file and if the MAPI variable is
nonzero. But the problem is that, even if the WIN.INI file contains such a section and even if the variable is nonzero,
that does not automatically imply that the Mail system is really enabled ... for the same reasons we were referring to
earlier. So that I suggest to use a mixture of two strategies :
1. Check for the existence of the [MAIL] section. Check for the presence of the MAPI variable (nonzero).
1. Load appropriate DLLs. If those do not load properly, then MAPI is not available !
The code described above tries to load MAPI.DLL. Here is an extract of this code :
MAILAvailable = TRUE;
But how can we search the WIN.INI file for the [MAIL] section ? Because this is not a built-in feature of FoxPro, we
once again have to turn to C to build our own service (which is only a call to a Windows SDK service).
_initparc(1); _initparc(2);
GetProfileString( Section,Entry,"",szBuf,sizeof(szBuf) );
_retc( szBuf );
_deinitparc(1); _deinitparc(2);
return 0;
}
Example :
PRIVATE cMAPI
IF ( EMPTY( cMAPI ) )
=StopDialog( "MAPI is not available" )
ELSE
IF ( VAL( cMapi ) == 0 )
=StopDialog( "MAPI is not available" )
ELSE
=InfoDialog( "MAPI should be there..." )
<... now let's try to load MAPI>
ENDIF
ENDIF
Having said this, you'll have now to load the library we are about to create. Imagine our own FLL is called
FOCUMAPI.FLL, then most likely you'll have to come up with the following code :
PUBLIC m.lIsMapi
PRIVATE m.cMAPI
m.lIsMapi = .F.
m.cMAPI = FIL_wreain( "Mail","MAPI" )
IF ( EMPTY( m.cMAPI ) )
=StopDialog( "MAPI is not available" )
ELSE
IF ( VAL( m.cMapi ) == 0 )
=StopDialog( "MAPI is not available" )
ELSE
SET LIBRARY TO FOCUMAPI.FLL ADDITIVE
IF ( ! MAI_ismapi() )
RELEASE LIBRARY FOCUMAPI.FLL
ELSE
m.lIsMapi = .T.
ENDIF
ENDIF
ENDIF
Then, along all your application code, simply check for the m.lIsMapi variable to allow MAPI calls or not.
Parameters
None.
Returns
lMAPI .T. if MAPI is installed; .F. if not.
MCI Functions
Parameters
szDevice device name or the alias name by which the device is known.
Returns
nDevice device identifier assigned to the device when it was opened if successful. The identifier is used
in the mciSendCommand() function. If the device name is not known, if the device is not
open, or if there was not enough memory to complete the operation, the return value is zero.
Comment
When calling this function the last MCI error is cleared off.
Syntax
MCI_error() szMCIError
Parameters
None.
Returns
szMCIError error string.
Parameters
szFile file to test.
Returns
lRiff .T. if RIFF format; .F. otherwise.
Parameters
szFile file to test.
Returns
lWave .T. if WAVE format; .F. otherwise.
Syntax
MCI_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\MCI.C-Mon Oct 19 15:55:22 1998" .
Syntax
MCI_send( szCommand ) szDescription
Parameters
szCommand command to be executed by MCI devices.
Returns
szDescription textual description of MCI command execution.
Metric Functions
MET_CmToInch() : Cm to inches.
Remark
The precision of the function is not acceptable for scientific computations.
Syntax
MET_CmToInch( nCm ) nInches
Parameters
nCm centimeters.
Returns
nInches inches.
Syntax
MET_FeetToInch( nFeet ) nInches
Parameters
nFeet feet.
Returns
nInches inches.
Syntax
MET_FeetToMeters( nFeet ) nMeters
Parameters
nFeet feet.
Returns
nMeters meters.
Example
? "Brad Pitt is " + ALLTRIM( STR( MET_FeetToMeters(6) * 100 ) ) + " cm tall"
? "Brad Pitt is " + ALLTRIM( STR( MET_MetersToFeet(1.83),20,2 ) ) + " feet tall"
Syntax
MET_FeetToMile( nFeet ) nMiles
Parameters
nFeet feet.
Returns
nMiles miles.
Syntax
MET_FeetToYard( nFeet ) nYards
Parameters
nFeet feet.
Returns
nYards yards.
Syntax
MET_InchToCm( nInches ) nCm
Parameters
nInches inches.
Returns
nCm centimeters.
Syntax
MET_InchToFeet( nInches ) nFeet
Parameters
nInches inches.
Returns
nFeet feet.
Syntax
MET_InchToMile( nInches ) nMiles
Parameters
nInches inches.
Returns
nMiles miles.
Syntax
MET_InchToYard( nInches ) nYards
Parameters
nInches inches.
Returns
nYards yards.
Syntax
MET_KmToMile( nKm ) nMiles
Parameters
nKm kilometers.
Returns
nMiles miles.
Remark
This function helps the developer identifying the last version of a set of functions. Sometimes the global version
information of FOCUS.FLL (MIS_major() and MIS_minor() ) does not help tracking down the changes in a project.
Starting with version 6.0 of FOCUS.FLL , each source file has now an internal date and time stamp.
Syntax
MET_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\METRIC.C-Mon Oct 19 15:55:22 1998" .
Syntax
MET_MetersToFeet( nMeters ) nFeet
Parameters
nMeters meters.
Example
? "Brad Pitt is " + ALLTRIM( STR( MET_FeetToMeters(6) * 100 ) ) + " cm tall"
? "Brad Pitt is " + ALLTRIM( STR( MET_MetersToFeet(1.83),20,2 ) ) + " feet tall"
Syntax
MET_MileToKm( nMiles ) nKm
Parameters
nMiles miles.
Returns
nKm kilometers.
Syntax
MET_MileToFeet( nMiles ) nFeet
Parameters
nMiles miles.
Returns
nFeet feet.
Syntax
MET_MileToInch( nMiles ) nInches
Parameters
nMiles miles.
Syntax
MET_MileToYard( nMiles ) nYards
Parameters
nMiles miles.
Returns
nYards yards.
Syntax
MET_MToYard( nM ) nYards
Parameters
nM meters.
Returns
nYards yards.
Syntax
MET_YardToFeet( nYards ) nFeet
Parameters
nYards yards.
Returns
nFeet feet.
Syntax
MET_YardToInch( nYards ) nInches
Parameters
nYards yards.
Returns
nInches inches.
Syntax
MET_YardToM( nYards ) nM
Parameters
nYards yards.
Returns
nM meters.
Syntax
MET_MileToYard( nYards ) nMiles
Parameters
nYards yards.
Returns
nMiles miles.
Miscellaneous Functions
Parameters
szFunction function to look for in FOCUS.FLL . The function is case insensitive. Don’t include parenthesis in
the function name.
Returns
szAliases a string with all known aliases of a given function. Each alias is semi-colon separated from the
other. The return value is an empty string is the function is not found. The function name is also
listed in the aliases of the function.
Example
? MIS_Aliases( "MIS_Vers" ) && "MIS_VER;MIS_VERS;MIS_VERSION"
Parameters
None.
Returns
szFuncs a string with all functions and aliases contained in FOCUS.FLL . The element of the list is
separated from the other by a semicolon (";" ).
Example
LOCAL OldSep
&& The following example lists all functions starting with "STR" (all string functions)
Filter( "STR" )
LOCAL szAllFunctions
LOCAL nFunctions
LOCAL nArgs
LOCAL i
LOCAL OldSep
IF ( nArgs == 0 )
cPrefix = "*"
ELSE
cPrefix = cPrefix + "_*"
ENDIF
szAllFunctions = MIS_AllFunctions()
nFunctions = MIS_NumberOfFunctions()
OldSep = STR_setsep( ";" )
FOR i = 1 TO nFunctions
szFunction = STR_ntoken( i,szAllFunctions )
IF ( LIKE( szPrefix,szFunction ) )
? cFunction
ENDIF
NEXT
STR_setsep( OldSep )
SET LIBRARY TO
RETURN ( .NULL. )
Parameters
szFunction function to look for in FOCUS.FLL .
Returns
nParams number of parameters or –1 if the function is not found.
Example
? MIS_Argc( "MIS_IsFunction" ) && 1
Syntax
MIS_Argv( szFunction ) szParamTypes
Parameters
szFunction function to look for in FOCUS.FLL .
Returns
szParamTypes parameters types or an empty string is the function is not found. If the specified function does
not expect any parameter, MIS_Argv() also returns an empty string.
Example
? MIS_Argv( "MIS_False" ) && ".?,.?,.?,.?,.?,.?,.?,.?,.?,.?"
Parameters
nWeight weight in kilos.
Returns
nIndex A good body mass index should be comprised between 20 and 25.
Parameters
None.
Returns
szCredits credits.
Example
? MIS_credits() && " FOCUS code by Pat Boens & Anurak Kongthong, FOCUS doc by Pat Boens & Pete
Cuiry, FOCUS Online doc by Pat Boens and Korakot Leelachareanwaranon"
See also
MIS_major() , MIS_minor() , MIS_knlmajor() , MIS_knlminor() , MIS_DocVers() ,
MIS_OnlineDocVers() , MIS_vers()
Syntax
MIS_DocVers() szDocVers
Parameters
None.
Returns
szDocVers Documentation version.
Example
? MIS_DocVers() && "FOCUS documentation by Pat Boens & Pete Cuiry - Tue Apr 20 21:37:38 1999-v
6.03"
See also
MIS_major() , MIS_minor() , MIS_knlmajor() , MIS_knlminor() , MIS_Credits() ,
MIS_OnlineDocVers() , MIS_vers()
Syntax
MIS_Error( nError ) .T.
Parameters
nError specifies the number of the error to generate.
Returns
.T. the function always returns .T. .
See also
MIS_UserError(), MIS_ErrorInfo()
Parameters
nError specifies the number of the error to obtain information about.
Returns
szErrorMsg error message corresponding to the nError .
See also
MIS_UserError(), MIS_Error()
Caution
The MIS_FuncPtr() , MIS_SetExecPtr() and MIS_ExecFuncPtr() are very powerful functions with which you
can build amazing features such as code that modifies itself. However they are also very dangerous. It goes far
beyond macros and is also much quicker because it never implies a compilation process of any sort.
If the parameters that are passed to this function do not correspond to the ones that are expected by the
function pointed to by the internal code pointer, unpredictable results will happen, often terminating the
current application by causing an illegal operation.
Syntax
MIS_ExecFuncPtr( <parameters> ) xValue
Parameters
<parameters> list of parameters coping with the parameters of the function that should be executed.
Returns
.T. the function always returns .T. .
Example
LOCAL FuncPtr
FuncPtr = MIS_FuncPtr("STR_mirror")
IF ( FuncPtr != -1 )
&& Set up the internal code pointer
MIS_SetExecPtr( FuncPtr )
&& Execute the function of FOCUS.FLL that's located at that place
&& This will correspond to STR_mirror( "Hello" ) !!!
? MIS_ExecFuncPtr( "Hello" ) && "olleH"
ENDIF
Syntax
MIS_false([[[[[[[[[[xExpr1,] xExpr2,] xExpr3,] xExpr4,] ;
xExpr5,] xExpr6,] xExpr7,] xExpr8,] xExpr9,] ;
xExpr10 ) .F.
Parameters
You can go up to 10 parameters that are totally disregarded by the function. The function acts as it was passed no
parameter.
Returns
.F. the function always returns .F..
Syntax
MIS_FuncPtr( cFunction ) nPointer
Parameters
cFunction function to look for in FOCUS.FLL or –1 if the function was not found.
Returns
nPointer code pointer within FOCUS.FLL .
Example
SET LIBRARY TO FOCUS.FLL
DISPLAY STATUS
&& You should have a list such as the one that follows:
BMP_BITS 10001490
BMP_COLORS 100014B0
BMP_HEADER 100014D0
BMP_HEIGHT 10001450
BMP_ISBMP 10001210
BMP_WIDTH 10001470
CD_BAYOPE 1000B860
CD_BAYCLO 1000B890
CD_CANEJE 1000BA40
CD_CANPLA 1000BAA0
<etc.>
? NUM_hexa( MIS_FuncPtr( "CD_CANPLA" ) ) && 1000BAA0
Because FOCUS.FLL is a common resource for many developers, people that want to interact with this common slot
also have to determine what signatures they'll use.
Alias
MIS_SetCommonSlot(), GetCommonSlot(), SetCommonSlot()
Syntax
MIS_GetCommonSlot( [szNewSlot] ) szSlot
Parameters
szNewSlot the new value that will be assigned to the common slot. Never pass a parameter that is longer
than 256 bytes unless you absolutely want to cause illegal operations!
Returns
szSlot current slot value, prior to assign a new value to it.
Example
&& Imagine the following scenario : APPLI1 is loaded; It is the first time an
&& application loads FOCUS.FLL and it executes the following code :
LOCAL szApplName
LOCAL szSlot
m.szApplName = "APPLI1"
m.szSlot = GetCommonSlot()
IF ( ! EMPTY( m.szSlot ) )
m.szSlot = m.szSlot + "^" + m.szApplName
SetCommonSlot( m.szSlot )
ELSE
SetCommonSlot( m.szApplName )
ENDIF
&& Now, you have a second application that loads and use FOCUS.FLL. It
&& currently executes the code that follows :
LOCAL m.szApplName
m.szApplName = "APPLI2"
m.szSlot = GetCommonSlot()
IF ( ! EMPTY( m.szSlot ) )
m.szSlot = m.szSlot + "^" + m.szApplName
SetCommonSlot( m.szSlot )
ELSE
SetCommonSlot( m.szApplName )
ENDIF
*************************************************
&& Imagine the same scenario as before, but now the 2 applications load
&& 2 different FOCUS.FLL
LOCAL m.szApplName
m.szApplName = "APPLI1"
m.szSlot = GetCommonSlot()
IF ( ! EMPTY( m.szSlot ) )
m.szSlot = m.szSlot + "^" + m.szApplName
SetCommonSlot( m.szSlot )
ELSE
SetCommonSlot( m.szApplName )
ENDIF
&& Now, you have a second application that loads and use FOCUS.FLL
&& (but not the same physical file) and it currently executes
&& the code that follows :
LOCAL m.szApplName
m.szApplName = "APPLI2"
m.szSlot = GetCommonSlot()
IF ( ! EMPTY( m.szSlot ) )
m.szSlot = m.szSlot + "^" + m.szApplName
SetCommonSlot( m.szSlot )
ELSE
SetCommonSlot( m.szApplName )
ENDIF
Syntax
MIS_GetFocusUsage() nCounter
Parameters
None.
Returns
nCounter current value of the internal counter. This counter can only be queried and never can be set.
Parameters
cFunction function to look for in FOCUS.FLL .
Returns
lExist .T. if function cFunction exists; .F. otherwise.
Example
? MIS_IsFunction( "MIS_Vers" ) && .T.
Syntax
MIS_knlmajor() nMajor
Parameters
None.
Returns
nMajor major version number.
Syntax
MIS_knlminor() nMinor
Parameters
None.
Returns
nMinor minor version number.
Syntax
MIS_knlvers() cVersion
Parameters
None.
Returns
cVersion version number identifier.
Example
? MIS_knlvers() && "KERNEL.DLL - Pat Boens - 17 June 1998 18:45-v3.0"
Syntax
MIS_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\MISC.C-Mon Oct 19 15:55:22 1998" .
Syntax
MIS_major() nMajor
Parameters
None.
Returns
nMajor major version number.
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 335
Miscellaneous Functions
Example
LOCAL lWrongVersion
IF ( MIS_major() >= 4 )
IF ( MIS_minor() >= 80 )
lWrongversion = .F.
ELSE
lWrongVersion = .T.
ENDIF
ELSE
lWrongVersion = .T.
ENDIF
IF ( lWrongVersion )
? "You should upgrade FOCUS.FLL"
ENDIF
Syntax
MIS_minor() nMinor
Parameters
None.
Returns
nMinor minor version number.
Example
LOCAL lWrongVersion
IF ( MIS_major() >= 4 )
IF ( MIS_minor() >= 80 )
lWrongversion = .F.
ELSE
lWrongVersion = .T.
ENDIF
ELSE
lWrongVersion = .T.
ENDIF
IF ( lWrongVersion )
? "You should upgrade FOCUS.FLL"
ENDIF
Syntax
MIS_nothin([[[[[[[[[[xExpr1,] xExpr2,] xExpr3,] xExpr4,] ;
xExpr5,] xExpr6,] xExpr7,] xExpr8,] xExpr9,] ;
xExpr10 ) .T.
Returns
.T. the function always returns .T.. Even though the function is not supposed to return anything,
Visual FoxPro gives a .T. which is the default for a function/procedure/method that does not
contain an explicit return.
Example
ON KEY LABEL ESCAPE =MIS_nothin()
Syntax
MIS_OnlineDocVers() szOnlineDocVers
Parameters
None.
Returns
szOnlineDocVers online documentation version.
Example
? MIS_OnlineDocVers() && "FOCUS Online documentation by Pat Boens & Korakot Leelachareanwaranon -
Tue Apr 20 21:37:38 1999-v 6.03"
See also
MIS_major() , MIS_minor() , MIS_knlmajor() , MIS_knlminor() , MIS_DocVers() , MIS_credits() ,
MIS_vers()
Syntax
MIS_OutputDebugString( szStr ) .T.
Parameters
szStr string to be sent to the debugger.
Parameters
None.
Returns
nFunctions number of functions supported by FOCUS.FLL including all aliases (For example, the
MIS_Vers() function counts actually for 3 functions because it is known under 3 different
names).
Example
? MIS_vers() + " / Support for " + ALLTRIM(STR(MIS_NumberOfFunctions())) + " functions"
&& "FOCUS.FLL by Pat Boens; Documentation by Pat Boens & Pete Cuiry - 10 October 1998 10:24-v 5.13 /
Support for 1130 functions"
&& The following example lists all functions starting with "STR" (all string functions)
Filter( "STR" )
LOCAL szAllFunctions
LOCAL nFunctions
LOCAL nArgs
LOCAL i
LOCAL OldSep
nArgs = PCOUNT()
szAllFunctions = MIS_AllFunctions()
nFunctions = MIS_NumberOfFunctions()
OldSep = STR_setsep( ";" )
FOR i = 1 TO nFunctions
szFunction = STR_ntoken( i,szAllFunctions )
IF ( LIKE( cPrefix,szFunction ) )
? szFunction
ENDIF
NEXT
STR_setsep( OldSep )
SET LIBRARY TO
RETURN ( .NULL. )
Syntax
MIS_SetExecPtr( nPointer ) .T.
Parameters
nPointer code pointer within FOCUS.FLL .
Returns
.T. the function always returns .T. .
Example
LOCAL FuncPtr
FuncPtr = MIS_FuncPtr("STR_mirror")
IF ( FuncPtr != -1 )
&& Set up the internal code pointer
MIS_SetExecPtr( FuncPtr )
ENDIF
Syntax
MIS_true([[[[[[[[[[xExpr1,] xExpr2,] xExpr3,] xExpr4,] ;
xExpr5,] xExpr6,] xExpr7,] xExpr8,] xExpr9,] ;
xExpr10 ) .T.
Parameters
You can go up to 10 parameters that are totally disregarded by the function. The function acts as it was passed no
parameter.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
szVersion version as string.
Example
? MIS_vers() && "FOCUS.FLL - Mon Sep 25 10:21:20 2000-v 7.88"
See also
MIS_major() , MIS_minor() , MIS_knlmajor() , MIS_knlminor() , MIS_DocVers() ,
MIS_OnlineDocVers() , MIS_credits()
Menu Functions
Parameters
nMenuHandle the handle identifying the menu to which an item must be added.
nChoice the value that must be returned by the MNU_Play() function if the user has selected this item.
szCaption the caption of the item. Use "\-" to add a separation line. Use '&' to create accelerators.
lEnabled optional parameter. Indicates whether the item must appear enabled or disabled. By default,
the item is enabled.
lChecked optional parameter. Indicates whether the item must appear being checked or not. By default,
the item is NOT checked.
Returns
lSuccess .T. if item added successfully; .F. if not.
Example
LOCAL nMainMenu
LOCAL nMenuCountries
LOCAL nMenuCities
LOCAL nMenuCurrencies
LOCAL nMenuFriends
LOCAL nCountries
LOCAL nCities
LOCAL nCurrencies
LOCAL nFriends
LOCAL nChoice
IF ( m.nMainMenu != -1 .AND. ;
m.nMenuCountries != -1 .AND. ;
m.nMenuCities != -1 .AND. ;
m.nMenuCurrencies != -1 .AND. ;
m.nMenuFriends != -1)
&& Now let's add some fancy items (a separation line, a disabled
&& item, a disabled and though checked item, and a checked item)
MNU_AddItem( m.nMainMenu,0,"\-" ) && Add a separation line
i = 0 && Return value if item selected
MNU_AddItem( m.nMainMenu,i,"Item disabled",.F. ) && Create the item
MNU_AddItem( m.nMainMenu,i,"Item disabled and checked",.F.,.T. ) && Create the item
i = 50000 && Return value if item selected
MNU_AddItem( m.nMainMenu,i,"Item checked",.T.,.T. ) && Create the item
Note the
accelerator
See also
MNU_Destroy() , MNU_Make() , MNU_Play() , MNU_AddMenu() .
Parameters
nMainMenu the menu handle nSubMenu must be attached to.
nSubMenu the menu handle that identifies the menu to be attached to nMainMenu .
Returns
lSuccess .T. if nSubMenu attached to nMainmenu ; .F. if not.
Example
LOCAL nMainMenu
LOCAL nMenuCountries
LOCAL nMenuCities
LOCAL nMenuCurrencies
LOCAL nMenuFriends
LOCAL nCountries
LOCAL nCities
LOCAL nCurrencies
LOCAL nFriends
LOCAL nChoice
IF ( m.nMainMenu != -1 .AND. ;
m.nMenuCountries != -1 .AND. ;
m.nMenuCities != -1 .AND. ;
m.nMenuCurrencies != -1 .AND. ;
m.nMenuFriends != -1)
&& Now let's add some fancy items (a separation line, a disabled
&& item, a disabled and though checked item, and a checked item)
MNU_AddItem( m.nMainMenu,0,"\-" ) && Add a separation line
i = 0 && Return value if item selected
MNU_AddItem( m.nMainMenu,i,"Item disabled",.F. ) && Create the item
MNU_AddItem( m.nMainMenu,i,"Item disabled and checked",.F.,.T. ) && Create the item
i = 50000 && Return value if item selected
ENDIF
See also
MNU_Play() , MNU_Destroy() , MNU_AddItem() , MNU_AddMenu() .
Syntax
MNU_create( szMenuDef ) nChoice
Parameters
szMenuDef a string containing the definition of the menu. The string is tokenized. Each token is separated
from another by a caret ( ^). Separation lines can be defined by using a "\-" token. Separation
lines aren't taken into account for the final choice.
If an option of the menu is prefixed by "\G\" , the option is displayed grayed out; if an option
of the menu is prefixed with "\C\" , the option is displayed as checked.
Returns
nChoice the position of the choice or 0 if the menu was cancelled. The separation lines aren't counted for
the final choice.
Example
LOCAL szMenu
See also
MNU_create2()
Parameters
nMenuHandle the menu handle identifying the menu to be destroyed.
Returns
lSuccess .T. if menu destroyed; .F. if not.
Example
LOCAL nMainMenu
LOCAL nMenuCountries
LOCAL nMenuCities
LOCAL nMenuCurrencies
LOCAL nMenuFriends
LOCAL nCountries
LOCAL nCities
LOCAL nCurrencies
LOCAL nFriends
LOCAL nChoice
IF ( m.nMainMenu != -1 .AND. ;
m.nMenuCountries != -1 .AND. ;
&& Now let's add some fancy items (a separation line, a disabled
&& item, a disabled and though checked item, and a checked item)
MNU_AddItem( m.nMainMenu,0,"\-" ) && Add a separation line
i = 0 && Return value if item selected
MNU_AddItem( m.nMainMenu,i,"Item disabled",.F. ) && Create the item
MNU_AddItem( m.nMainMenu,i,"Item disabled and checked",.F.,.T. ) && Create the item
i = 50000 && Return value if item selected
MNU_AddItem( m.nMainMenu,i,"Item checked",.T.,.T. ) && Create the item
ENDIF
See also
MNU_Play() , MNU_Make() , MNU_AddItem() , MNU_AddMenu() .
Parameters
None.
Returns
nMenuHandle a menu handle or -1 if menu cannot be created.
Example
LOCAL nMainMenu
LOCAL nMenuCountries
LOCAL nMenuCities
LOCAL nMenuCurrencies
LOCAL nMenuFriends
LOCAL nCountries
LOCAL nCities
LOCAL nCurrencies
LOCAL nFriends
LOCAL nChoice
IF ( m.nMainMenu != -1 .AND. ;
m.nMenuCountries != -1 .AND. ;
m.nMenuCities != -1 .AND. ;
m.nMenuCurrencies != -1 .AND. ;
m.nMenuFriends != -1)
&& Now let's add some fancy items (a separation line, a disabled
&& item, a disabled and though checked item, and a checked item)
MNU_AddItem( m.nMainMenu,0,"\-" ) && Add a separation line
i = 0 && Return value if item selected
MNU_AddItem( m.nMainMenu,i,"Item disabled",.F. ) && Create the item
ENDIF
See also
MNU_Play() , MNU_Destroy() , MNU_AddItem() , MNU_AddMenu() .
Parameters
nMenuHandle the menu handle identifying the menu to be played.
Returns
nChoice a number identifying the choice made by the user. It corresponds to the nChoice parameter of
the MNU_AddItem() function.
Example
LOCAL nMainMenu
LOCAL nMenuCountries
LOCAL nMenuCities
LOCAL nMenuCurrencies
LOCAL nMenuFriends
LOCAL nCountries
LOCAL nCities
LOCAL nCurrencies
LOCAL nFriends
LOCAL nChoice
IF ( m.nMainMenu != -1 .AND. ;
m.nMenuCountries != -1 .AND. ;
m.nMenuCities != -1 .AND. ;
m.nMenuCurrencies != -1 .AND. ;
m.nMenuFriends != -1)
ENDIF
See also
MNU_Destroy() , MNU_Make() , MNU_AddItem() , MNU_AddMenu() .
Mouse Functions
Alias
ClipCursor()
Syntax
MOU_ClipCursor( nTop,nLeft,nBottom,nRight ) lSuccess
Or…
MOU_ClipCursor( .NULL. ) lSuccess
Parameters
nTop the top position of the rectangular area the cursor will be restricted to.
nLeft the left position of the rectangular area the cursor will be restricted to.
nBottom the bottom position of the rectangular area the cursor will be restricted to.
nRight the right position of the rectangular area the cursor will be restricted to.
Or…
.NULL. when the .NULL. value is passed to MOU_ClipCursor() the function behaves like
MOU_FreeClipCursor() . When used so, the ClipCursor() alias is performing exactly as
documented in the Win32 API.
The nTop , nLeft , nBottom and nRight parameters delimit a rectangular area described in absolute pixel screen
coordinates. Therefore, should the developer want to restrict the coordinates to a particular region of a given form,
then he'll need to adjust the relative position to absolute screen position. What's more, he should notice that he needs
to pay attention to Window titles, menu height, form border width, form border height, etc. In the example below, the
accurate calculations were performed.
Returns
.T. the function always returns .T..
Example
oClipForm = CREATEOBJECT( "ClipForm" )
oClipForm.Show()
Name = "Dvlform1"
*--------------------------------------------------------------*
LOCAL nPercent
IF ( nButton == 1 )
This.Left = nXCoord
nPercent = ( ( nXCoord - ThisForm.dvlSeparator1.Left ) / ;
ThisForm.dvlSeparator1.Width ) * 100
ThisForm.dvlLabel1.caption = ALLTRIM(STR(nPercent))
ThisForm.Shape1.Width = 150 * ( nPercent / 100 )
ThisForm.Shape1.Height = 150 * ( nPercent / 100 )
ThisForm.Shape2.Height = ThisForm.Shape1.Height
ThisForm.Shape2.Left = ThisForm.Shape1.Left + ;
ThisForm.Shape1.Width + 10
ENDIF
ENDPROC
*--------------------------------------------------------------*
*--------------------------------------------------------------*
LOCAL nTitleHeight
LOCAL nBorderHeight
LOCAL nMenuHeight
LOCAL nBorderWidth
nTitleHeight = SYSMETRIC(9)
nBorderHeight = SYSMETRIC(4)
nMenuHeight = SYSMETRIC(20)
nBorderWidth = SYSMETRIC(3)
MOU_ClipCursor( nTop , ;
nLeft , ;
nTop + ThisForm.Dvlseparator1.Height, ;
nLeft + ThisForm.Dvlseparator1.Width ) && - This.Width)
ENDPROC
*--------------------------------------------------------------*
PROCEDURE shape1.RightClick()
MOU_FreeClipCursor()
ENDPROC
*--------------------------------------------------------------*
PROCEDURE shape1.Click()
LOCAL nTitleHeight
LOCAL nBorderHeight
LOCAL nMenuHeight
LOCAL nBorderWidth
nTitleHeight = SYSMETRIC(9)
nBorderHeight = SYSMETRIC(4)
nMenuHeight = SYSMETRIC(20)
nBorderWidth = SYSMETRIC(3)
MOU_ClipCursor( nTop , ;
nLeft , ;
nTop + This.Height, ;
nLeft + This.Width ) && - This.Width)
ENDPROC
*--------------------------------------------------------------*
PROCEDURE shape2.Click()
LOCAL nTitleHeight
LOCAL nBorderHeight
LOCAL nMenuHeight
LOCAL nBorderWidth
nTitleHeight = SYSMETRIC(9)
nBorderHeight = SYSMETRIC(4)
nMenuHeight = SYSMETRIC(20)
nBorderWidth = SYSMETRIC(3)
MOU_ClipCursor( nTop , ;
nLeft , ;
nTop + This.Height, ;
nLeft + This.Width ) && - This.Width)
ENDPROC
*--------------------------------------------------------------*
PROCEDURE shape2.RightClick
MOU_FreeClipCursor()
ENDPROC
*--------------------------------------------------------------*
ENDDEFINE
Alias
FreeClipCursor() .T.
Syntax
MOU_FreeClipCursor() .T.
Parameters
None.
Returns
.T. the function always returns .T..
Example
See MOU_ClipCursor() example.
See also
MOU_ClipCursor()
Syntax
MOU_isdown() lIsDown
Parameters
None.
Returns
lIsDown .T. if the left mouse button is down
Example
&& Waiting until the left button is depressed
DO WHILE( MOU_isdown() )
ENDDO
Syntax
MOU_IsLeftMouseDown() lIsSet
Parameters
None.
Returns
lIsSet .T. if the left mouse button is down.
Syntax
MOU_IsLeftMouseUp() lIsSet
Parameters
None.
Returns
lIsSet .T. if the left mouse button is up.
Syntax
MOU_IsMiddleMouseDown() lIsSet
Parameters
None.
Syntax
MOU_IsMiddleMouseUp() lIsSet
Parameters
None.
Returns
lIsSet .T. if the middle mouse button is up.
Syntax
MOU_IsRightMouseDown() lIsSet
Parameters
None.
Returns
lIsSet .T. if the right mouse button is down.
Syntax
MOU_IsRightMouseUp() lIsSet
Returns
lIsSet .T. if the right mouse button is up.
Syntax
MOU_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\MOUSE.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
.T. the function always returns .T..
Example
* Simulates a click where the mouse is
MOU_LeftDown()
MOU_LeftUp()
Parameters
None.
Example
* Simulates a click where the mouse is
MOU_LeftDown()
MOU_LeftUp()
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Example
* Simulates a right click where the mouse is
MOU_RightDown()
MOU_RightUp()
Parameters
None.
Returns
.T. the function always returns .T..
Example
* Simulates a right click where the mouse is
MOU_RightDown()
MOU_RightUp()
Alias
MOU_SwapButton(), MOU_SwapButtons(), MOU_SwapMouseButton(), MOU_SwapMouseButtons(), SwapMouseButton().
Syntax
MOU_Swap( lSwap ) lSuccess
Parameters
lSwap .T. to swap mouse buttons; .F. to restore mouse buttons.
Returns
lSuccess .T.. if the function was successful; .F. if not.
Example
IF ( MOU_Swap( .T. ) )
? "Brace yourself! Enjoy the mouse now!"
ENDIF
MQSeries Functions
Functions Synopsis
MQSeries is the leading product in the field of messaging and queuing. It is vastly used in Banks and Pharmaceutical
Industries and it has proved to be stable and reliable. FOCUS.FLL per se does not provide access to the MQSeries
API: FOCUSMQS.FLL and FOCUSMQC.FLL do!
Sending a message
Reading a message
There is quite some overhead while connecting/disconnecting to/from a Queue Manager. Opeing/Closing queues is
faster but still creates some overhead. Therefore you might want to connect only once to the Queue Manager and open
only once the queue.
UNDER CONSTRUCTION
*************
Parameters
None.
Returns
nSuccess 0 if the current queue is successfully closed; otherwise, please refer to your MQSeries
documentation.
Example
?????
Parameters
szQueueManager MQSeries Queue Manager.
Returns
nSuccess 0 if successfully connected; otherwise, please refer to your MQSeries documentation.
Example
?????
Parameters
None.
Returns
nSuccess 0 if successfully disconnected; otherwise, please refer to your MQSeries documentation.
Example
?????
Value Description
Returns
nSuccess 0 if szQueue is successfully opened; otherwise, please refer to your MQSeries documentation.
Example
??????????
Messaging Functions
Functions Synopsis
FOCUS.FLL provides a basic messaging mechanism. It is working on the Post Office scheme, which basically means
that all messages are stored in a common place: the Post Office!
Appli1 Appli7
Appli2 Post
Office
Appli3 Appli5
Appli4 Appli6
For different applications to exchange messages, they all have to agree on a common Post office and a common
Settings File. This is done through the MSG_PostOffice() function. For example, by issuing the following command,
many different applications specify they rely on the Post Office located on the WALK2227 machine, in the Post
Office directory, and that the Settings File to take in consideration is the PO.INI :
Each application should be uniquely identified. In our example, we have 7 different applications running on different
machines but they all access one common central Post Office and they all use the same Settings File.
[MESSAGES]
Counter=111
[SEQUENCING]
next=111
[ACCOUNTS]
APPLI1=00000001
APPLI2=00000002
APPLI3=00000003
[DEADLETTER]
Dir=Dead
[APPLI1]
Dir=00000001
Comment=Elected PC
[APPLI]
Dir=00000002
Comment=mailbox of COMPAQ 166 MHz
[APPLI3]
Dir=00000003
Comment=mailbox of Dominique's PC
Post Office
Technically, the Post Office is nothing else but a shared directory on a network. Each application (recipient) is uniquely
identified and is granted its own directory within the Post Office. For example, on the WALK2227 machine, the central
Post office is located in the Post Office directory, and Appli1 is hooked to the 00000001 directory within the
Post Office; Appli2 is hooked to the 00000002 directory, and so on (according to the structure of the Settings File).
Imagine the following situation : you have 3 applications, Appli1 , Appli2 and Appli3 . Appli1 and Appli2 are
located on the MACHINE1 computer while Appli3 is placed on MACHINE2 . You want the Post Office to be located on
a third machine, MACHINE3 , in the BP directory. The first thing to do is to create a Post Office Settings File similar to:
[MESSAGES]
Counter=0
[SEQUENCING]
next=0
[ACCOUNTS]
APPLI1=00000001
APPLI2=00000002
APPLI3=00000003
[DEADLETTER]
Dir=Dead
[APPLI1]
Dir=00000001
[APPLI]
Dir=00000002
[APPLI3]
Dir=00000003
You place this Settings File in the BP directory of the Post Office (\\MACHINE3\BP , a directory that you share for both
Read and Write operations) and you name it PO.INI . On MACHINE3 , directory BP, you will need to create the
subdirectories that each application is hooked to, in other words 00000001 , 00000002 , and 00000003 .
Now, you're ready to use Messaging Functions of FOCUS.FLL . For example, the following code that gets executed in
Appli1 will broadcast a message to the other two applications that are served by the same Post Office:
MSG_PostOffice( "\\MACHINE3\BP\PO.INI" )
Now one might ask : How do I know when a message has arrived? The answer is clear and obvious (for one that
already pointed a head in the direction of the Notification Functions) : you simply set a notification hook.
For example, Appli3 might want to monitor its own directory on the Post office to be warned whenever a new message
arrives. Therefore it simply needs to use the following code :
LOCAL nHandle
LOCAL lSubDir
lSubDir = .T.
PROCEDURE MyMsgHandler( n )
LOCAL cMessage
**********************************************************************
* PURPOSE : Whenever thios procedure is called it means that there is
* a new message coming in the mailbox of this application
**********************************************************************
RETURN
An application can dynamically create multiple Post Offices although one and only one Post Office is the current Post
Office. To do so, it must call the MSG_CreatePostOffice() , and MSG_CreateAccount() functions of
FOCUS.FLL . This allows intelligent applications to dialog between each other beyond the knowledge of any user.
FOCUS.FLL provides also some statistical functions (although they are very few) to tighter control messages :
MSG_TotalMessagesSent() , MSG_BytesSent() , MSG_MessagesSent() , MSG_MessagesRead() ,
MSG_MessagesReceived() .
Parameters
szFrom sender identification.
Returns
lSuccess .T. if message was successfully sent; .F. if not. There is no message sent to the sender.
Example
MSG_PostOffice( "\\WALK2227\Post Office\PO.INI" )
IF ( ! MSG_Broadcast( "ME","System","Life","ME still alive" ) )
? "Message cannot be sent",MSG_LastError()
ENDIF
Parameters
None.
Returns
nBytes number of bytes sent. Only the body of a message is taken in account.
Example
? "Average message length:",MSG_BytesSent()/MSG_TotalMessagesSent()
Syntax
MSG_count( szRecipient ) nMessages
Returns
nMessages the number of waiting messages or -1 if the recipient is unknown.
Example
? MSG_PostOffice( "C:\PO.INI" )
? MSG_count( "APPLI5" ) && 0
? MSG_count( "UNKNOWN RECIPIENT" ) && -1
? MSG_send( "APPLI1","APPLI5","Subject","Category",TTOC(DATETIME()) ) && .T.
? MSG_count( "APPLI5" ) && 1
? MSG_send( "APPLI1","APPLI5","Subject","Category",TTOC(DATETIME()) ) && .T.
? MSG_count( "APPLI5" ) && 2
Parameters
szAccount account identification.
Returns
lSuccess .T. if the account was successfully created; .F. if not.
Example
IF ( MSG_CreatePostOffice( "\\WALK2227\Post Office\PO.INI" ) )
IF ( MSG_CreateAccount( "Account1","00000001" ) )
? "Account successfully recognized"
ENDIF
ELSE
? "Post Office cannot be created"
ENDIF
Parameters
szPO Post Office Settings file and location.
Returns
lSuccess .T. if the Post Office was successfully created; .F. if not. The current Post Office is changed to
szPO .
Example
IF ( MSG_CreatePostOffice( "\\WALK2227\Post Office\PO.INI" ) )
IF ( MSG_CreateAccount( "Account1","00000001" ) )
Parameters
szAccount account identification.
lSubdir deletes the directory in which messages of this account have been stored including all messages
that are still to be read.
Returns
lSuccess .T. if the account was successfully deleted; .F. if not. If the return value is .F., call
MSG_LastError() to get a more explicit reason.
Syntax
MSG_DeleteUnread( szAccount ) nDeleted
Parameters
szAccount account identification.
Returns
nDeleted number of messages actually deleted or –1 if the account is not found or the current Post Office
not set.
Example
* Simulates a right click where the mouse is
MOU_RightDown()
MOU_RightUp()
Syntax
MSG_GetAllAccounts() szAccounts
Returns
szAccounts a tokenized string with all accounts defined in the current Post Office. Each token is separated
by a ";".
Example
LOCAL nAccounts
LOCAL OldSep
LOCAL i
LOCAL szAccounts
MSG_PostOffice( "\\MYSERVER\Bureau\BP.INI" )
IF ( MSG_IsPostOfficeAccessible() )
m.szAccounts = MSG_GetAllAccounts()
IF ( ! EMPTY( m.szAccounts ) )
FOR i = 1 TO m.nAccounts
? "Account : " + STR_ntoken( i,m.szAccounts )
NEXT
ENDIF
ENDIF
STR_setsep( m.OldSep )
Parameters
szRecipient recipient identification.
Returns
szDir the mailbox directory or an empty string is the mailbox directory cannot be found in the
Settings File. When an empty string is returned, use the MSG_LastError() function to
determine the cause of the problem.
Example
? MSG_PostOffice("C:\PO.INI")
? MSG_GetDir("APPLI5") && "C:\00000005"
See also
MSG_GetSubDir()
Parameters
None.
Returns
szSep the separator used internally by FOCUS.FLL to tokenize a message.
Example
LOCAL cMessage
LOCAL OldSep
LOCAL szFrom
LOCAL szTo
LOCAL szDateTime
LOCAL szSubject
LOCAL szCategory
LOCAL szBody
LOCAL nTokens
IF ( EMPTY( szMessage ) )
? "Empty message"
ELSE
OldSep = STR_setsep( MSG_GetSep() )
nTokens = STR_numtok( szMessage )
IF ( nTokens == 6 )
szFrom = STR_ntoken( 1,szMessage )
szTo = STR_ntoken( 2,szMessage )
szDateTime = STR_ntoken( 3,szMessage )
szSubject = STR_ntoken( 4,szMessage )
szCategory = STR_ntoken( 5,szMessage )
szBody = STR_ntoken( 6,szMessage )
ELSE
? "Unexpected number of tokens"
ENDIF
STR_setsep( OldSep )
ENDIF
Parameters
szRecipient recipient identification.
Returns
szDir the mailbox directory or an empty string is the mailbox directory cannot be found in the
Settings File. When an empty string is returned, use the MSG_LastError() function to
determine the cause of the problem.
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 377
Messaging Functions
Example
? MSG_PostOffice("C:\PO.INI")
? MSG_GetSubDir("APPLI5") && "00000005"
See also
MSG_GetDir()
Parameters
szAccount account identification.
Returns
lExist .T. if szAccount exists in current Post Office; .F. if not.
Example
MSG_PostOffice( "C:\PO.INI" )
IF ( MSG_IsPostOfficeAccessible() )
IF ( MSG_IsAccount( "SYSTEM" ) )
IF ( MSG_send( "ME","SYSTEM","Test","Category","My message" )
? "SYSTEM has received",MSG_MessagesReceived( "SYSTEM" ),"messages"
ENDIF
ENDIF
ENDIF
Syntax
MSG_IsPostOfficeAccessible() lSuccess
Parameters
None.
Returns
lSuccess .T. if the Post Office can be contacted; .F. if not.
Example
LOCAL nAccounts
LOCAL OldSep
LOCAL i
LOCAL szAccounts
MSG_PostOffice( "\\WALK2227\Bureau\BP.INI" )
szAccounts = MSG_GetAllAccounts()
IF ( ! EMPTY( szAccounts ) )
FOR i = 1 TO nAccounts
? "Account : " + STR_ntoken( i,szAccounts )
NEXT
ENDIF
ENDIF
STR_setsep( OldSep )
Syntax
MSG_LastError() szError
Parameters
None.
Returns
szError message describing the last error that occurred in messaging functions.
Example
LOCAl nMessages
? MSG_PostOffice("C:\PO.INI")
IF ( nMessages == -1 )
? MSG_LastError() && "Cannot find recipient"
ENDIF
Syntax
MSG_LastVersion() szLastVersion
Parameters
None.
Parameters
szRecipient recipient identification.
Returns
nMessages number of messages.
Parameters
szRecipient recipient identification.
Returns
nMessages number of messages.
Parameters
szOriginator originator identification.
Returns
nMessages number of messages.
Returns
szPOLoc current Post Office location.
Example
MSG_PostOffice( "\\WALK2227\Post Office\PO.INI" )
? MSG_PO() && "\\WALK2227\Post Office"
? MSG_POFile() && "PO.INI"
Parameters
None.
Returns
szFile current Post Office settings file.
Example
MSG_PostOffice( "\\WALK2227\Post Office\PO.INI" )
? MSG_PO() && "\\WALK2227\Post Office"
? MSG_POFile() && "PO.INI"
Syntax
MSG_PostOffice( szPO ) szCurrentPO
Parameters
sz Post Office location and settings file. The settings file is typically an INI file.
Returns
szCurrentPO current Post office location and settings file.
Example
MSG_PostOffice( "\\WALK2227\Post Office\PO.INI" )
? MSG_PO() && "\\WALK2227\Post Office"
? MSG_POFile() && "PO.INI"
Parameters
szRecipient recipient identification.
lDelete should the message be deleted? By default, the message is deleted from the Post office.
Returns
szMessage the message string is composed of 6 tokens. Each token is separated by a CHR(1) . The
separator can be queried by the programmer by the MSG_GetSep() function.
Example
LOCAL szMessage
LOCAL OldSep
LOCAL szFrom
LOCAL szTo
LOCAL szDateTime
LOCAL szSubject
LOCAL szCategory
LOCAL szBody
LOCAL nTokens
IF ( EMPTY( szMessage ) )
? "Empty message"
ELSE
OldSep = STR_setsep( MSG_GetSep() )
nTokens = STR_numtok( szMessage )
IF ( nTokens == 6 )
szFrom = STR_ntoken( 1,szMessage )
szTo = STR_ntoken( 2,szMessage )
szDateTime = STR_ntoken( 3,szMessage )
szSubject = STR_ntoken( 4,szMessage )
szCategory = STR_ntoken( 5,szMessage )
szBody = STR_ntoken( 6,szMessage )
ELSE
? "Unexpected number of tokens"
ENDIF
STR_setsep( OldSep )
ENDIF
Parameters
szFrom sender identification.
Returns
lSuccess .T. if message was sent successfully; .F. if not.
Example
MSG_PostOffice( "\\WALK2227\Post Office\PO.INI" )
IF ( ! MSG_Send( "ME","YOU","Subject","Topic","This is my message" ) )
? "Message cannot be sent",MSG_LastError()
ENDIF
Parameters
szDir directory to monitor for messages.
Returns
lSuccess .T. if directory notification mechanism successfully hooked to szDir ; .F. if not.
Example
Parameters
None.
Returns
szConstant "The command completed successfully".
Example
&& Call whatever MSG function, and then simply test whether
&& MSG_LastError() is identical to MSG_Successful()
Parameters
None.
Returns
nMessages number of messages sent.
Example
? "Average message length:",MSG_BytesSent()/MSG_TotalMessagesSent()
Mathematical Functions
To convert degrees to radians, multiply degrees by pi/180, or use DTOR() . To convert radians to degrees, multiply
radians by 180/pi or use the RTOD() function.
MTH_atan() is the inverse trigonometric function of TAN() , which takes an angle as its argument and returns the
ratio of two sides of a right triangle.
Alias
ATAN(), ATN()
Syntax
MTH_atan( x ) nRadians
Parameters
x ratio of two sides of a right triangle.
Returns
nRadians corresponding angle in radians.
Syntax
MTH_combinations( x,n ) z
Parameters
x number of choices.
Returns
z number of combinations = xPn = x! / (x-n)! The Lotto (or Loto) is a good candidate for the
number of different solutions. If you have 42 balls in total, and you need to get 6 out of that,
then the number of solutions is 42C6 = 42P6 / 6! … which makes 5245786 .
C Code
double FWFactorial( int x )
/*-----------------------*/
{
double y=1;
x = abs( x );
while ( x > 1 )
{
y *= (double) x--;
}
return ( y );
}
double result;
int i=1;
x = abs( x );
n = abs( n );
result = (double) x;
return( result );
}
Syntax
MTH_distance( x1,y1,x2,y2 ) nDistance
Parameters
x1 x position (left).
y1 y position (top).
x2 x position (left).
y2 y position (top).
Returns
nDistance distance between (x1,y1) and (x2,y2).
Syntax
MTH_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\FWMATH.C-Mon Oct 19 15:55:22 1998" .
y = ax + b
Syntax
MTH_origin( x1,y1,x2,y2 ) nOrigin
Parameters
x1 abscisse du premier point.
Returns
origin Ordonnée à l'origine.
y = ax + b
Syntax
MTH_pente( x1,y1,x2,y2 ) pente
Parameters
x1 abscisse du premier point.
Returns
pente pente de la droite. Si une droite ne varie pas en abscisse ainsi que l'illustre la capture d'écran
qui suit, alors la valeur retournée par MTH_pente() devrait représenter l'infini ().
Syntax
MTH_permutations( x,n ) z
Parameters
x number of choices.
Returns
z number of permutations = xPn = x! / (x-n)!
See also
MTH_combinations()
Network Functions
Parameters
szRes local name.
Returns
lSuccess .T. is the function succeeds; .F. otherwise.
Example
&& Disconnect network resource; force disconnection even if there are open
&& files or jobs on the connection.
? NET_CancelConnection( "K:",.T. )
See also
NET_CancelConnection()
Parameters
nType 1 for disks resources (default); 2 for print resources.
Returns
lSuccess .T. if the function is successful; .F. otherwise.
Example
IF ( ! NET_ConnectionDialog() )
? "Error:",NET_LastError()
ENDIF
See also
NET_DisconnectDialog()
Parameters
None.
Returns
lSuccess .T. if the function is successful; .F. otherwise.
Example
NET_DisconnectDialog()
See also
NET_ConnectionDialog()
Parameters
None.
Returns
szConnections a tokenized string indicating all the connections. The string is formatted in such a way that the
local resource is mentioned first, then a caret ( "^") is placed, and finally the remote resource is
mentioned. Multiple connections are separated by a ";" . For example the following string
denotes 2 connections :
Syntax
NET_EthernetAddress( [n] ) nAddress|szAddress
Parameters
n the address to obtain. Optional parameter. If passed n must be >= 1 and <= 6. When not
passed, the full Ethernet Address is returned as a character string.
Returns
nAddress the desired address. –1 is returned when the Ethernet Address can’t be determined.
szAddress the full Ethernet address is returned when the n parameter is not passed to the function.
Parameters
None.
Returns
szComputer computer name. This name is established at system startup, when it is initialized from the
registry. If function was unsuccessful, it simply returns an empty string ( "").
Parameters
None.
Returns
szHost standard host name.
Syntax
NET_GetUserName() szUser
Parameters
None.
Returns
szUser user name.
Syntax
NET_InternetTime( [szHost] ) iUTC
Parameters
szHost optional host. By default, the internal host used by FOCUS.FLL is "time.nrc.ca" . The
following hosts implement Time protocol on the Internet:
time-a.nist.gov
time-b.nist.gov
time-a.timefreq.bldrdoc.gov
time-b.timefreq.bldrdoc.gov
time-c.timefreq.bldrdoc.gov
utcnist.Colorado.edu
time.nist.gov
time-nw.nist.gov
nist1.datum.com
nist.dc.glassey.com
nist.ny.glassey.com
nist.sj.glassey.com
nist1.aol-ca.truetime.com
nist1.aol-va.truetime.com
Returns
iUTC UTC time as integer.
Example
? TIM_CTime( NET_InternetTime( "time-nw.nist.gov" ) ) && Sun Mar 10 20:31:23 2002
Parameters
None.
Returns
szLastError last error that occurred while using the NET_*() functions.
Example
nEthernetID = NET_EthernetAddress(1)
nEthernetID = NET_EthernetAddress(-1)
Syntax
NET_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\NET.C-Mon Oct 19 15:55:22 1998" .
Parameters
nLevel user level.
Returns
nOldLevel previous user level.
Parameters
nUsers number of users that can log simultaneously into your application.
Returns
nOldUsers previous number of users.
NET_mode() :?????????
Special
Not ready yet.
Parameters
nMode ????????
Returns
nOldMode ???????.
Parameters
szCommand FoxPro command.
Returns
.T. the function always returns .T. .
Parameters
szName computer name.
Windows 95 : If this string contains one or more characters that are outside the standard
character set, those characters are coerced into standard characters.
Windows NT : If this string contains one or more characters that are outside the standard
character set, NET_SetComputerName() returns .F. . It does not coerce the characters
outside the standard set.
The standard character set includes letters, numbers, and the following symbols : ! @ # $ %
^ & ' ) ( . - _ { } ~ .
Returns
lSuccess .T.. if function was successful, .F. if not.
Example
OldName = NET_GetComputerName()
? NET_SetComputerName( "PAT78" )
? NET_SetComputerName( OldName )
Parameters
lStatus .T. indicates that FOCUS should take care of network settings; .F. otherwise.
Returns
lOldStatus previous status of the network flag.
Parameters
nTimeInterval time interval in milliseconds.
Returns
nNetTimer time identifier.
Returns
.T. the function always returns .T. .
Parameters
nUserNo most recently logged user number.
Returns
nOldUserNo previous most recently logged user number.
Notification Functions
Functions Synopsis
File (or Directory) Notification functions are handy possibilities of FOCUS. Imagine being kept informed whenever there
is a change in a directory. That's what the Notification Functions are all about in fact.
These functions request that the operating system signal a change notification handle whenever it detects an
appropriate change.
To track these changes, FOCUS.FLL uses an internal timer whose frequency is set to 5000 milliseconds. The frequency
can be freely adjusted.
1. NOT_set()
2. <in between, FOCUS.FLL will call a procedure that you passed to NOT_set() whenever
there is a change such as the ones you want to track down>
3. NOT_kill()
Parameters
nMilliSeconds number of milliseconds used by the internal timer of FOCUS. Any change to the directories to
monitor will be reported within that number of milliseconds. This parameter is optional; if it's
not passed, the function simply returns the current frequency.
When setting up a new frequency, the internal timer of FOCUS is re-activated.
Returns
nOldFrequency current frequency.
Example
LOCAL nHandle
IF ( NOT_HandlesFree() > 0 )
NOT_Frequency( 1000 ) && Any change will be reported within 1 sec
nHandle = NOT_set( "C:\","WarnMe",.T.,24 )
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
ELSE
MESSAGEBOX( "Cannot set notification. Free up some handles.",48,"Notification" )
ENDIF
Parameters
None.
Returns
nHandles maximum number of notification handles.
Returns
nHandles number of free handles.
Example
LOCAL nHandle
IF ( NOT_HandlesFree() > 0 )
nHandle = NOT_set( "C:\","WarnMe",.T.,24 )
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
ELSE
MESSAGEBOX( "Cannot set notification. Free up some handles.",48,"Notification" )
ENDIF
Parameters
nHandle handle identifying the notification to be queried. Be careful to pass a handle whose value is
comprised between NOT_MinHandle() and NOT_MaxHandle() ; otherwise illegal operations
can appear.
VALUE DESCRIPTION
1 Directory to monitor
2 Associated procedure
3 Subdir
4 Flags
5 Suspended
6 Strategy
7 Cargo member
Returns
szInfo either the directory name or the trigger procedure.
nInfo flags.
Example
LOCAL nHandle
IF ( NOT_HandlesFree() > 0 )
IF ( nHandle != -1 )
? NOT_info( nHandle,1 ) && "C:\"
? NOT_info( nHandle,2 ) && "WarnMe"
? NOT_info( nHandle,3 ) && .T.
? NOT_info( nHandle,4 ) && 24
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
ELSE
MESSAGEBOX( "Cannot set notification. Free up some handles.",48,"Notification" )
ENDIF
Parameters
None.
Returns
lTimer .T. internal timer of FOCUS is alive; .F. if not.
Example
? NOT_Frequency( 1000 ) && This statement forces the timer to be active
? NOT_IsTimer() && .T.
? NOT_KillTimer() && Kill the internal timer
? NOT_IsTimer() && .F.
? NOT_Frequency( 2000 ) && This statement forces the timer to be active
? NOT_IsTimer() && .T.
Syntax
NOT_Kill( nHandle ) lSuccess
Parameters
nHandle handle identifying the notification to be killed.
Returns
lSuccess .T. indicates that the notification was killed successfully; .F. otherwise. All notification
handles set by an application should be killed; otherwise they all remain in force. When the SET
LIBRARY TO statement is issued, unloading FOCUS.FLL from memory, FOCUS releases all
notifications automatically.
Parameters
None.
Returns
.T. the function always returns .T. . The internal timer of FOCUS.FLL can be re-established with
the NOT_Frequency() function.
Example
? NOT_Frequency( 1000 ) && This statement forces the timer to be active
? NOT_IsTimer() && .T.
? NOT_KillTimer() && Kill the internal timer
? NOT_IsTimer() && .F.
Syntax
NOT_LastError() szErrorString
Parameters
None.
Returns
szErrorString last error string.
Example
LOCAL nDummyHandle
IF ( nDummyHandle == -1 )
? NOT_LastError() && "The system cannot find the file specified."
ENDIF
Syntax
NOT_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\NOTIFICATIONS.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
nHandle highest potential handle.
Parameters
None.
Returns
nHandle lowest potential handle.
Parameters
szAll a character string that represents all the notifications set. This character string is usually set by
a previous call to NOT_SaveAll() .
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL szAll
szAll = NOT_SaveAll()
NOT_Zapll()
IF ( ! NOT_RestoreAll( szAll ) )
? "Cannot reset all notifications"
ENDIF
Parameters
nHandle handle identifying the notification to be resumed. Be careful to pass a handle whose value is
comprised between 0 and 49; otherwise illegal operations can appear.
Returns
.T. the function always returns .T. .
Example
LOCAL nHandle
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
NOT_Suspend( nHandle )
IF ( nLogFile != -1 )
FPUTS( "Somebody touched my C drive (" + TTOC( DATETIME() ) + ")" )
FCLOSE( nLogFile )
ENDIF
RETURN
Parameters
None.
Returns
.T. the function always returns .T. .
Example
LOCAL nHandle
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
NOT_SuspendAll()
IF ( nLogFile != -1 )
FPUTS( "Somebody touched my C drive (" + TTOC( DATETIME() ) + ")" )
FCLOSE( nLogFile )
ENDIF
NOT_ResumeAll()
RETURN
Parameters
None.
Returns
szAll a character string that represents all the notifications set.
Example
LOCAL szAll
szAll = NOT_SaveAll()
NOT_ZapAll()
IF ( ! NOT_RestoreAll( szAll ) )
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 409
Notification Functions
? "Cannot reset all notifications"
ENDIF
Parameters
szDir directory to monitor.
szProc procedure to execute whenever a change is detected. Only the name of the procedure should
be mentioned. This procedure is passed a parameter: the handle that caused the procedure to
be called.
Value Meaning
FILE_NOTIFY_CHANGE_FILE_NAME Any filename change in the watched directory or subtree
0x00000001
causes a change notification wait operation to return.
Changes include renaming, creating, or deleting a filename.
FILE_NOTIFY_CHANGE_DIR_NAME Any directory-name change in the watched directory or
0x00000002
subtree causes a change notification wait operation to return.
Changes include creating or deleting a directory.
FILE_NOTIFY_CHANGE_ATTRIBUTES Any attribute change in the watched directory or subtree
0x00000004
causes a change notification wait operation to return
FILE_NOTIFY_CHANGE_SIZE Any file-size change in the watched directory or subtree
0x00000008
causes a change notification wait operation to return. The
operating system detects a change in file size only when the
file is written to the disk. For operating systems that use
extensive caching, detection occurs only when the cache is
sufficiently flushed.
FILE_NOTIFY_CHANGE_LAST_WRITE Any change to the last write-time of files in the watched
0x00000010
directory or subtree causes a change notification wait
operation to return. The operating system detects a change
to the last write-time only when the file is written to the disk.
For operating systems that use extensive caching, detection
occurs only when the cache is sufficiently flushed.
FILE_NOTIFY_CHANGE_LAST_ACCESS
0x00000020
FILE_NOTIFY_CHANGE_CREATION
0x00000040
Returns
nHandle notification handle or –1 if the function is not successful. 50 notifications can be set in total.
Example
LOCAL nHandle
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
Parameters
nHandle handle identifying the notification to be suspended. Be careful to pass a handle whose value is
comprised between 0 and 49; otherwise illegal operations can appear.
Returns
nStrategy strategy in use before entering the function.
Example
LOCAL nHandle
IF ( nHandle != -1 )
&& This means that WarnMe is a program (EXE) that should be
&& launched and it should receive one parameter (the handle
&& of the notification mechanism)
NOT_Strategy( nHandle,2 )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
Parameters
None.
Returns
szConstant "The command completed successfully".
Example
&& Call whatever NOT function, and then simply test whether
&& NOT_LastError() is identical to NOT_Successful()
On some circumstances, you might temporarily stop notifications, especially when you will
trigger a notification change within the procedure that handles notification changes. That's why
the NOT_Suspend() function is provided.
Returns
.T. the function always returns .T. .
Example
LOCAL nHandle
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
NOT_Suspend( nHandle )
IF ( nLogFile != -1 )
FPUTS( "Somebody touched my C drive (" + TTOC( DATETIME() ) + ")" )
FCLOSE( nLogFile )
ENDIF
NOT_Resume( nHandle )
RETURN
Parameters
None.
Returns
.T. the function always returns .T. .
Example
LOCAL nHandle
IF ( nHandle != -1 )
MESSAGEBOX( "Notification set successfully",64,"Notification" )
ELSE
MESSAGEBOX( "Cannot set notification",48,"Notification" )
ENDIF
IF ( nLogFile != -1 )
FPUTS( "Somebody touched my C drive (" + TTOC( DATETIME() ) + ")" )
FCLOSE( nLogFile )
ENDIF
NOT_ResumeAll()
RETURN
Parameters
None.
Returns
.T. the function always returns .T. .
Example
LOCAL szAll
szAll = NOT_SaveAll()
NOT_ZapAll()
IF ( ! NOT_RestoreAll( szAll ) )
? "Cannot reset all notifications"
ENDIF
NTEvents Functions
Functions Synopsis
Many applications record errors and events in various proprietary error logs. These proprietary error logs have
different formats and display different user interfaces. Moreover, you cannot merge the data to provide a complete
report. Therefore, you need to check a variety of sources to diagnose problems. Event logging in Microsoft® Windows
NT®/Windows® 2000 provides a standard, centralized way for applications (and the operating system) to record
important software and hardware events. The event-logging service stores events from various sources in a single
collection called an event log. Windows NT/Windows 2000 also supplies Event Viewer for viewing the logs, and a
programming interface for examining the logs.
The NTE_*() functions of FOCUS.FLL are especially useful to directly interface with the standard services of Windows
NT/Windows 2000.
Event Types3
There are 5 types of events. All event classifications have well-defined common data and can optionally include
event-specific data. The application indicates the event type when it reports an event. Each event must be of a
single type. The Windows NT/Windows 2000 Event Viewer uses this type to determine which icon to display in the
list view of the log.
The following table describes the event types used in event logging.
Logging Guidelines
Event logs store records of significant events on behalf of Windows NT/Windows 2000 and applications running
on Windows NT/Windows 2000. Because the logging functions are general purpose, you must decide what
information is appropriate to log. Generally, you should log only information that could be useful in diagnosing a
hardware or software problem. Event logging is not intended to be used as a tracing tool4.
Resource problems. If an application gets into a low-memory situation (caused by a code bug or inadequate
memory) that degrades performance, logging a warning event when memory allocation fails might provide a
clue about what went wrong.
Hardware problems. If a device driver encounters a disk controller time-out, a power failure in a parallel port, or
a data error from a network or serial card, logging information about these events can help the system
administrator diagnose hardware problems. The device driver logs the error.
3
Extracted from Microsoft documentation and provided here for the sake of simplicity.
4
FOCUS.FLL provides additional functions for tracing tools (LOG_*() and TRA_*()).
Information events. A server application (such as a database server) records a user logging on, opening a
database, or starting a file transfer. The server can also log error events it encounters (cannot access file, host
process disconnected, and so on), a corruption in the database, or whether a file transfer was successful.
Logfiles
Applications and services use the Application logfile. Device drivers use the System logfile. The system will
generate success and failure audit events in the Security log when auditing is turned on.
<TO BE CONTINUED>
Parameters
hLog Handle to the event log to be cleared.
szBackupFile Optional parameter. The name of an optional backup file before the event log is cleared.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL hLog
LOCAL szBackup
IF ( m.hLog != -1 )
m.szBackup = "D:\APPLICATION.NTLOG"
IF ( NTE_ClearEventLog( m.hLog,m.szBackup ) )
? "The application log has been cleared successfully"
ELSE
? "The application log could not be cleared"
ENDIF
NTE_CloseEventLog( m.hLog )
ENDIF
Parameters
hLog Handle to the event log to be closed.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL hLog
LOCAL szBackup
IF ( m.hLog != -1 )
m.szBackup = "D:\APPLICATION.NTLOG"
IF ( NTE_ClearEventLog( m.hLog,m.szBackup ) )
? "The application log has been cleared successfully"
ELSE
? "The application log could not be cleared"
ENDIF
Parameters
szComputerName Name of the computer (usually the name of the machine the application runs on).
szType Name of the log to open ("Application" , "Security" ," System" ).
Returns
hLog Handle to the given application log or -1 if the function failed.
Example
LOCAL hLog
LOCAL szBackup
IF ( m.hLog != -1 )
m.szBackup = "D:\APPLICATION.NTLOG"
IF ( NTE_ClearEventLog( m.hLog,m.szBackup ) )
? "The application log has been cleared successfully"
ELSE
? "The application log could not be cleared"
ENDIF
NTE_CloseEventLog( m.hLog )
ENDIF
Numeric Functions
Parameters
n the integer number to transform.
nRadix the radix to take into account. Must be in the range 2 – 36.
Returns
szNum the string corresponding to the transformation of n in radix nRadix .
Example
? NUM_base( 3, 2 ) && "11"
? NUM_base( 10,16 ) && "a"
? NUM_base( 32,16 ) && "20"
? NUM_base( 7, 8 ) && "7"
? NUM_base( 9, 8 ) && "11"
See also
NUM_radix() .
Parameters
n number to test.
Returns
lBetween .T. if n >= nLow and n <= nHigh; .F. otherwise
Example
? NUM_Between( 10,7,20 ) && .T.
? NUM_Between( 10,15,20 ) && .F.
Returns
nHigh high byte of n.
Example
? NUM_BinHi( 255 ) && 0
? NUM_BinHi( 256 ) && 1
? NUM_BinHi( 257 ) && 1
? NUM_BinHi( 512 ) && 2
? NUM_BinHi( 7894 ) && 30
See also
NUM_BinLow() .
Parameters
n number to process.
Returns
nLow low byte of n.
Example
? NUM_BinLow( 255 ) && 255
? NUM_BinLow( 256 ) && 0
? NUM_BinLow( 257 ) && 1
? NUM_BinLow( 512 ) && 0
? NUM_BinLow( 7894 ) && 214
? NUM_BinLow( 7894 ) == 7894 % 256 && .T.
See also
NUM_BinHi() .
Parameters
n1 integer #1.
n2 integer #2.
Example
? NUM_gcd( 6, 9 ) && 3
? NUM_gcd( 6, 6 ) && 6
? NUM_gcd( 6,78 ) && 6
? NUM_gcd( 6,77 ) && 1
? NUM_gcd( 3,15 ) && 3
? NUM_gcd( 4,15 ) && 1
? NUM_gcd( 5,15 ) && 5
Parameters
n the integer from which to obtain the next prime number.
Returns
nNext next prime number.
Example
? NUM_IsPrime( 101 ) && .T.
? NUM_IsPrime( 103 ) && .T.
? NUM_GetNextPrime( 103 ) && 107
? NUM_GetNextPrime( 5737 ) && 5741
? NUM_GetPrevPrime( 5741 ) && 5737
? NUM_GetPrevPrime( 7583 ) && 7577
See also
NUM_IsPrime() , NUM_GetPrevPrime() .
Parameters
n the integer from which to obtain the previous prime number.
Returns
nPrevious previous prime number.
Example
? NUM_IsPrime( 101 ) && .T.
? NUM_IsPrime( 103 ) && .T.
? NUM_GetNextPrime( 103 ) && 107
? NUM_GetNextPrime( 5737 ) && 5741
? NUM_GetPrevPrime( 5741 ) && 5737
? NUM_GetPrevPrime( 7583 ) && 7577
Parameters
n number to process.
Returns
szHexa hexadecimal equivalent of n.
Example
? NUM_hexa( 255 ) && "FF"
See also
STR_hexa() , STR_htos() , NUM_htoi()
Parameters
szHexa hexadecimal number to process.
Returns
n integer which is the equivalent of the hexadecimal string.
Example
? NUM_hexa( 255 ) && "FF"
? NUM_htoi( "FF" ) && 255
See also
STR_hexa() , STR_htos() , NUM_htoi()
Parameters
nInteger seed. Optional parameter. If the seed number is not passed, the NUM_InitRandom() function
uses the current time of the PC.
Returns
.T. the function always returns .T. .
See also
NUM_RandomInt() , NUM_RandomDouble() ,
Parameters
None.
Returns
n maximum value of an integer.
Example
? NUM_int_max() && 2147483647
See also
NUM_int_min()
Parameters
None.
Returns
n minimum value of an integer.
Example
? NUM_int_min() && -2147483648
See also
NUM_int_max()
Parameters
n the integer to test.
Returns
lPrime .T. if n is a prime number; .F. if not.
Example
? NUM_IsPrime( 101 ) && .T.
? NUM_IsPrime( 103 ) && .T.
? NUM_GetNextPrime( 103 ) && 107
? NUM_GetNextPrime( 5737 ) && 5741
? NUM_GetPrevPrime( 5741 ) && 5737
? NUM_GetPrevPrime( 7583 ) && 7577
See also
NUM_GetNextPrime() , NUM_GetPrevPrime() .
Syntax
NUM_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\NUM.C-Mon Oct 19 15:55:22 1998" .
Syntax
NUM_long_max() n
Returns
n maximum value of a long.
Example
? NUM_long_max() && 2147483647
See also
NUM_long_min()
Syntax
NUM_long_min() n
Parameters
None.
Returns
n minimum value of a long.
Example
? NUM_long_min() && -2147483648
See also
NUM_int_max()
Parameters
nInteger integer to process.
Returns
szOctal octal representation.
Example
? NUM_octal( 8 ) && "10"
? NUM_octal( 10 ) && "12"
See also
STR_hexa() , STR_htos() , NUM_htoi()
Parameters
szNum the string to transform to a number.
nRadix the radix to take into account. Must be in the range 2 – 36.
Returns
n the resulting integer number.
Example
? NUM_base( 3, 2 ) && "11"
? NUM_base( 10,16 ) && "a"
? NUM_base( 32,16 ) && "20"
? NUM_base( 7, 8 ) && "7"
? NUM_base( 9, 8 ) && "11"
See also
NUM_Base() .
Parameters
None.
Returns
nNum random float number.
Example
? NUM_RandomDouble() && 0,9304951553
See also
NUM_InitRandom() , NUM_RandomInt() .
Parameters
None.
Returns
nInt Random integer.
See also
NUM_InitRandom() , NUM_RandomDouble() .
Remark
The algorithm uses:
With it, it is capable to generate a global ID that is said to be unique in space and unique in time.
Syntax
NUM_UniversalID() szID
Parameters
None.
Returns
szID a globally unique ID that can be used in distributed environments. Very handy for keys that are
generated for primary keys in tables for example. The ID can be up to 66 bytes long.
Parameters
oObject the object to add the property to.
Returns
lSuccess .T. if the property was successfully added; .F. if not.
Example
LOCAL oForm
Syntax
OBJ_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\OBJECTS.C-Mon Oct 19 15:55:22 1998" .
Printer Functions
Functions Synopsis
Obtaining all the available printers can be achieved by following several strategies. One might want to obtain the list of
installed printers from Windows INI files; another one would choose one registry place; a third one would disagree and
propose another registry location; yet exists the EnumPrinters() Win32 API call! .. or simply the APRINTERS()
native VFP function.
The latter has our favor because it is available from Windows NT 3.51 and exists for Win95, Win98 and Windows Me …
and of course, because we totally control its code which makes it very attractive to us!
The latter has our favor because it is available since Windows NT 3.51 and exists for Win95, Win98 and Windows Me.
This API call has been wrapped in FOCUS.FLL through the PRN_EnumPrinters() function. What this function does
is pretty simple: it returns a tokenized string of Printer names with each printer separated with a caret ( ^):
Once the string is obtained, it becomes a matter of parsing it to extract each token that composes it. Such thing is
easy to achieve with FOCUS.FLL thanks to some token functions such as STR_numtok() and STR_ntoken() . What
follows is an example of such an extraction:
LOCAL szPrinters
LOCAL OldSep
LOCAL i
&& Get all the printers that are installed locally on the system
m.szPrinters = PRN_EnumPrinters()
Now that all the installed printers can be listed, either by calling the PRN_EnumPrinters() or the APRINTERS()
function, we would like to be able to determine the properties of a specific printer.
Parameters
nNew new color setting (same values as nColor )
Returns
nColor color setting.
Color 1
Monochrome 2
Parameters
nNew Optional parameter. When passed it updates the internal DeviceCapabilities structure of
FOCUS. Number of copies to position printer driver with.
Returns
nCopies number of copies.
Parameters
None.
Returns
cDevice Device unique string.
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read current printer driver"
ELSE
? "Current printer :" + PRN_device()
ENDIF
Parameters
nFrom starting page number.
Returns
lSuccess .T. if FOCUS was able to access current printer driver and the user did press the OK button;
.F. otherwise.
Parameters
None.
Returns
nVersion Specifies the printer driver version number assigned by the developer.
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read current printer driver"
ELSE
? "Driver v. :" + LTRIM( STR( PRN_driver() ) )
ENDIF
Having both structures constantly updated also has a major advantage : the DEVNAMES structure also retains the
name of the driver associated with the current default printer and the port it is connected to.
The PRN_drv() function queries the driver name from the DEVNAMS structure.
Parameters
None.
Returns
szDriver Printer driver name.
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read current printer driver"
ELSE
? "Current printer driver :" + PRN_drv()
ENDIF
Parameters
nNew Optional parameter. When passed it updates the internal DeviceCapabilities structure of
FOCUS. Same values as nDuplex .
Returns
nDuplex duplex mode.
1 Simplex
2 Horizontal
3 Vertical
Parameters
None.
Returns
szPrinters serialized string of printers or an empty string if an error occurred. The string is a caret ( ^)
separated list.
Example
LOCAL szPrinters
LOCAL OldSep
LOCAL i
&& Get all the printers that are installed locally on the system
m.szPrinters = PRN_EnumPrinters()
Syntax
PRN_extra() nSize
Parameters
None.
Returns
nSize size of the dmDriverData member.
Parameters
None.
Returns
nFlags flags that have been updated.
0x0000001L DM_ORIENTATION
0x0000002L DM_PAPERSIZE
0x0000004L DM_PAPERLENGTH
0x0000008L DM_PAPERWIDTH
0x0000010L DM_SCALE
0x0000100L DM_COPIES
0x0000200L DM_DEFAULTSOURCE
0x0000400L DM_PRINTQUALITY
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read current printer driver"
ELSE
IF ( PRN_fields() = 0 )
? "No field has been updated by the driver"
ENDIF
ENDIF
Parameters
None.
Returns
szPrinterDef name of the default printer, its driver and port.
Example
LOCAL szDefault
m.szDefault = PRN_GetDefaultprinter()
&& When we're done ... let's restore the default printer
PRN_SetdefaultPrinter( m.szDefault )
Parameters
Returns
szDriverSettings tokenized string. The string is prefixed with "WINNT:" if it applies to Windows NT, or
"WIN95:" if it applies to Windows 95, which makes it easy in your own code to distinguish
between these two environments.
Windows NT :
Windows 95 :
Example
LOCAL i,j, OldSep, nTokens, szDrvInfo
APRINTERS( gaPrns )
OldSep = STR_setsep( "," )
CLEAR
IF ( ! SYS_isNT() )
? "Driver's help file: " , STR_ntoken( 6,szDrvInfo )
? "Files the driver depends on : ", STR_ntoken( 7,szDrvInfo )
? "Language monitor : " , STR_ntoken( 8,szDrvInfo )
? "Default data type : " , STR_ntoken( 9,szDrvInfo )
ENDIF
NEXT
STR_setsep( OldSep )
Here is a screen capture of an instance of the ErrorForm class which uses the PRN_GetDrvInfo() to construct a
list of all printers installed on the system :
Parameters
szPrinter printer for which the jobs need to be obtained.
Returns
szJobs a serialized string with each job set as a separate token. All jobs are separated from each other
by a caret (^).
Because this function actually replaces a lot of functions that worked under FoxPro 2.6, and because we didn't want to
duplicate too much information, we will refer to the old routine. For example, PRN_GetPrnData("HP LaserJet
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 441
Printer Functions
5P",12) is actually identical to set the default printer to "HP LaserJet 5P" , and get the PRN_copies() value
(12 is to be used to acquire the number of copies).
Special
Most the printer information is stored in the registry ( HKEY_LOCAL_MACHINE\System\CurrentControlSet\
Control\Print\Printers ). For example, here is a screen capture of the settings pertaining to a "HP LaserJet 5P"
printer installed on our system :
Syntax
PRN_GetPrnData( szPrinter,nInfo ) xValue
Parameters
nInfo information required. This can be one of the values listed in the following table:
FW_PRN_GIVEUSEFULNUM
Token Description
1 dmOrientation
2 dmPaperSize
3 dmPaperLength
4 dmPaperWidth
5 dmScale
6 dmCopies
7 dmDefaultSource
8 dmPrintQuality
9 dmColor
10 dmDuplex
11 dmYResolution
12 dmTTOption
13 dmCollate
FW_PRN_GIVEUSEFULSTR
Token Description
1 dmDeviceName
2 pServerName
3 pPrinterName
4 pShareName
5 pPortName
6 pDriverName
7 pComment
8 pLocation
9 pSepFile
10 pPrintprocessor
11 pDataType
12 pParameters
Returns
xValue value returned by the function according to the type of information that was requested.
FastWrite has created useful VFP classes dedicated to printer settings. Here are two screen captures from VFP
programs that use these classes to gain total control over printer settings :
When clicking the Settings command button, the following form is displayed :
Syntax
PRN_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\PRN.C-Mon Oct 19 15:55:22 1998" .
Having both structures constantly updated also has a major advantage : the DEVNAMES structure also retains the
name of the driver associated with the current default printer and the port it is connected to.
Syntax
PRN_name() szDevice
Parameters
None.
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read current printer driver"
ELSE
? "Current printer :" + PRN_name()
ENDIF
Parameters
nNew Optional parameter. When passed it updates the internal DeviceCapabilities structure of
FOCUS. 1 for Portrait mode, 2 for Landscape.
Returns
nOrientation 1 for Portrait mode, 2 for Landscape.
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read the current printer driver"
ELSE
? "Paper orientation : " + IIF( PRN_orient() == 1, ;
"Portrait" , ;
"Landscape" )
ENDIF
Syntax
PRN_paperL() nSize
Parameters
None.
Returns
nSize Paper length.
Returns
nSize Paper size
Syntax
PRN_paperW() nSize
Returns
nSize Paper width.
Comment
When calling PRN_capa() two different structures are updated : a DEVMODE and a DEVNAMES structure. The
dmDeviceName of the DEVMODE structure retains the same value as the Device member of the DEVNAMES structure.
PRN_device() queries the information which is stored in the DEVMODE structure whereas the PRN_name() function
queries the same information in the DEVNAMES structure.
Having both structures constantly updated also has a major advantage : the DEVNAMES structure also retains the
name of the driver associated with the current default printer and the port it is connected to.
The PRN_port() function queries the port the printer is connected to.
Syntax
PRN_port() szPort
Parameters
None.
Returns
szPort Printer port.
Parameters
None.
Returns
nQuality Default bin. There are four predefined device-independent values which are :
High resolution -4
Medium resolution -3
Low resolution -2
Draft mode -1
If a positive value is given, it specifies the number of dots per inch (dpi) and is therefore
device-dependent.
Parameters
None.
Returns
nResolution y-resolution in dots per inch. If the printer initializes this member, the PRN_qualit() function
specifies the x-resolution in dots per inch.
Parameters
None.
Returns
nFactor factor by which the printed output is to be scaled.
Parameters
szPrinterDef name of the printer to set, its driver and port.
Returns
lSuccess .T. if the printer has been successfully set; .F. if not. What the function does is very
straightforward: it simply writes the new default printer to the WIN.INI file via the
nReturn = WriteProfileString( "WINDOWS","device",_parc(1) ) call. On NT
systems this is mapped to the registry. Then we make sure that the WIN.INI file is flushed
(something that many programmers forget, but you shouldn't lose from sight that the WIN.INI
file is kept in memory whenever Windows can. In other terms, all running applications can still
think that some entries are different from what is actually written in the file). Then we issue a
warning to all running applications informing them that the WIN.INI file has changed. On a
Windows 98 system, here's the line in my [Windows] section:
[windows]
NullPort=None
SkipMouseRedetect=0
device=HP LaserJet 5P,HPPCL5MS,\\Pegasus\hp5p
C Code
FOCUSFNC FW_PRN_SetDefaultPrinter( XBASE_PARAMETERS )
/*--------------------------------------------------*/
{
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 451
Printer Functions
int nReturn;
_initparc(1);
// Write the printer name, the driver name, and the port to WIN.INI
nReturn = WriteProfileString( "WINDOWS","device",_parc(1) );
Example
LOCAL szDefault
m.szDefault = PRN_GetDefaultprinter()
&& When we're done ... let's restore the default printer
PRN_SetdefaultPrinter( m.szDefault )
Parameters
nInfo information that will be updated. This can be one of the values listed in the following table:
FW_PRN_DMPAPERLENGTH 9 For printer devices only, overrides the length of the paper
specified by the dmPaperSize member, either for custom
paper sizes or for devices such as dot-matrix printers that
can print on a page of arbitrary length. These values, along
with all other values in this structure that specify a physical
length, are in tenths of a millimeter.
FW_PRN_DMPAPERWIDTH 10 For printer devices only, overrides the width of the paper
specified by the dmPaperSize member.
FW_PRN_DMSCALE 11 Specifies the factor by which the printed output is to be
scaled. The apparent page size is scaled from the physical
page size by a factor of dmScale/100. For example, a
letter-sized page with a dmScale value of 50 would contain
as much data as a page of 17- by 22-inches because the
output text and graphics would be half their original height
and width.
FW_PRN_DMCOPIES 12 Selects the number of copies printed if the device supports
multiple-page copies.
FW_PRN_DMDEFAULTSOURCE 13 Specifies the paper source. To retrieve a list of the available
paper sources for a printer, use the DeviceCapabilities()
function with the DC_BINS flag.
This member can be one of the following values, or it can be
a device-specific value greater than or equal to one of the
following values:
Tray Value Tray Value
First 1 Auto 7
Only one 1 Cassette 14
Upper 1 Envelope 5
Lower 2 Envelope 6
manual
Middle 3 First 1
Manual 4 Large capacity 11
Envelope 5 Large format 10
Envelope 6 Last 14
manual
Auto 7 Lower 2
Tractor 8 Manual 4
Small format 9 Middle 3
Large format 10 Only one 1
Large capacity 11 Small format 9
Cassette 14 Tractor 8
Last 14 Upper 1
FW_PRN_DMPRINTQUALITY 14 Specifies the printer resolution. There are four predefined
device-independent values:
DMRES_HIGH
DMRES_MEDIUM
DMRES_LOW
DMRES_DRAFT
If a positive value is specified, it specifies the number of
dots per inch (DPI) and is therefore device dependent.
FW_PRN_DMCOLOR 15 Switches between color and monochrome on color printers.
Following are the possible values:
DMCOLOR_COLOR
nValue|szValue If nInfo is equal to FW_PRN_PCOMMENT, then the parameter that must be passed in a character
string (szValue). In all other cases, the parameter is an integer (nValue).
Returns
lSuccess .T. if the function is successful; .F. if not.
&& In general, most printers are set by default with 1 copy, and portrait mode
? "Before any change ...","Copies",nCopies,"Orientation",nOrientation
Syntax
PRN_size() nSize
Parameters
None.
Returns
nSize Size of the DEVMODE structure.
Syntax
PRN_source( [nNew] ) nBin
Parameters
nNew Optional parameter. When passed it updates the internal DeviceCapabilities structure of
FOCUS. Same values as nBin .
Returns
nBin Default bin.
Parameters
None.
Returns
nVersion version number of the DEVMODE structure. For Windows 3.1 it should be 0x30A (778)
Example
IF ( ! PRN_capa() )
? "FOCUS was unable to read current printer driver"
ELSE
? "Windows v. :" + LTRIM( STR( PRN_spec() ) )
ENDIF
Parameters
None.
Returns
nResolution y-resolution in dots per inch. If the printer initializes this member, the PRN_qualit() function
specifies the x-resolution in dots per inch.
Registry Functions
Parameters
szRoot root key.
Returns
nSuccess 0 in case of success.
Example
IF ( REG_CreateKey( "HKEY_LOCAL_MACHINE","Software\AAA" ) )
? "The key was successfully created"
ENDIF
Parameters
szRoot root key.
szData|nData data to write for szValue . This can be only strings or integers.
Example
? REG_CreateValue( "HKEY_LOCAL_MACHINE" , ;
"SOFTWARE\FastWrite\Trees\1.0", ;
"Test" , ;
"Hello World" , ;
)
? REG_CreateValue( "HKEY_LOCAL_MACHINE" , ;
"SOFTWARE\FastWrite\Trees\1.0", ;
"Test2" , ;
43 , ;
)
Parameters
szRoot root key.
Returns
szString character string. So far, only character strings can be returned by the REG_QueryValue()
function.
Example
????????????
Parameters
szRoot root key.
Returns
szString character string. So far, only character strings can be returned by the REG_QueryValue()
function.
Example
????????????
Parameters
szRoot root key.
Returns
szKeys character string that represents all the subkeys of a given key ( szPath ). All keys are separated
from each other by a caret (^).
Example
LOCAL nPrograms
LOCAL szPrograms
LOCAL szThisProgram
LOCAL OldSep
LOCAL i
Syntax
REG_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\REG.C-Mon Oct 19 15:55:22 1998" .
Parameters
szRoot root key.
Returns
szString character string. So far, only character strings can be returned by the REG_QueryValue()
function.
Example
? REG_QueryValue( "HKEY_LOCAL_MACHINE" , ;
"SOFTWARE\Microsoft\Windows\CurrentVersion", ;
"ProductId" ) && 31895-OEM-0006663-59319
Function Synopsis
The implementation of Regular Expressions in the framework of FOCUS.FLL is based on code that was first created by
the University of California.
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
3. All advertising materials mentioning features or use of this software must display the
following acknowledgement: "This product includes software developed by the
University of California, Berkeley and its contributors."
4. Neither the name of the University nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written
permission.
The RG_Compile() function compiles a regular expression into a structure of type regexp (internal to FOCUS.FLL ),
and returns a pointer to it (kept internally). In final, the result of the function is either a logical true ( .T.) or a logical
false (.F. ) to indicate success or failure.
If the return value of RG_Compile() was .T. , then a subsequent call to RG_Execute() can be carried out.
The RG_Execute() function determines if a match can be found in the string that was passed to it. The function uses
the internal structure that was filled thanks to the previous call to RG_Compile() .
For example, here's how you would determine that "World" is found in "Hello World" :
IF ( RG_Compile( "World" )
IF( RG_Execute( "Hello World" ) )
? "We found it"
ELSE
? "We dind't find it"
ENDIF
ENDIF
An atom is a regular expression in parentheses (matching a match for the regular expression), a range (see below),
'.' (matching any single character), '^' (matching the null string at the beginning of the input string), '$'
(matching the null string at the end of the input string), a '\' followed by a single character (matching that
character), or a single character with no other significance (matching that character).
A range is a sequence of characters enclosed in '[]' . It normally matches any single character from the sequence. If
the sequence begins with '^', it matches any single character not from the rest of the sequence. If two characters in
the sequence are separated by '-', this is shorthand for the full list of ASCII characters between them (e.g. '[0-9]'
matches any decimal digit). To include a literal ']' in the sequence, make it the first character (following a possible
'^' ). To include a literal '-', make it the first or last character.
char *startp[10];
char *endp[10];
Once a successful RG_Execute() has been done, each startp-endp pair describes one substring within the string ,
with the startp pointing to the first character of the substring and the endp pointing to the first character following
the substring. The 0th substring is the substring of string that matched the whole regular expression. The others are
those substrings that matched parenthesized expressions within the regular expression, with parenthesized
expressions numbered in left-to-right order of their opening parentheses.
The RG_sub() function copies source to destination, making substitutions according to the most recent
RG_Execute() performed. Each instance of '&' in source is replaced by the substring indicated by startp and
endp . Each instance of '\n' , where n is a digit, is replaced by the substring indicated by startp n and endp n . To
get a literal '&' or '\n' into destination , prefix it with '\'; to get a literal '\' preceding '&' or '\n' , prefix it
with another '\' .
Useful Examples
Example #1: We look for a pattern that is composed of two parts: part #1 can either be "Hello" or "Good
morning" ; part #2 must be "World" . Here's how we build the pattern, and the result of few tests:
Example #3: We want to match a string that contains a pattern formed of 2 parts: part #1 must contain a number
made of at least two digits; part #2 must contain the word "dog" :
Example #4: Same example as above, but this time, we also want to match if we have no dog at all:
The following code does exactly the same thing, but the pattern was constructed differently:
Examine the last line: a match was found for "00". Now, what can be done if we don't want the first
letter to be a 0? We can simply change the range of the first digit:
Example #4: Same example as above, but this time, we want to match only if we have between 10 and 29 dogs:
Parameters
szPattern the pattern to compile.
Returns
lSuccess .T. if szPattern could be compiled successfully; .F. otherwise.
Example
? RG_Compile( "(no|[1,2][0-9]) dog" ) && .T.
? RG_Execute( "We have 9 dogs" ) && .F.
? RG_Execute( "We have 10 dogs" ) && .T.
? RG_Execute( "We have 13 dogs" ) && .T.
? RG_Execute( "We have 20 dogs" ) && .T.
? RG_Execute( "We have 29 dogs" ) && .T.
? RG_Execute( "We have 30 dogs" ) && .F.
? RG_Execute( "We have no dog" ) && .T.
Syntax
RG_Execute( szString ) lSuccess
Parameters
szString the string to search.
Returns
lSuccess .T. if szString contains the pattern that was compiled previously by RG_Compile() . .F.
otherwise.
Example
? RG_Compile( "(no|[1,2][0-9]) dog" ) && .T.
? RG_Execute( "We have 9 dogs" ) && .F.
? RG_Execute( "We have 10 dogs" ) && .T.
? RG_Execute( "We have 13 dogs" ) && .T.
? RG_Execute( "We have 20 dogs" ) && .T.
? RG_Execute( "We have 29 dogs" ) && .T.
? RG_Execute( "We have 30 dogs" ) && .F.
? RG_Execute( "We have no dog" ) && .T.
Returns
szMatch the match of the whole regular expression or an empty string ("") in case of failure.
Example
? RG_Compile( "(no|a lot of) dog" ) && .T.
? RG_Execute( "I have no dog" ) && .T.
? RG_Match() && "no dog"
? RG_Execute( "I have a lot of dogs" ) && .T.
? RG_Match() && "a lot of dogs"
Screen Functions
Syntax
SCR_BitmapHeight() nPixels
Parameters
None.
Returns
nPixels number of Y pixels.
Syntax
SCR_BitmapWidth() nPixels
Parameters
None.
Returns
nPixels number of X pixels.
Parameters
None.
Returns
nColors number of colors in the current screen resolution.
Example
IF ( SCR_ColorDepth() < 32768 )
? "Warning : This application uses highcolor bitmaps"
ENDIF
Parameters
None.
Returns
nColumns number of X pixels.
Example
? "Display resolution", ;
SCR_rows(), ;
SCR_col()
Parameters
i Graphics mode. Graphics mode indexes start at zero. To obtain information for all of a display
device's graphics modes, make a series of calls to SCR_EnumDisplaySettings(), as follows: Set
i to zero for the first call, and increment i by one for each subsequent call. Continue calling the
function until the return value is .F..
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL I
LOCAL x
LOCAL nFreq
ENDDO
Parameters
i Member to query information about.
Returns
xRetVal Value of the member that must be queried. The return type depends on the member to query.
For example, if i is equal to 1, a character string is returned. If i is equal to 26, a numeric
value is returned.
FW_PRN_DMDEVICENAME 1
FW_PRN_DMSPECVERSION 2
FW_PRN_DMDRIVERVERSION 3
FW_PRN_DMSIZE 4
FW_PRN_DMDRIVEREXTRA 5
FW_PRN_DMFIELDS 6
FW_PRN_DMORIENTATION 7
FW_PRN_DMPAPERSIZE 8
FW_PRN_DMPAPERLENGTH 9
FW_PRN_DMPAPERWIDTH 10
FW_PRN_DMSCALE 11
FW_PRN_DMCOPIES 12
FW_PRN_DMDEFAULTSOURCE 13
FW_PRN_DMPRINTQUALITY 14
FW_PRN_DMCOLOR 15
FW_PRN_DMDUPLEX 16
FW_PRN_DMYRESOLUTION 17
FW_PRN_DMTTOPTION 18
FW_PRN_DMCOLLATE 19
FW_PRN_DMFORMNAME 20
FW_PRN_DMLOGPIXELS 21
FW_PRN_DMBITSPERPEL 22
FW_PRN_DMPELSWIDTH 23
FW_PRN_DMPELSHEIGHT 24
FW_PRN_DMDISPLAYFLAGS 25
FW_PRN_DMDISPLAYFREQUENC 26
Y
FW_PRN_DMICMMETHOD 27
FW_PRN_DMICMINTENT 28
FW_PRN_DMMEDIATYPE 29
FW_PRN_DMDITHERTYPE 30
FW_PRN_DMICCMANUFACTURER 31
FW_PRN_DMICCMODEL 32
Example
LOCAL I
LOCAL x
LOCAL nFreq
ENDDO
Syntax
SCR_GetFullScreenDimensions( @iRows,@iCols ) lSuccess
Parameters
iRows number of Y pixels. MUST BE PASSED BY REFERENCE.
Returns
lSuccess .T. if the function is successful; .F. if not.
Syntax
SCR_GetScreenDimensions( @iRows,@iCols ) lSuccess
Parameters
iRows number of Y pixels. MUST BE PASSED BY REFERENCE.
Returns
lSuccess .T. if the function is successful; .F. if not.
Syntax
SCR_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\SCR.C-Mon Oct 19 15:55:22 1998" .
Comment
The user cannot drag the window's frame to a size smaller than this dimension.
Syntax
SCR_MinimumDragHeight() nPixels
Parameters
None.
Returns
nPixels number of pixels.
Comment
The user cannot drag the window’s frame to a size smaller than this dimension. A form cannot be resized to a smaller
dimension than the return value of this function. However, the SCR_MinimumDragWidth() takes the width of the
Syntax
SCR_MinimumDragWidth() nPixels
Parameters
None.
Returns
nPixels number of pixels.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
iRetVal The function returns one of the following values:
DISP_CHANGE_SUCCESSFUL 0
DISP_CHANGE_RESTART 1
DISP_CHANGE_FAILED -1
DISP_CHANGE_BADMODE -2
DISP_CHANGE_NOTUPDATED -3
DISP_CHANGE_BADFLAGS -4
DISP_CHANGE_BADPARAM -5
Example
SCR_ResetDisplaySettings()
? SCR_LastError()
Syntax
SCR_roloc( nColor ) nRevert
Parameters
nColor color attribute (see appendix A).
Returns
nRevert reverted color.
Example
* This example turns the color 135 (W/N*) into 120 (N+/W)
? SCR_roloc( 135 ) && 120
Shell Functions
Functions Synopsis
Shell functions were first introduced in FOCUS.FLL 7.84. They requires some important update of the SHELL32.DLL
file. To get the most recent version of the Shell and Common Controls DLLs, download and install Internet Explorer
(http://www.microsoft.com/windows/IE).
FOCUS.FLL can handle up to 15 different icons. Here's the quick path to Tray Icons:
1) Use the SHE_AddIcon() function with 2 parameters: the icon filename and the Tooltip text
2) SHE_AddIcon() will return an icon number (starting from 0 to 14). Up to 15 icons can be placed in the tray
3) When you want to remove the icon, please use its number (returned by SHE_AddIcon() ) with the
SHE_DeleteIcon() function
4) Notifications of mouse events are sent to a customizable function. The function can be set using the
SHE_SetTrayIconProc() function. ALL icons trigger the same notification function. The function receives
two parameters: the icon number that fired the event and the event ID (to check to distinguish between mouse
moves, clicks, right-clicks).
5) Notifications will start being fired as soon as the SYS_HookWindowProc() is called.
Syntax
SHE_AddIcon( szIcon,szTooltip ) nIconID
Parameters
szIcon icon filename.
szTooltip tooltip to assign to the icon.
Returns
nCountID icon identification number (from 0 to 14). –1 if the icon hasn't been added.
Example
&& EXAMPLE #1
LOCAL szIcon
LOCAL nIcon
IF ( SHE_IconsFree() > 0 )
m.szIcon = "D:\Microsoft Visual Studio\Common\Graphics\icons\computer\w95mbx02.ico"
m.nIcon = SHE_AddIcon( m.szIcon,"Hello from FastWrite" )
IF ( m.nIcon != -1 )
? "Icon successfully added to the Tray Notification Area"
ENDIF
ENDIF
&& EXAMPLE #2
&& Here's a full example in pure interactive mode:
&& It adds 6 times the same icon to the System Tray
? SHE_SetTrayIconProc( "HereWeGo" )
? SYS_HookWindowProc()
*********************************
* Put this function in MYPROC.PRG
*********************************
FUNCTION HereWeGo( n,x )
WAIT WINDOW "Icon #" + ALLTRIM(STR(n)) NOWAIT
RETURN ( .NULL. )
Unlike many functions of the Windows API, the SHFileOperation() does not perform a given operation on files
whose names have been passed as parameters to the function. Instead, the action to perform is a parameter in itself
which gives the Visual FoxPro developer with somewhat troubles. The SH_CopyFile() function solves this difficulty
by automatically preparing the parameters you need.
The SHFileOperation() function can perform many tasks such as copying files, deleting files, moving and
renaming files. Of course, here we're concentrated on the copy operation.
a string containing the source file names. This can be a sequence of files, a single name, wildcards, or even a
sequence of wildcards.
a string containing a directory name. If we're moving or copying a well-defined list of files, then this string needs
to be a list of names, taking care to preserve a 1:1 correspondence with the source names which basically means
that each source file name should be matched by a target file name.
Each file name must be separated by the next one with a NULL ( CHR(0) ). The function expects a double
NULL (CHR(0) + CHR(0) ) at the end of the string passed (this is true even if you pass a single file name or
a single wildcard). If you do not include a double NULL at the end of the string, then the function might
work or not. This is applicable for the szSource parameter of SHE_CopyFile() and for szTarget if this
one contains more than one file name.
Because FOCUS.FLL greatly simplifies the interface of the Shell API it uses a set of default behaviors that are
otherwise all triggered via parameters:
1. No error message will be displayed because all dialog have been suppressed; instead, the function will return
.T. or .F. ,
3. In case of name collisions, the files are duplicated by assigning them new names (THEY ARE NOT
OVERWRITTEN!)
Even though supported, at this time we cannot fully assure you that copying entire directories will work
smoothly and seamlessly. This function needs more testing cycles even if we have made every effort to
ensure its accuracy.
Alias
SHE_CopyFiles(), SHCopyFiles()
Syntax
SHE_CopyFiles( szSource,szTarget ) lSuccess
Parameters
szSource source files such as "D:\INVOICES\*.*". Don't forget to use double NULL to terminate the
string.
szTarget target files or simply a directory under which files should be recopied (please notice that the
target directory MUST exist prior to calling the SHE_CopyFile() function).
Returns
lSuccess .T. if the function was successful; .F. if not.
Example
&& "O:\MYCOPY" MUST exist for the function to be successful!
? SHE_CopyFile( "D:\INVOICES\*.*" + CHR(0) + CHR(0),"O:\MYCOPY" )
... will produce the following dialog to be displayed. Please notice that all sub-directories will be automatically created!
Syntax
SHE_DeleteAllTrayIcons() .T.
Parameters
None.
Returns
.T. Always.
FOCUS.FLL can handle up to 15 different icons. Please notice that FOCUS.FLL cannot remove icons placed by
other processes.
Syntax
SHE_DeleteIcon( nIcon ) lSuccess
Parameters
nIcon icon identification number.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL szIcon
LOCAL nIcon
IF ( SHE_IconsFree() > 0 )
m.szIcon = "D:\Microsoft Visual Studio\Common\Graphics\icons\computer\w95mbx02.ico"
m.nIcon = SHE_AddIcon( m.szIcon,"Hello from FastWrite" )
IF ( m.nIcon != -1 )
? "Icon successfully added to the Tray Notification Area. Let's remove it now"
WAIT WINDOW "Press ENTER"
IF ( SHE_DeleteIcon( m.nIcon ) )
? "The icon is removed now!"
ELSE
? "The icon hasn't been removed",SHE_LastError()
ENDIF
ENDIF
ENDIF
Syntax
SHE_GetDllVersion( nInfo ) nVersionInfo
Parameters
nInfo the member to obtain information for:
Value Description
1 Major number
2 Minor number
3 Build number
4 Platform ID
#define DLLVER_PLATFORM_WINDOWS 0x00000001 // Windows 95/98
#define DLLVER_PLATFORM_NT 0x00000002 // Windows NT
Any other Major number
numeric
value
Returns
nVersionInfo the version info that was queried. -1 if the DLL couldn't be opened. -2 if the version info
couldn't be obtained.
Example
? SHE_GetDllversion( 1 ) // 4
? SHE_GetDllversion( 2 ) // 72
? SHE_GetDllversion( 3 ) // 3110
? SHE_GetDllversion( 4 ) // 1
See also
SYS_GetDllVersion()
Parameters
szFile file from which the number of icons must be returned.
Returns
n icon count or –1 in case of error.
Example
szFile = " FOCUS.FLL"
? SHE_GetIconCount( szFile ) && Should display 2
Syntax
SHE_IconsFree() nCount
Parameters
None
Returns
nCount number of icons free (from 0 to 15).
Example
LOCAL szIcon
LOCAL nIcon
IF ( SHE_IconsFree() > 0 )
m.szIcon = "D:\Microsoft Visual Studio\Common\Graphics\icons\computer\w95mbx02.ico"
m.nIcon = SHE_AddIcon( m.szIcon,"Hello from FastWrite" )
IF ( m.nIcon != -1 )
? "Icon successfully added to the Tray Notification Area"
ENDIF
ENDIF
Syntax
SHE_IsActiveDesktopInstalled() lInstalled
Parameters
None
Returns
lInstalled .T. if Active Desktop is installed; .F. otherwise.
Example
IF ( SHE_IsActiveDesktopInstalled() )
? "Active Desktop is installed"
ENDIF
Parameters
None.
Returns
szLastError last error
Syntax
SHE_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"D:\Focus\6.0\Shell.c-Thu Jul 20 21:42:48 2000".
Parameters
szDrive drive string such as "D:\".
Returns
nItems number of items in given recycle bin. 0 indicates that there is no deleted item available in the
recycle bin; -1 indicates that there was an error trying to access the specific recycle bin; -2
indicates that shell32.dll does not support the requested feature.
Example
LOCAL nItems
Parameters
szDir path to which to add the backslash.
Returns
szNewDir path with added backslash.
Example
? SHE_PathAddBackslash( "D:\MYDIR\MYOTHERDIR" ) && "D:\MYDIR\MYOTHERDIR\"
See also
SYS_PathRemoveBackslash()
Parameters
szDir path to alter.
nChars maximum number of characters to be contained in the new path.
Returns
szDirEllipses the altered path.
Example
? SHE_PathCompact( "c:\mydir\theOtherDir\myfile.txt",25 ) && "c:\mydir\th...\myfile.txt"
Returns
lIsRelative .T. if szDir is a relative resource; .F. if not.
Example
? SHE_PathIsRelative( "D:\MYDIR\MYOTHERDIR" ) && .F.
? SHE_PathIsRelative( "C:\" ) && .F.
? SHE_PathIsRelative( "D:\" ) && .F.
? SHE_PathIsRelative( "\\orion\d" ) && .F.
? SHE_PathIsRelative( "..\test" ) && .T.
? SHE_PathIsRelative( "test.exe" ) && .T.
? SHE_PathIsRelative( ".\test.exe" ) && .T.
? SHE_PathIsRelative( ".\" ) && .T.
See also
SYS_PathIsRoot()
Parameters
szDir path to be validated.
Returns
lIsRoot .T. if szDir is a root directory; .F. if not.
Example
? SHE_PathIsRoot( "D:\MYDIR\MYOTHERDIR" ) && .F.
? SHE_PathIsRoot( "C:\" ) && .T.
? SHE_PathIsRoot( "D:\" ) && .T.
? SHE_PathIsRoot( "\\orion\d" ) && .T.
See also
SYS_PathIsRelative()
Syntax
SHE_PathIsUNC( szPath ) lIsUNC
Parameters
szPath path to consider.
Example
? SHE_PathIsUNC( "\\orion" ) && .T.
? SHE_PathIsUNC( "\\orion\" ) && .T.
? SHE_PathIsUNC( "\\orion\d" ) && .T.
? SHE_PathIsUNC( "\\orion\d\mydir" ) && .T.
? SHE_PathIsUNC( "y:\mydir" ) && .F.
Parameters
szPath path to consider.
Returns
lIsUNCServer .T. if szPath is a valid UNC server path; .F. otherwise.
Example
? SHE_PathIsUNCServer( "\\orion" ) && .T.
? SHE_PathIsUNCServer( "\\orion\d" ) && .F.
Parameters
szPath path to consider.
Returns
lIsUNCServerShare .T. if szPath is a valid UNC server share path; .F. otherwise.
Example
? SHE_PathIsUNCServerShare( "\\orion" ) && .F.
? SHE_PathIsUNCServerShare( "\\orion\d" ) && .T.
Returns
lIsURL .T. if szDir is a URL path; .F. if not.
Example
? SHE_PathIsURL( "http://www.fastwrite.com/products/" ) && .T.
? SHE_PathIsURL( "://www.fastwrite.com/products/" ) && .F.
? SHE_PathIsURL( "www.fastwrite.com" ) && .F.
? SHE_PathIsURL( " fastwrite.com" ) && .F.
? SHE_PathIsURL( "htt://www.fastwrite.com/products/" ) && .T.
? SHE_PathIsURL( "ht://www.fastwrite.com/products/" ) && .T.
? SHE_PathIsURL( "h://www.fastwrite.com/products/" ) && .F.
? SHE_PathIsURL( "ftp://www.fastwrite.com/products/" ) && .T.
Parameters
szDir path from which to remove the backslash.
Returns
szNewDir path with removed backslash.
Example
? SHE_PathRemoveBackslash( "D:\MYDIR\MYOTHERDIR\" ) && "D:\MYDIR\MYOTHERDIR"
See also
SYS_PathAddBackslash()
Sizeof Functions
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type. Obviously, this function should return 1.
Parameters
None.
Returns
nSize size of the corresponding data type. Obviously, this function should return 2.
Parameters
None.
Returns
nSize size of the corresponding data type. Obviously, this function should return 4.
Parameters
None.
Returns
nSize size of the corresponding data type. Currency data type in Visual FoxPro corresponds to a large
integer (int64). Obviously, this function should return 8.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Syntax
SIZ_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\SIZEOF.C-Mon Oct 19 15:55:22 1999" .
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 494
Sizeof Functions
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Returns
nSize size of the corresponding data type.
Parameters
None.
Parameters
None.
Returns
nSize size of the corresponding data type.
Sound Functions
Parameters
szApplication the application name as stored in the Windows registry.
As the above screen capture suggests, the Application Name must appear under the following
key : HKEY_CURRENT_USER\AppEvents\Schemes\Apps .
Returns
lSuccess .T.. if the sound was found and successfully played; .F. otherwise.
Example
SND_AppEvent( "FOCUS","FOCUSLoading" )
Parameters
None.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Syntax
SND_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\SOUND.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
.T. the function always returns .T..
Syntax
SND_play( szFile[,nType] ) lSuccess
Parameters
szFile the name of the sound to play. The function searches the name section of WIN.INI for an
entry with this name and plays the associated waveform file. If no entry by this name exists,
then it assumes the name is the name of a waveform file. If this parameter is NULL( ""), any
currently playing sound is stopped.
nType options for playing the sound using one or more of the following flags. Optional: 0 by default:
Value Description
0 plays the sound file synchronously. The function does not return until the sound
ends.
1 plays the sound file asynchronously. The function returns immediately after
beginning the sound. To terminate an asynchronously-played sound, call
sndPlaySound() with szFile set to NULL.
Returns
lSuccess .T. if sound played; .F. if not.
Example
SND_play( "Banner",1 ) && Plays musical theme
Parameters
None.
Example
SND_play( "Banner" ) && Plays musical theme
SND_repeat() && Replay
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
szVers version of SOUND module of FOCUS.
Functions Synopsis
SPI_*() functions are all based on SystemParametersInfo() function of the Windows SDK. Given the fact that
this function uses data types that do not exist in Visual FoxPro, we found it useful to provide these services to you.
The SystemParametersInfo() function queries or sets system-wide parameters. This function can also update the
user profile while setting a parameter.
One of my favorites is the ability to setup the Windows Wallpaper easily. You’ll also notice that it is possible to change
keyboard delay and keyboard speed.
Following is a table of all SystemParametersInfo() values you can query or set. In order to have the most
accurate information we could provide, we slightly adapted the Microsoft Visual C++ help.
VALUE Meaning
SPI_GETACCESSTIMEOUT Retrieves information about the time-out period associated with the
accessibility features. The wParam parameter specifies the size of an
ACCESSTIMEOUT structure, and pvParam is the address of the
ACCESSTIMEOUT structure that receives the information.
SPI_GETBEEP Determines whether the warning beeper is on ( TRUE ) or off (FALSE ). The
pvParam parameter points to a BOOL variable.
SPI_GETBORDER Retrieves the border multiplier factor that determines the width of a
window's sizing border. The pvParam parameter points to an integer
variable.
SPI_GETFASTTASKSWITCH Determines whether fast task switching is enabled. The pvParam parameter
points to a BOOL variable that receives TRUE if enabled, or FALSE
otherwise.
SPI_GETFILTERKEYS Retrieves information about the FilterKeys accessibility feature. The wParam
parameter specifies the size of the FILTERKEYS structure, and pvParam is
the address of the FILTERKEYS structure that receives the information.
SPI_GETGRIDGRANULARITY Retrieves the current granularity value of the desktop sizing grid. The
pvParam parameter points to an integer variable that receives the
granularity.
SPI_GETICONTITLELOGFONT Retrieves the logical font information for the current icon-title font. The
wParam parameter specifies the size of a LOGFONT structure, and the
pvParam parameter points to the LOGFONT structure to fill in.
SPI_GETICONTITLEWRAP Determines whether icon-title wrapping is enabled. The pvParam parameter
points to a BOOL variable that receives TRUE if enabled, or FALSE
otherwise.
SPI_GETKEYBOARDDELAY Retrieves the keyboard repeat-delay setting. The pvParam parameter
points to an integer variable that receives the setting.
SPI_GETKEYBOARDSPEED Retrieves the keyboard repeat-speed setting. The pvParam parameter
points to a DWORD variable that receives the setting.
SPI_GETMENUDROPALIGNMENT Determines whether pop-up menus are left aligned or right aligned, relative
to the corresponding menu-bar item. The pvParam parameter points to a
BOOL variable that receives TRUE if left-aligned, or FALSE otherwise.
SPI_GETMOUSE Retrieves the mouse thresholds and speed. The pvParam parameter points
to an array of three integers that receive the x-threshold, the y-threshold,
and the speed.
SPI_GETMOUSEKEYS Retrieves information about the MouseKeys accessibility feature. The
wParam parameter specifies the size of a MOUSEKEYS structure, and
pvParam is the address of the MOUSEKEYS structure that receives the
information.
SPI_GETSCREENSAVEACTIVE Determines whether screen saving is enabled. The pvParam parameter
points to a BOOL variable that receives TRUE if enabled, or FALSE
otherwise.
SPI_GETSCREENSAVETIMEOUT Retrieves the screen saver time-out value, in milliseconds. The pvParam
parameter points to an integer variable that receives the value.
SPI_GETSHOWSOUNDS Determines whether the user requires an application to present information
[windows]
load=C:\WINDOWS\POINTER.EXE C:\MOUSE\POINTER.EXE
run=C:\WINDOWS\WSIZER.EXE
Beep=yes
NullPort=None
BorderWidth=3
CursorBlinkRate=530
DoubleClickSpeed=452
Programs=com exe bat pif
Documents=
KeyboardDelay=0
KeyboardSpeed=31
ScreenSaveActive=0
ScreenSaveTimeOut=120
MouseThreshold1=0
MouseThreshold2=0
MouseSpeed=0
device=Epson EPL-5600,HPPCL5MS,LPT1:
[Desktop]
Pattern=(aucun)
TileWallPaper=1
GridGranularity=5
Wallpaper=D:\CSERVE\DOWNLOAD\WIN95.BMP
WallpaperStyle=0
Parameters
None.
Returns
lIsBeepOn .T. when warning beep on; .F. otherwise.
Parameters
None.
Returns
nBorder border multiplier factor.
Alias
GetDoubleClickHeight(), SYS_GetDoubleClickHeight()
Syntax
SPI_GetDoubleClickHeight() nHeight
Parameters
None.
Returns
nHeight current height in pixels of the rectangle in which the double click should occur.
Alias
GetDoubleClickTime(), SYS_GetDoubleClickTime()
Syntax
SPI_GetDoubleClickTime() nMilliSeconds
Parameters
None.
Returns
nMilliSeconds current double-click time, in milliseconds.
Alias
GetDoubleClickHeight(), SYS_GetDoubleClickHeight()
Syntax
SPI_GetDoubleClickHeight() nHeight
Parameters
None.
Returns
nHeight current width in pixels of the rectangle in which the double click should occur.
Syntax
SPI_GetFastTaskSwitch() lAltTab
Returns
lAltTab Alt-Tab fast task switching allowed (.T. ) or not (.F. ).
Parameters
None.
Returns
nGranularity current granularity value.
Parameters
None.
Returns
lIconWrapping .T. if icon-title wrapping is ON; .F. otherwise.
Parameters
None.
Returns
nDelay keyboard repeat-delay.
Parameters
None.
Returns
nSpeed keyboard repeat-speed.
Syntax
SPI_GetLastError() szError
Parameters
None.
Returns
szError Last SPI error description.
Parameters
None.
Returns
lLeftAligned .T. if left-aligned; .F. otherwise.
Syntax
SPI_GetScreenReader() lScreenReader
Parameters
None.
Returns
lScreenReader Determines whether a screen reviewer utility is running (.T. ) or not (.F. ).
Parameters
None.
Returns
lScreenSaveActive .T. if screen save active; .F. otherwise.
Parameters
None.
Returns
nValue screen saver time-out value.
Returns
lShowSounds .T. if the user requires an application to present information visually in situations where it
would otherwise present the information only in audible form; .F. otherwise.
Syntax
SPI_GetWorkArea( [@nTop,@nLeft,@nBottom,@nRight] ) szArea
Parameters
nTop top of rectangle. If passed, it must be passed by reference.
Returns
szArea gets the size of the working area. The working area is the portion of the screen not obscured by
the tray (taskbar). The coordinates of the working area rectangle are formatted according to the
following pattern : "t,l,b,r" (top, left, bottom, right). If the function wasn't successful, then
szArea is empty.
if nTop ,nLeft ,nBottom and nRight were passed, these values will be updated and the result
of SPI_GetWorkArea() can simply be ignored.
Example
&& This code can be invoked after the user has moved the window on the screen
&& What is here, is a check to avoid having windows that are outside the limits
&& of the desktop
LOCAL nTop
LOCAL nLeft
LOCAL nBottom
LOCAL nRight
WITH ThisForm
m.nTop = 0
m.nLeft = 0
m.nBottom = 0
m.nRight = 0
SPI_GetWorkArea( @nTop,@nLeft,@nBottom,@nRight )
&& Impossibility to hide the window at the rightmost side of the screen
IF ( .Left + .Width > m.nRight )
.Left = m.nRight - .Width
ENDIF
&& Impossibility to hide the window at the leftmost side of the screen
IF ( .Left < 0 )
.Left = 0
ENDIF
ENDWITH
Syntax
SPI_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\SPI.C-Mon Oct 19 15:55:22 1998" .
Parameters
nBorder border multiplier factor.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Alias
SetDoubleClickHeight(), SYS_SetDoubleClickHeight()
Syntax
SPI_SetDoubleClickHeight( nHeight ) lSuccess
Parameters
nHeight height in pixels of the rectangle in which the double click should occur.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Alias
SetDoubleClickTime(), SYS_SetDoubleClickTime()
Syntax
SPI_SetDoubleClickTime( nMilliSeconds )
Parameters
nMilliSeconds double-click time, in milliseconds.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Alias
SetDoubleClickHeight(), SYS_SetDoubleClickHeight()
Syntax
SPI_GetDoubleClickHeight( nHeight ) lSuccess
Parameters
nHeight width in pixels of the rectangle in which the double click should occur.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Syntax
SPI_SetFastTaskSwitch( lAltTab ) lSuccess
Parameters
lAltTab Alt-Tab fast task switching allowed (.T. ) or not (.F. ).
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
nGranularity new granularity of the desktop sizing grid.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
nSpacing width of an icon cell.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
lIconWrapping .T. if icon-title wrapping is ON; .F. otherwise.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
nSpacing height of an icon cell.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Syntax
SPI_SetKeyboardDelay( nValue ) lSuccess
Returns
lSuccess .T. if function was successful, .F. otherwise.
See also
SPI_SetKeyboardSpeed(), KEY_fast(), KEY_slow(), KEY_norm()
Syntax
SPI_SetKeyboardSpeed( nValue ) lSuccess
Parameters
nValue repeat-speed setting.
Returns
lSuccess .T. if function was successful, .F. otherwise.
See also
SPI_SetKeyboardDelay(), KEY_fast(), KEY_slow(), KEY_norm()
Parameters
lAlignment .T. for left-aligned; .F. otherwise.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
lSetting .T. to set the screen saver state, .F. otherwise.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
nValue screen saver time-out value.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Syntax
SPI_SetWallpaper( szFile ) lSuccess
Parameters
szFile string containing the name of a bitmap file.
Returns
lSuccess .T. if function was successful, .F. otherwise.
IF ( ! EMPTY( m.szFile ) )
&& For a tiled wallpaper
FIL_wwriin( "Desktop","TileWallpaper","1" )
SPI_SetWallpaper( m.szFile )
ENDIF
Parameters
nTop top of rectangle.
Returns
lSuccess .T. if function was successful, .F. otherwise.
Parameters
None.
Returns
szConstant "The operation completed successfully".
String Functions
Parameters
szString string to process.
Returns
szResult resulting string.
Example
? STR_addcod( "12345678",1 ) && "23456789"
Syntax
STR_AllChars( szString[,nType] ) szResult
Parameters
szString string to process.
Returns
szResult resulting string.
Example
LOCAL szString
Returns
nResult resulting number.
Example
? STR_ascii ( "AA" ) && 130
? STR_ascii2( "AA" ) && 195
? STR_ascii ( "AB" ) && 131
? STR_ascii2( "AB" ) && 197
Parameters
szString string to process.
Returns
nResult resulting number.
Example
? STR_ascii ( "AA" ) && 130
? STR_ascii2( "AA" ) && 195
? STR_ascii ( "AB" ) && 131
? STR_ascii2( "AB" ) && 197
Parameters
szAscii string to process.
Returns
szEbcdic resulting number.
Example
LOCAL szString
Parameters
n the position.
Returns
nLine line number. Please note that unlike VFP native ATLINE() function, the STR_AtLine()
function does not rely on SET MEMOWIDTH to calculate the line number: only the sequence
CR + LF ( CHR(13) + CHR(10) ) controls the line jump.
Example
&& This example searches an entire source code (.PRG) and locates
&& Change Control Tags so that they can be documented automatically
&& A Change Control tag has the following form:
&&
&& <cc date="20010520120000" auth="Anurak">
&& ... the code that is enclosed within the tags
&& </cc date="20010520120000">
&& As you can see there is an opening tag, and a closing tag
&&
LOCAL szCode
LOCAL nStart
LOCAL nEnd
LOCAL nEnd2
LOCAL nMatch
LOCAL szToken
LOCAL i
LOCAL szDateTime
LOCAL szAuthor
LOCAL szRef
LOCAL szComment
LOCAL nAtLine && Starting line
LOCAL nAtLine2 && Ending line
IF ( ! EMPTY( m.szCode ) )
m.n
&& Process the entire string
DO WHILE ( .T. )
&& Let's get an optional reference number (in case the Change Control
&& has been assigned such a number)
IF ( STR_Like( [*<cc*date="*"*ref="*"*>*],m.szCode,5,@nMatch,m.nStart ) != 0 )
m.szRef = STR_LikeGetToken()
ELSE
m.szRef = ""
ENDIF
&& Let's remember where the oepning tag was ending … because,
&& this will be used to continue the scanning of the source code
m.nStart = m.nEnd
&& If we found it
IF ( m.nEnd2 != 0 )
&& To which line of the source code this tag belongs to?
m.nAtLine2 = STR_AtLine( m.nEnd2,m.szCode )
ELSE
m.nAtLine2 = -1
ENDIF
ENDDO
ENDIF
Parameters
szString string to process.
Returns
nPosition position where character is balanced. szString starts at 1. If not found, 0.
Example
LOCAL szVar
Caution
No test is made on the parameters. Passing wrong parameters can produce unexpected results.
Syntax
STR_char( szString,nPosition ) szResult
Parameters
szString string to process.
Returns
szResult resulting string.
Example
? STR_char( "Hello World",3 ) && "llo World"
Parameters
szString string to process.
Returns
nOccurrences number of occurrences of cChar in szString .
Parameters
szString string to be processed.
Returns
szNewString resulting string.
Example
? STR_chrswa( "Hello World","l","A" ) && "HeAAo WorAd"
Parameters
szString string to be processed.
Returns
szNumber resulting string.
Example
? STR_comma( "1024.78","," ) && "1.024,78"
? STR_comma( "1024.78","." ) && "1,024.78"
Parameters
szString1 first string to compare.
nFlags comparison flags. These flags indicate how the function compares the two strings. By default,
these flags are not set. This parameter can specify zero to get the default behavior, or it can be
any combination of the following values :
Value Meaning
1 szString1 parameter is less in lexical value than the string pointed to by the
szString2 parameter.
2 szString1 is equal in lexical value to szString2 .
3 szString1 is greater in lexical value than szString2 .
Parameters
szString1 first string to compare.
nFlags comparison flags (optional). When not passed, the two strings are strictly compared. The only
supported flag is:
All together, these functions permit to convert character strings: a 'A' must be transformed into a 'C' , a 'C' into a
'B' , a 'B' into a 'A' , … It can be used to scramble strings. Likewise, it can be used to issue ASCII to EBCDIC
transformations.
Syntax
STR_ConvertA2B( szStr ) szResult
Parameters
szStr the string to treat.
Returns
szResult szStr transformed thanks to the internal conversion table. The internal conversion table can
be altered thanks to STR_SetConvTable() and STR_SetCharConversion() .
Example
LOCAL iCharH,iCharW
LOCAL szString
See also
STR_ConvertB2A() , STR_SetCharConversion() , STR_SetConvTable() .
Syntax
STR_ConvertB2A( szStr ) szResult
Parameters
szStr the string to treat.
Returns
szResult szStr transformed thanks to the internal conversion table. The internal conversion table can
be altered thanks to STR_SetConvTable() and STR_SetCharConversion() .
Example
LOCAL iCharH,iCharW
LOCAL szString
See also
STR_ConvertA2B() , STR_SetCharConversion() , STR_SetConvTable() .
Parameters
szString1 string to be search for.
Returns
szString resulting character string.
Example
? STR_cpbrk( "The 3 men and 2 dogs ate 5 pigs","0123456789" )
&& "3 men and 2 dogs ate 5 pigs"
Parameters
szBase64 the character string that is base 64 encoded.
Returns
szString original string.
Example
LOCAL szString
LOCAL szEncrypted
LOCAL szDecrypted
IF ( m.szDecrypted == m.szString )
? "It worked"
ELSE
? "It didn't worked"
ENDIF
Parameters
szString string to be processed.
Returns
szResult resulting string. Only digits and decimal separator are kept ( ".").
Example
? STR_dionly( "Hello the 101 dogs" ) && "101"
Parameters
szEbcdic string to process.
Returns
szAscii resulting number.
Parameters
szString string to process.
Returns
szBase64 the character string base 64 encoded.
Example
LOCAL szString
LOCAL szEncrypted
LOCAL szDecrypted
IF ( m.szDecrypted == m.szString )
? "It worked"
ELSE
? "It didn't worked"
ENDIF
Syntax
STR_encrypt( szString,szCode ) szResult
Parameters
szString string to process.
Returns
szResult the encrypted string.
Example
LOCAL szEncrypted
LOCAL szCode
Parameters
szString1 string to process.
Returns
lResult .T. if szString1 ends with szString2 .
Example
? STR_end( "Hello World","rld" ) && .T.
See also
STR_start()
Syntax
STR_exclude( szString,szToExclude ) szResult
Parameters
szString string to process.
szToExclude string from which each character should be excluded from szString .
Returns
szResult resulting string.
Example
LOCAL szString
Syntax
STR_find( szPattern,szString ) nPos
Parameters
szPattern the substring to look for in szString . szPattern cannot contain embedded NULs (CHR(0) ).
If szPattern is smaller than 5 characters, the internal search won't be optimized and you
won't notice performance gains compared to AT() .
Returns
nPos position where szPattern was found in szString .
Example
LOCAL szString,szPattern,nLoops,dNow,i
CLEAR
m.dNow = GetTickCount()
m.dNow = GetTickCount()
See also
STR_FindBackward()
Parameters
szPattern the substring to look for in szString . szPattern cannot contain embedded NULs (CHR(0) ).
If szPattern is smaller than 5 characters, the internal search won't be optimized and you
won't notice performance gains compared to AT() .
Returns
nPos position where szPattern was found in szString .
See also
STR_Find()
Parameters
szString string to find the first character from.
Returns
cChar first character that is not a space in szString . The string is processed from right to left.
Example
? STR_first( "Hello World" ) && "H"
? STR_first( " Hello" ) && "H"
See also
STR_last()
Parameters
n integer to treat as a size in bytes.
Returns
szSize resulting number.
Syntax
STR_getoff() nOffset
Parameters
None.
Returns
nOffset value returned by this function indicates the offset position prior STR_toknex() did reach
when retrieving tokens from a string.
See Also
STR_tokini() , STR_toknex() , STR_tokfin() .
Parameters
nLength optional length of the generated password. By default szPwd is 8 characters long.
nStrategy optional strategy when generating the password. By default, each character of szPwd is
generated using a random strategy.
Strategy Description
0 szPwd will contain digits only.
1 szPwd will contain uppercase letters only.
2 szPwd will contain lowercase letters only.
Returns
szPwd the generated password.
Example
? STR_GeneratePassword() && "M5RPY453"
? STR_GeneratePassword( 10 ) && "31B12cT9LE"
? STR_GeneratePassword( 10,0 ) && "5709359440"
? STR_GeneratePassword( 10,1 ) && "QVAADIVKFL"
? STR_GeneratePassword( 10,2 ) && "gpjjpfdojr"
Alias
stoh()
Syntax
STR_hexa( szString ) szHex
Parameters
szString string to process.
Returns
szHex hexadecimal equivalent of szString .
Example
? STR_hexa( "DVL Group" ) && "44564C2047726F7570"
? STR_htos("44564C2047726F7570" ) && "DVL Group"
See also
NUM_hexa() , STR_htos() , NUM_htoi()
Alias
htos()
Syntax
STR_htos( cHexaString ) szString
Parameters
cHexaString string to process.
Returns
szString original string.
Example
? STR_hexa( "DVL Group" ) && "44564C2047726F7570"
? STR_htos("44564C2047726F7570" ) && "DVL Group"
See also
STR_hexa()
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 535
String Functions
STR_IsAlpha() : Determines if a given string contains only
alpha characters.
Remark
Unlike the ISALPHA() function of Visual FoxPro which only considers the first character, this makes it possible to
examine the entire string, or only a portion of it.
Syntax
STR_IsAlpha( szString[,nStart[,nCount]] ) lResult
Parameters
szString string to process.
nStart specifies the position in the character string to examine. This parameter is optional. Default is 0.
nCount specifies the number of characters to test. This parameter is optional. Default is equal to the
length of the string from the nStart position.
Returns
lResult .T. if the string is only made of alpha characters. .F. otherwise.
Example
? STR_IsAlpha( "Hello All Of You" ) && .F.
? STR_IsAlpha( "Hello All Of You",1,5 ) && .T.
? STR_IsAlpha( "Hello All Of You",1,6 ) && .F.
See also
STR_IsUpper() , STR_IsLower() , STR_IsAlphaNumeric() , STR_IsPunct() , STR_IsSpace() ,
STR_IsPrint() , STR_IsGraph() , STR_IsVowel() , STR_IsConsonant()
Parameters
szString string to process.
nStart specifies the position in the character string to examine. This parameter is optional. Default is 0.
nCount specifies the number of characters to test. This parameter is optional. Default is equal to the
length of the string from the nStart position.
Returns
lResult .T. if the string is only made of alphanumeric characters. .F. otherwise.
Example
? STR_IsAlphaNumeric( "MYFILE105.EXT" ) && .F.
? STR_IsAlphaNumeric( "MYFILE105.EXT",1,9 ) && .T.
See also
STR_IsUpper() , STR_IsLower() , STR_IsAlpha() , STR_IsPunct() , STR_IsSpace() , STR_IsPrint() ,
STR_IsGraph() , STR_IsVowel() , STR_IsConsonant()
Parameters
szString string to process.
nStart specifies the position in the character string to examine. This parameter is optional. Default is 0.
nCount specifies the number of characters to test. This parameter is optional. Default is equal to the
length of the string from the nStart position.
Returns
lResult .T. if the string is only made of punctuation marks. .F. otherwise.
Example
? STR_IsPunct( "MYFILE105.EXT" ) && .F.
? STR_IsPunct( "MYFILE105.EXT",10 ) && .F.
? STR_IsPunct( "MYFILE105.EXT",10,1 ) && .T.
See also
STR_IsUpper() , STR_IsLower() , STR_IsAlpha() , STR_IsAlphaNumeric() , STR_IsSpace() ,
STR_IsPrint() , STR_IsGraph() , STR_IsVowel() , STR_IsConsonant()
Parameters
szString string to process.
nStart specifies the position in the character string to examine. This parameter is optional. Default is 0.
nCount specifies the number of characters to test. This parameter is optional. Default is equal to the
length of the string from the nStart position.
Returns
lResult .T. if the string is only made of spaces. .F. otherwise. The following characters are considered
to be spaces : CHR(9) , CHR(10) , CHR(11) , CHR(12) , CHR(13) , CHR(32) .
Parameters
szString string to process.
nStart specifies the position in the character string to examine. This parameter is optional. Default is 0.
nCount specifies the number of characters to test. This parameter is optional. Default is equal to the
length of the string from the nStart position.
Returns
lResult .T. if the string is only made of spaces. .F. otherwise. Only the representation of any ASCII
or Katakana printable character except a white space are considered to be graph characters : !,
", #, $, %, &, ', (, ), *, +, ,, -, ., /, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, :, ;, <, =, >,?, @, A, B, C, D, E,
F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, [, \, ], ^, _, `, a, b, c, d, e, f, g, h, i,
j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, {, |, }, ~.
See also
STR_IsUpper() , STR_IsLower() , STR_IsAlpha() , STR_IsAlphaNumeric() , STR_IsPunct() ,
STR_IsPrint() , STR_IsSpace() , STR_IsVowel() , STR_IsConsonant()
Parameters
szString string to process.
nStart specifies the position in the character string to examine. This parameter is optional. Default is 0.
nCount specifies the number of characters to test. This parameter is optional. Default is equal to the
length of the string from the nStart position.
Returns
lResult .T. if and only if the string is only made of single-byte representations of any ASCII or
Katakana printable character including a white space.
Syntax
STR_IsCharAlpha( szString[,nPosition] ) lResult
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult .T. if the character is an alpha character. .F. otherwise.
Example
? STR_IsCharAlpha( "Hello",1 ) && .T.
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharLower() , STR_IsCharUpper() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() .
Syntax
STR_IsCharAlphaNumeric( szString[,nPosition] ) lResult
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult .T. if the character is an alphanumeric character. .F. otherwise.
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha ,
STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() , STR_IsCharGraph() .
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult STR_IsCharDigit() returns a .T. value if the character is a digit. Otherwise it returns .F. .
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharUpper() , STR_IsCharLower() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharPrint() , STR_IsCharSpace() .
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult STR_IsCharGraph() returns a .T. value if the character is a printable character other than a
space. Otherwise it returns .F. .
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharUpper() , STR_IsCharLower() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharPrint() , STR_IsCharSpace() .
Syntax
STR_IsCharLower( szString[,nPosition] ) lResult
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult is the character in a lowercase format? .T. if yes, .F. if not.
Example
? STR_IsCharLower( "Hello",1 ) && .F.
? STR_IsCharLower( "Hello",2 ) && .T.
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() .
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult STR_IsCharPrint() returns a .T. value if the character is a printable character, including
the space character. Otherwise it returns .F..
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharUpper() , STR_IsCharLower() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharGraph() , STR_IsCharSpace() .
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult is the character a punctuation character? STR_IsCharPunct() returns .T. for any printable
character that is not a space character. Otherwise it returns .F..
Example
? STR_IsCharPunct( "Hello World.",12 ) && .T.
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharUpper() , STR_IsCharLower() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharSpace() , STR_IsCharPrint() , STR_IsCharGraph() .
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult is the character a white space character? STR_IsCharSpace() returns a .T. value if the
character is a white-space character (CHR(9) , CHR(10) , CHR(13) , CHR(32) ). Otherwise it
returns .F..
Example
? STR_IsCharSpace( "Hello World",6 ) && .T.
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharUpper() , STR_IsCharLower() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharPrint() , STR_IsCharGraph() .
Syntax
STR_IsCharUpper( szString[,nPosition] ) lResult
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. Optional parameter.
Returns
lResult is the character in an uppercase format? .T. if yes, .F. if not.
Example
? STR_IsCharUpper( "Hello",1 ) && .T.
? STR_IsCharUpper( "Hello",2 ) && .F.
See also
STR_IsUpper() , STR_IsLower() , STR_IsCharLower() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() .
Parameters
szString string to process.
nPosition specifies the position in the character string to examine. If not passed, the first character of the
string is examined.
Returns
lResult .T. if the character is a hexadecimal digit; .F. if not.
Example
? STR_IsCharXDigit( "0123456789ABCDEF" ) && .T.
? STR_IsCharXDigit( "0123456789ABCDEFG",17 ) && .F.
Syntax
STR_IsDigit( szString[,nStart[,nLength]] ) lResult
Parameters
szString string to process.
nStart specifies the position in the character string from where the string is going to be processed.
Optional. When not mentioned, the string is processed from the first position.
nLength specifies the number of characters to process. Optional. When not mentioned, the string is
processed from the starting position to the end of the string.
Returns
lResult are all the examined characters digits? .T. if yes, .F. if not.
Example
? STR_IsDigit( "Hello101" ) && .F.
? STR_IsDigit( "Hello101" ,6 ) && .T.
? STR_IsDigit( "Hello101a",6 ) && .F.
? STR_IsDigit( "Hello101a",6,3 ) && .T.
See also
STR_IsUpper() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharDigit() , STR_IsCharGraph() .
Parameters
szString string to process.
nStart specifies the position in the character string from where the string must be processed. Optional.
If not mentioned, the string is processed from the first position ( 1).
Returns
lResult are all characters digits and/or decimal separators ('.' )? .T. if yes, .F. if not.
Example
? STR_IsDigit( "101.8" ) && .F.
? STR_IsDigitOrDecimalSeparator( "101.8" ) && .T.
See also
STR_IsUpper() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharDigit() , STR_IsCharGraph() .
Syntax
STR_IsInSet( szString,szCharacters[,nStart[,nLength]] ) lResult
Parameters
szString string to process.
nStart specifies the position in the character string from where the string is going to be processed.
Optional. When not mentioned, the string is processed from the first position.
nLength specifies the number of characters to process. Optional. When not mentioned, the string is
processed from the starting position to the end of the string.
Returns
lResult are all the examined characters belonging to the cCharacters set of characters? .T. if yes,
.F. if not.
Example
? STR_IsInSet( " –123.18"," +-0123456789." ) && .T.
See also
STR_IsUpper() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() .
Returns
lIsNumber .T. if szString can be evaluated to a number; .F. if not.
Example
? STR_IsNumber( "45" ) && .T.
? STR_IsNumber( "45a" ) && .F.
? STR_IsNumber( "45+12" ) && .T.
? STR_IsNumber( "45-12" ) && .T.
Syntax
STR_IsLower( szString[,nStart[,nLength]] ) lResult
Parameters
szString string to process.
nStart specifies the position in the character string from where the string is going to be processed.
Optional. When not mentioned, the string is processed from the first position.
nLength specifies the number of characters to process. Optional. When not mentioned, the string is
processed from the starting position to the end of the string.
Returns
lResult are all the examined characters in a lowercase format? .T. if yes, .F. if not.
Example
? STR_IsLower( "Hello" ) && .F.
? STR_IsLower( "Hello",2 ) && .T.
? STR_IsLower( "HelLo",2,2 ) && .T.
See also
STR_IsUpper() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() .
Syntax
STR_IsUpper( szString[,nStart[,nLength]] ) lResult
Parameters
szString string to process.
nStart specifies the position in the character string from where the string is going to be processed.
Optional. When not mentioned, the string is processed from the first position.
nLength specifies the number of characters to process. Optional. When not mentioned, the string is
processed from the starting position to the end of the string.
Returns
lResult are all the examined characters in an uppercase format? .T. if yes, .F. if not.
Example
? STR_IsUpper( "hELLO" ) && .F.
? STR_IsUpper( "hELLO",2 ) && .T.
? STR_IsUpper( "hELlo",2,2 ) && .T.
? STR_IsUpper( "hELlo",2,3 ) && .F.
See also
STR_IsLower() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() .
Parameters
cNumber credit card number with a maximum of 16 digits (if more, the function may generate illegal
operations). Non digit characters are disregarded.
Returns
Example
? STR_IsValidCreditCard( "6045.4360.3078.4771" ) && .F.
Parameters
szString string to process.
nStart specifies the position in the character string from where the string is going to be processed.
Optional. When not mentioned, the string is processed from the first position.
nLength specifies the number of characters to process. Optional. When not mentioned, the string is
processed from the starting position to the end of the string.
Returns
lResult are all the examined characters hexadecimal digits? .T. if yes, .F. if not.
Example
? STR_IsXDigit( "0123456789aBCDEF" ) && .T.
? STR_IsXDigit( "0123456789ABCDEF" ) && .T.
? STR_IsXDigit( "0123456789ABCDEFG" ) && .F.
? STR_IsXDigit( "0123456789ABCDEFG",1,16 ) && .T.
See also
STR_IsLower() , STR_IsCharLower() , STR_IsCharUpper() , STR_IsCharAlpha() ,
STR_IsCharAlphaNumeric() , STR_IsCharPunct() , STR_IsCharSpace() , STR_IsCharPrint() ,
STR_IsCharGraph() , STR_IsCharXDigit() .
Parameters
szString string to be processed.
Returns
szNewString resulting string. The function is case sensitive !
Example
? STR_keep( "Hello World","lod" ) && "lloold" (Length = 6)
Returns
szNewString resulting string. The function is case sensitive !
Example
? STR_KeepConsonants( "Hello World" ) && "HllWrld"
Parameters
szString string to be processed.
Returns
szNewString resulting string. The function is case sensitive !
Example
? STR_KeepVowels( "Hello World" ) && "eoo"
Parameters
szString string to find the last character from.
Returns
cChar last character that is not a space in szString . The string is processed from left to right.
Example
? STR_last( "Hello World" ) && "d"
? STR_last( "World " ) && "d"
See also
STR_first()
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\STRINGS.C-Mon Oct 19 15:55:22 1998" .
Parameters
szString string to process.
nCount specifies the number of characters returned from the character expression. This parameter is
optional. If nCount is greater than the length of szString , an empty string is returned. If
nCount is not specified, only the leftmost character of szString is returned.
Returns
cResult the nCount leftmost characters of szString .
Example
? STR_Left("Hello" ) && "H"
? STR_Left("Hello",4 ) && "Hell"
Syntax
STR_Length( szString ) nLength
Parameters
szString string of which to determine length.
Returns
nLength length of the string.
Syntax
STR_Like( szToLookFor,[@]szToSearch[,nToken[,@nLastMatch[,nStart]]] ) nMatch
Parameters
szToLookFor the character expression to look for. Wildcards are permitted (* for any character, ? for a single
character).
szToSearch the character expression to search. This parameter can be sent by reference for better
performance (remains unchanged).
Returns
nMatch position where the match ends; 0 if no match is found.
Example
LOCAL szHTML
&& Example 1
m.szHTML = '<HTML><HEADER><TITLE>Hello World' + ;
'</TITLE></HEADER><BODY BGCOLOR="#FFFF00">This is the body</BODY></HTML>'
&& Example 2
&& This example searches an entire source code (.PRG) and locates
&& Change Control Tags so that they can be documented automatically
&& A Change Control tag has the following form:
&&
&& <cc date="20010520120000" auth="Anurak">
&& </cc date="20010520120000">
&& As you can see there is an opening tag, and a closing tag
&&
LOCAL szCode
LOCAL nStart
LOCAL nEnd
LOCAL nEnd2
LOCAL nMatch
IF ( ! EMPTY( m.szCode ) )
m.n
&& Process the entire string
DO WHILE ( .T. )
&& That's the line number where we found the opening tag
m.nAtLine = STR_AtLine( m.nEnd,m.szCode )
&& Let's get an optional reference number (in case the Change Control
&& has been assigned such a number)
IF ( STR_Like( [*<cc*date="*"*ref="*"*>*],m.szCode,5,@nMatch,m.nStart ) != 0 )
m.szRef = STR_LikeGetToken()
ELSE
m.szRef = ""
ENDIF
&& Let's remember where the oepning tag was ending … because,
&& this will be used to continue the scanning of the source code
m.nStart = m.nEnd
&& If we found it
IF ( m.nEnd2 != 0 )
&& To which line of the source code this tag belongs to?
m.nAtLine2 = STR_AtLine( m.nEnd2,m.szCode )
ELSE
m.nAtLine2 = -1
ENDIF
ENDDO
ENDIF
Syntax
STR_LikeCase( [lSetting] ) lOldSetting
Parameters
lSetting the new setting for STR_Like() . This parameter is optional. If not passed, the function simply
returns the current setting. .T. means case sensitive; .F. not.
Returns
lOldSetting old setting.
Example
LOCAL szHTML
Syntax
STR_LikeGetToken() szToken
Returns
szToken the specified token or an empty string is this token hasn't been found.
Example
LOCAL szHTML
Parameters
szString string to process.
Returns
szNewString string with leading blanks removed.
Example
LOCAl szString
See Also
STR_TrimLeft() , STR_TrimRight()
Parameters
szString string to process.
Example
? STR_mirror( "Hello" ) && "olleH"
Parameters
szString string to process.
Returns
szMixUp the string mixed up. STR_MixUp() can be successfully applied on its return value to retrieve
the original string. STR_MixUp() , when combined to other string functions of FOCUS.FLL , can
be used to encrypt strings.
Example
LOCAL szString
LOCAL szEncrypted
LOCAL szDecrypted
Syntax
STR_n( szString,n ) cChar
Parameters
szString string to extract the nth character from.
n string offset.
Returns
cChar character that was extracted from szString . The first character has order 1.
See also
STR_last(), STR_first()
Syntax
STR_nparam( szString,n ) szParam
Parameters
szString string to extract the nth parameter from.
n parameter number.
Returns
szParam character that was extracted from szString . The first character has order 1.
Example
? STR_nparam( "MyFunc(15,YourFunc(10,11,12),20",1 ) && "15"
? STR_nparam( "MyFunc(15,YourFunc(10,11,12),20",2 ) && "YourFunc(10,11,12)"
? STR_nparam( "MyFunc(15,YourFunc(10,11,12),20",2 ) && "20"
Parameters
szString1 string to be search for.
Returns
nPosition position of 1st occurrence of a character of szString2 in szString1
Example
? STR_npbrk( "The 3 men and 2 dogs ate 5 pigs","0123456789" ) && 5
Parameters
szString string to process (cannot contain embedded nulls CHR(0) ).
n number of characters to be set. If n is greater than the length of szString , the length of
szString is used instead of n.
Returns
szNewString altered string.
Example
&& Example 1
? STR_nset( "Hello World","B",4 ) && "BBBBo World"
&& Example 2
str2 = SPACE( 15 )
str = REPLICATE( "B",15 )
? str && "BBBBBBBBBBBBBBB"
? str2 && " "
? LEN( str ) && 15
? LEN( str2 ) && 15
str2 = str_nset( str,"A",3,4 ) && Set 3 characters starting at position 4
? str2 && "BBBAAABBBBBBBBB"
Syntax
STR_ntoken( nToken,szString[,nStart] ) szToken
Parameters
nToken token number.
Returns
szToken desired token.
Example
LOCAL szOldSep
LOCAL szString
LOCAL nTokens
LOCAL i
Syntax
STR_null() ""
Parameters
None.
Returns
"" empty string.
Alias
NumberOfTokens()
Syntax
STR_numtok( szString[,nStart] ) nTokens
Parameters
szString string to process.
Returns
nTokens number of tokens based on the internal separator.
Example
LOCAL szOldSep
LOCAL szString
LOCAL nTokens
LOCAL i
Parameters
szString string to process.
Returns
nPosition position where the nOccurrence of cChar was found in szString .
Parameters
szString string to process.
Returns
nCode ASCII code value of the character found at nPosition in szString .
Example
? STR_peek( "Hello",1 ) && 72 because 'H' is 72
See also
STR_n() , STR_poke()
Parameters
szString string to process.
Returns
szResult resulting string.
Example
szString = "Hello"
? STR_poke( szString,2,97 ) && "Hallo"
? szString && "Hello"
See also
STR_peek()
Parameters
szString string to be processed.
szSpecialChars characters that should force an uppercase of the next letter. Usually, these characters are
" ","'","." ,"-".
Returns
szProper resulting string.
Potential problem
When STR_Proper() treats a character string, it cannot distinguish between characters that must be especially kept
lowercase as it appears in names such as "Jan de la Court" where "de la" should be especially kept as it is.
Therefore, STR_Proper() will use the special character "\" to force an unchanged letter. The way to keep "JAN DE
LA COURT" being properly uppercased is to pass the following string "JAN \DE \LA COURT" . This is forcing the
following result "Jan de la Court" .
All characters that are preceded by a backslash are rendered as they appear in the original string.
Example
LOCAL szName
The STR_raw() function is really handy to replace strings formed of a character range. For example the
STR_raw( 1,5 ) is strictly equivalent to CHR(1)+CHR(2)+CHR(3)+CHR(4)+CHR(5) .
Syntax
STR_raw( nRangeIn,nRangeOut ) szString
Parameters
nRangeIn starting range.
Returns
szString the character string is formed with all the ASCII characters comprised within ASCII nRangeIn
and ASCII nRangeOut .
Example
? STR_raw( 1,5 ) == CHR(1)+CHR(2)+CHR(3)+CHR(4)+CHR(5) && .T.
Parameters
szString string to process.
Returns
szNewString resulting string.
Example
? STR_reduce("Hello WWWorld","W" ) // "Hello World"
Syntax
STR_relin( szString ) szNewString
Parameters
szString string to process.
Returns
szNewString resulting string.
Example
? STR_relin( "Hellllllllllo World" )
&& The multiple l in "Hellllllllllo World" will be reduced to 3
&& characters (first one is CHR(1), second is the number of
&& occurrences, third is the character that should be repeated
Parameters
szString string to process.
Returns
szOriString resulting string.
Example
szString = "Hellllllllllo World"
? STR_relout( STR_relin( szString ) ) && "Hellllllllllo World"
Parameters
szString string to process.
szExpSought character expression that is searched for in szString . The search is case-sensitive.
Example
STR_Replace( "Hello Pat","Pat","Martin" ) && "Hello Martin"
Syntax
STR_ResetLikeCharConversions() .T.
Parameters
None.
Returns
.T. the function returns always .T. .
Example
? STR_Like( "*Sammy*","Fanny was here." ) && 0
STR_SetLikeCharConversion( "S","F" )
STR_SetLikeCharConversion( "m","n" )
STR_ResetLikeCharConversions()
Parameters
szString string to process.
nCount specifies the number of characters returned from the character expression. This parameter is
optional. If nCount is greater than the length of szString , an empty string is returned. If
nCount is not specified, only the rightmost character of szString is returned.
Example
? STR_Right("Hello" ) && "o"
? STR_Right("Hello",4 ) && "ello"
Parameters
szString string to process.
Returns
szNewString string with trailing blanks removed.
Example
LOCAl szString
Syntax
STR_SetCharConversion( iChar1,iChar2 ) lSuccess
Parameters
iChar1 character for which a conversion needs to take place.
Returns
.T. .T.. if the function is successful; .F. if not.
Example
LOCAL iCharH,iCharW
LOCAL szString
See also
STR_ConvertA2B() , STR_ConvertB2A() , STR_SetConvTable() .
All together, these functions permit to convert character strings: a 'A' must be transformed into a 'C' , a 'C' into a
'B' , a 'B' into a 'A' , … It can be used to scramble strings. Likewise, it can be used to issue ASCII to EBCDIC
transformations.
Syntax
STR_SetConvTable( @aConv ) lResult
Parameters
aConv a 256 elements array (MUST be passed by reference). Each cell of the array contains the value
that must be applied for the conversion. The position itself (array index) is associated to the
character for which a conversion must take place (be careful … position 1 in the array is
associated with CHR(0) ).
Returns
lResult .T. if function is successful, .F. if not.
Example
LOCAL ARRAY aConv[256]
<Je devrais reprendre l'exemple d'une table de conversion EBCDIC comme dans le conversion.txt>
FOR i = 1 TO 256
aConv[i] = <ICI JE DOIS CONTINUER>
NEXT
See also
STR_ConvertA2B() , STR_ConvertB2A() , STR_SetCharConversion() .
Parameters
cChar1 character for which a conversion needs to take place.
Returns
.T. the function returns always .T. .
Example
? STR_Like( "*Sammy*","Fanny was here." ) && 0
STR_SetLikeCharConversion( "S","F" )
STR_SetLikeCharConversion( "m","n" )
Syntax
STR_setoff( nOffset ) .T.
Parameters
nOffset new value to post into the internal counter Offset. Extra caution ... you can easily fool this
function and consequently STR_toknex() will yield unpredictable results.
Returns
.T. the function always returns a logical .T.
Syntax
STR_setsep( szSeparators ) szOldSeparators
Parameters
szSeparators new separators to use. By default the current separators is ",". You can use a multiple
separators such as ",;:.()/" .
Example
LOCAL szOldSep
LOCAL szString
LOCAL nTokens
LOCAL i
Syntax
STR_shl( szString,nBits ) szNewString
Parameters
szString string to be processed.
nBits number of bits to shift the string by. Minimum 1 bit, maximum 7 bits. If you pass a negative
number, the function acts as its contrary STR_shr() .
Returns
szNewString shifted string.
Syntax
STR_shr( szString,nBits ) szNewString
Parameters
szString string to be processed.
nBits number of bits to shift the string by. Minimum 1 bit, maximum 7 bits. If you pass a negative
number, the function acts as its contrary STR_shl() .
Syntax
STR_sort( szStr ) szSorted
Parameters
szStr string to process.
Returns
szSorted szStr sorted.
Example
? STR_sort( "Hello World" ) && "Hwdellloor"
Syntax
STR_Soundex( szString ) nResult
Parameters
szString string to process.
Returns
nResult phonetic key representing szString .
Example
&& If the name of that terrorist appears in the text, I won't miss it
? STR_soundex( "Ousama Bin Ladin" ) == STR_soundex( "Usama Ben Laden" ) && .T.
? STR_soundex( "Ousamma BinLadin" ) == STR_soundex( "Usama ben Laten" ) && .T.
Returns
lResult .T. if szString1 starts with szString2 .
Example
? STR_start( "L'Année du dragon","L'" ) && .T.
See also
STR_end()
Parameters
szString string to process.
Returns
szNewString szString without any character comprised within ASCII nRangeIn and ASCII nRangeOut .
Example
? STR_strip( szString,0,31 ) && Eliminates all chars between ASCII 0 and 31
Parameters
n token number.
Returns
szToken extracted token.
See also
STR_end()
Parameters
szString the string to process. Usually this strings contains null characters.
Returns
szResult the stripped string. The function does not strip all null characters. It merely returns a substring
up to the first null of szString .
Example
LOCAL szString
Comment
STR_tokfin() is one of the token functions. This function is intended to be used to know if we processed entirely a
string with STR_toknex() .
Syntax
STR_tokfin() lEnd
Parameters
None.
Returns
lEnd indicates whether we processed the entire token string.
szString = "Hello all of you. Are you OK? What's your name? Mine is Pat"
STR_setsep( " .,;?" ) && Separators to be considered
STR_tokini( szString ) && Initialize the string
CLEAR
See Also
STR_tokini() , STR_toknex() .
Syntax
STR_tokini( szString ) .T.
Parameters
szString the string to be processed.
Returns
.T. the function always returns a logical .T.
Example
LOCAL szString
LOCAL szToken
szString = "Hello all of you. Are you OK? What's your name? Mine is Pat"
STR_setsep( " .,;?" ) && Separators to be considered
STR_tokini( szString ) && Initialize the string
CLEAR
Syntax
STR_toknex( szString ) szToken
Parameters
szString string from which the next token has to be extracted.
Returns
szToken next token available in stream.
Example
LOCAL szString
LOCAL szToken
szString = "Hello all of you. Are you OK? What's your name? Mine is Pat"
STR_setsep( " .,;?" ) && Separators to be considered
STR_tokini( szString ) && Initialize the string
CLEAR
See Also
STR_tokini() , STR_tokfin() .
Parameters
nToken token number.
Example
LOCAL cOldSep
LOCAL szString
STR_setsep( cOldSep )
Caution
When you attempt to determine the starting position of a given token, ensure that this token does really exist because
no test is made to ensure this from within the C and assembler routines. Trying to access a non existing token can
produce unpredictable results.
Parameters
szString string to process.
n characters count.
Returns
szNewString output string.
Example
LOCAl szString
m.szString = "ABCDE"
See Also
STR_LTrim() , STR_RTrim() , STR_TrimRight()
Parameters
szString string to process.
n characters count.
Example
LOCAl szString
m.szString = "ABCDE"
See Also
STR_LTrim() , STR_RTrim() , STR_TrimRight()
System Functions
Syntax
SYS_ACLineStatus() nStatus
Parameters
None.
Returns
nStatus AC power status. This parameter can be one of the following values:
Value Description
0 Offline
1 Online
255 Unknown status
Parameters
szTitle title of the new console window. This parameter is optional.
Returns
nSuccess 1 if the function is entirely successful; -1 if the function is partially successful; 0 if failure.
Example
SYS_FreeConsole() && Free the current console if any
Syntax
SYS_avaclu( szDrive ) nClusters
Returns
nClusters number of available clusters.
Example
LOCAL nClusters
LOCAL nSectors
LOCAL nBytes
LOCAL szDrive
See also
SYS_totclu()
Syntax
SYS_BatteryFlag() nStatus
Parameters
None.
Returns
nStatus battery charge status. This parameter can be a combination of the following values:
Value Description
1 High
2 Low
4 Critical
8 Charging
128 No system battery
255 Unknown status
On Windows NT 4.0 this function returned 0. It is not documented anywhere what this value
means.
Parameters
None.
Returns
nStatus number of seconds of battery life when at full charge, or
-1 if full lifetime is unknown.
Syntax
SYS_BatteryLifePercent() nPercent
Parameters
None.
Returns
nPercent percentage of full battery charge remaining. It can be a value in the range 0 to 100, or 255 if
status is unknown.
Syntax
SYS_BatteryLifeTime() nSeconds
Parameters
None.
Returns
nSeconds number of seconds of battery life remaining, or -1 if remaining seconds are unknown.
Parameters
szSetting setting that has changed.
Returns
.T. the function always returns .T..
Syntax
SYS_bytsec( szDrive ) nBytes
Parameters
szDrive drive letter from which to obtain the number of bytes per sector.
Returns
nBytes number of bytes per sector.
Example
LOCAL nClusters
LOCAL nSectors
LOCAL nBytes
LOCAL szDrive
See also
SYS_totclu(), SYS_avaclu(), SYS_secclu()
Syntax
SYS_ConfigurePort( szPort ) .T.
Returns
.T. the function always returns .T..
Examples
? SYS_ConfigurePort( "LPT1" )
* Displays the following dialog
? SYS_ConfigurePort( "COM1" )
* Displays the following dialogs
Parameters
None.
Returns
nHwnd 0 if the function is not successful; otherwise the window handle (HWND).
Parameters
None
Returns
szTitle Title of the console window.
Example
&& If we can allocate a new console
IF ( SYS_AllocConsole( "FOCUS Debugging Window" ) != 0 )
? SYS_GetConsoleTitle() && Should be "FOCUS Debugging Window"
SYS_SetConsoleTitle( "My new debugging window" )
ENDIF
Alias
CreateMutex()
Syntax
SYS_CreateMutex( szMutex ) nMutexHandle
Parameters
szMutex string indicating the mutex name.
Returns
nMutexHandle handle to the mutex object.
Remark
A very easy way to check whether an Instance of an application is already in memory is to create a named mutex. In
an application you first test whether a given mutex exists, if not, you create it. If it exists, that means that the
application is already running.
Example
&& This example checks whether a given mutex already exists;
&& if it exists, it means that this application is in memory,
&& and consequently, already unloads
IF ( ! SYS_isMutex( "UniqueMutex" ) )
SYS_CreateMutex( "UniqueMutex" )
ELSE
QUIT
ENDIF
Parameters
None.
Returns
szDrive current system drive. This function differs from FoxPro built-in SYS(5) which returns the SET
DEFAULT TO setting, even though under normal circumstances this should be the same.
Example
? "Current drive = " + SYS_curdri()
Alias
DeleteMutex()
Syntax
SYS_DeleteMutex( nMutexHandle ) lSuccess
Parameters
nMutexHandle handle to the mutex object.
Returns
lSuccess .T. if the operation was successful; .F. if not.
See also
SYS_isMutex() , SYS_CreateMutex()
Returns
szDisplayDrv display driver used by the system.
Example
* This could be used in an About dialog box
? "Display driver : ",SYS_displa()
Parameters
szDrive drive to test for existence.
Returns
lExist .T. if <szDrive> exists, .F. otherwise.
Parameters
szRootDir root directory of drive to obtain information from.
Returns
lCompression .T. if file system supports compression, .F. otherwise.
Syntax
SYS_dosmaj() nMajor
Parameters
None.
Example
? "DOS ver : " + LTRIM(STR(SYS_dosmaj())) + "." + LTRIM(STR(SYS_dosmin()))
Syntax
SYS_dosmin() nMinor
Parameters
None.
Returns
nMinor DOS minor version number.
Example
? "DOS ver : " + LTRIM(STR(SYS_dosmaj())) + "." + LTRIM(STR(SYS_dosmin()))
Parameters
None.
Returns
szString string where all available drives are listed.
Example
szDriveStr = SYS_dristr()
Syntax
SYS_DriveType( szDriveRoot ) nType
Returns
nType drive type.
#define DRIVE_UNKNOWN 0
#define DRIVE_NO_ROOT_DIR 1
#define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3
#define DRIVE_REMOTE 4
#define DRIVE_CDROM 5
#define DRIVE_RAMDISK 6
See also
FOCUS.FLL will use GetDiskFreeSpaceEx() if possible; in other cases it will turn down to
GetDiskFreeSpace() . The code of FOCUS.FLL has changed due to the remark of Paul Newton which also made all
the necessary research to help us fix the problem.
Alias
DiskSize(), SYS_DiskSize()
Syntax
SYS_dsksiz( szDrive ) nBytes
Parameters
szDrive drive to test. It can be a full pathname with a drive specifier since only the first character is
checked.
Return
nBytes total capacity of szDrive .
See also
? SYS_dskspa()
FOCUS.FLL will use GetDiskFreeSpaceEx() if possible; in other cases it will turn down to
GetDiskFreeSpace() . The code of FOCUS.FLL has changed due to the remark of Paul Newton which also made all
the necessary research to help us fix the problem.
Alias
DiskRoom(), SYS_DiskSpace(), SYS_DiskSpaceLeft(), SYS_DiskEmpty()
Syntax
SYS_dskspa( szDrive ) nBytes
Parameters
szDrive drive to test. It can be a full pathname with a drive specifier since only the first character is
checked.
Return
nBytes number of available bytes on the specific drive. This function is useful for determining whether
sufficient space is available on a given drive. It differs from FoxPro DISKSPACE() in that it
allows the developer to specify which drive has to be checked while FoxPro only checks for the
current drive.
Example
? SYS_dskspa( SYS_curdri() + ":\" )
See also
? SYS_dsksiz()
Alias
EnumDeviceDrivers()
Syntax
SYS_EnumDeviceDrivers() szList
Parameters
nAppTypes optional parameter: 0 by default. Can be 16 if you want to list 16-bit applications, or 32 for 32-
bit applications. This parameter is completely ignored when the function operates on the
Windows NT platform.
Returns
szList list of all active tasks running on the system. Each task is separated by each other by a caret
(^) like in this example :
"KERNEL32.DLL(32-bit)^MSGSRV32(16-bit)^MPREXE.EXE(32-bit)^VSHWIN32.EXE(32-
bit)^MMTASK(16-bit)^EXPLORER.EXE(32-bit)^POINTEXE(16-bit)^SYSTRAY.EXE(32-
bit)^SAGE.EXE(32-bit)^INTERNAT.EXE(32-bit)^FINDFAST.EXE(32-bit)^SPOOL32.EXE(32-
bit)^INFOVIEW.EXE(32-bit)^MSVC.EXE(32-bit)^WINOLDAP(16-bit)^VFP.EXE(32-
bit)^CTCD(16-bit)^WINWORD.EXE(32-bit)"
When no parameter has been passed to the function, or when this parameter was 0, then each
process is clearly shown as a 32-bit or 16-bit process when run under Windows 9x. When run in
NT, the function does not add any process information (16-bit or 32-bit).
Example
? SYS_Processes() under Windows 95 or Windows 98 (Windows 9x)
&& KERNEL32.DLL(32-bit)^MSGSRV32(16-bit)^MPREXE.EXE(32-bit)^VSHWIN32.EXE(32-
&& bit)^MMTASK(16-bit)^EXPLORER.EXE(32-bit)^POINTEXE(16-bit)^SYSTRAY.EXE(32-
&& bit)^SAGE.EXE(32-bit)^INTERNAT.EXE(32-bit)^FINDFAST.EXE(32-bit)^SPOOL32.EXE(32-
&& bit)^INFOVIEW.EXE(32-bit)^MSVC.EXE(32-bit)^WINOLDAP(16-bit)^VFP.EXE(32-
&& bit)^CTCD(16-bit)^WINWORD.EXE(32-bit)
Parameters
nNewHandlerLevel new level of Windows error handling.
Returns
nOldHandlerLevel old level of Windows error handling.
Caution
Be extra careful when using this function because it supersedes Windows default behavior.
Syntax
SYS_exenam() szExeName
Parameters
None.
Returns
szExeName name of the current executable.
Example
? FIL_exenam()
? SYS_exenam()
? SYS( 16,0 )
Alternatives
Try SYS(16,0) to get the real .EXE name.
Syntax
SYS_ExitProcess( nLevel ) you never return from this function
Parameters
nLevel the error level to return to calling application or command file.
Returns
None.
Example
SYS_ExitProcess( 115 ) && 115 is completely arbitrary!
See also
SYS_ExitWindows() , SYS_FatalExit()
Syntax
SYS_ExitWindows( nMode ) lSuccess
Parameters
nMode shutdown operation.
Value Description
0 Logoff
1 Shuts down the system to a point at which it is safe to turn off the power. All file
buffers have been flushed to disk, and all running processes have stopped
2 Reboot
4 Forces processes to terminate. When this flag is set, Windows does not send the
messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications
currently running in the system. This can cause the applications to lose data.
Therefore, you should only use this flag in an emergency
8 Shuts down the system and turns off the power. The system must support the
power-off feature
Returns
lSuccess .T. if the command could be executed; .F. if not.
Alias
FatalExit()
Syntax
SYS_FatalExit( szMsg ) you never return from this function
Parameters
szMsg message to be displayed in the dialog box. The dialog bow appears to be different in
Windows 95 and in Windows NT.
Returns
None.
Example
SYS_FatalExit( "Unexpected error. Quit" )
See also
SYS_ExitWindows() , SYS_ExitProcess()
Syntax
SYS_FileSystemName( szDrive ) szFS
Parameters
szDrive drive to consider. It contains the root directory of the volume whose file system is to be
determined. If this parameter is NULL , the root of the current directory is used. If this
parameter is a UNC name, you must follow it with an additional backslash. For example, you
would specify "\\MyServer\MyShare" as "\\MyServer\MyShare\" .
Returns
szFS file system ("FAT" , "NTFS" , "HPFS" , "CDFS" , etc.).
Example
IF ( SYS_FileSystemName( "C:\" ) == "NTFS" )
? "You can start using NTFS capabilities"
ENDIF
Parameters
nDrive drive number (0=A, 1=B, 2=C, etc.)
Returns
.T. the function always returns .T. .
Remark
Windows cannot format the drive on which its own files are located.
Example
SYS_FormatDrive( 3 )
See also
SYS_isMutex() , SYS_DeleteMutex()
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
SYS_FreeConsole() && Free the current console if any
Parameters
nInstanceHandle handle of the DLL.
Returns
lSuccess .T. if the function was successful; .F. otherwise.
Example
LOCAL nInst
IF ( nInst != -1 )
? "MQSeries server is installed"
ELSE
nInst = SYS_LoadLibrary( "MQIC32.DLL" )
IF ( nInst != -1 )
? "MQSeries client is installed"
ELSE
? "MQSeries is not installed"
ENDIF
ENDIF
IF ( nInst != -1 )
SYS_FreeLibrary( nInst )
ENDIF
Returns
nMilliSeconds the blink time, in milliseconds.
Value Description
0 Unknown
1 SCS_32BIT_BINARY
2 SCS_DOS_BINARY
3 SCS_OS216_BINARY
4 SCS_PIF_BINARY
5 SCS_POSIX_BINARY
6 SCS_WOW_BINARY
Syntax
SYS_GetCaretBlinkTime() nMilliSeconds
Parameters
None.
Returns
nMilliSeconds the blink time, in milliseconds.
Example
OldCaretBlinkTime = SYS_GetCaretBlinkTime()
See also
SYS_SetCaretBlinkTime()
Syntax
SYS_GetCaretPosX() nPos
Parameters
None.
See also
SYS_GetCaretPosY() , SYS_SetCaretPos()
Syntax
SYS_GetCaretPosY() nPos
Parameters
None.
Returns
nPos y-coordinate expressed in the current client coordinates.
See also
SYS_GetCaretPosX() , SYS_SetCaretPos()
Syntax
SYS_GetCommandLine() cCmdLine
Parameters
None.
Returns
cCmdLine command line string used to start the current process.
Parameters
None.
Syntax
SYS_GetDllVersion( szDLL,nInfo ) nVersionInfo
Parameters
szDLL the name of the DLL to query information from.
Value Description
1 Major number
2 Minor number
3 Build number
4 Platform ID
#define DLLVER_PLATFORM_WINDOWS 0x00000001 // Windows 95/98
#define DLLVER_PLATFORM_NT 0x00000002 // Windows NT
Any other Major number
numeric
value
Returns
nVersionInfo the version info that was queried. -1 if the DLL couldn't be opened. -2 if the version info
couldn't be obtained.
Example
? SYS_GetDllversion( "shell32.dll",1 ) // 4
? SYS_GetDllversion( "shell32.dll",2 ) // 72
? SYS_GetDllversion( "shell32.dll",4 ) // 1
See also
SHE_GetDllVersion()
Syntax
SYS_GetEnvironmentStrings( szVar ) szEnvironment
Parameters
None.
Returns
szEnvironment the value of the whole environment block. Each variable is separated by a caret ( ^).
Example
? SYS_GetEnvironmentStrings()
&& On our system it did return:
See also
SYS_SetEnvironmentVariable() , SYS_GetEnvironmentStrings()
Syntax
SYS_GetEnvironmentVariable( szVar ) szValue
Parameters
szVar the variable to query
Example
IF ( SYS_SetEnvironmentVariable( "Hello World","This is Hello" ) )
? SYS_GetEnvironmentVariable( "Hello World" ) && "This is Hello"
? GETENV( "Hello World" ) && ""
ENDIF
See also
SYS_SetEnvironmentVariable() , SYS_GetEnvironmentStrings()
Syntax
SYS_GetHInstance() nInstance
Parameters
None.
Returns
nInstance application instance. If the function fails, the return value is set to zero.
See also
WIN_GetHInstance() .
Syntax
SYS_GetLocalTime() szTime
Parameters
None.
Returns
szTime local time.
Example
? SYS_GetLocalTime() && "1997-11-16-0-23-41-59-880".
Syntax
SYS_GetNumDrives() nDrives
Parameters
None.
Returns
nDrives number of logical drives attached to the system.
Parameters
nStdHandle the standard handle (standard input, standard output, standard error):
STD_INPUT_HANDLE -10
STD_OUTPUT_HANDLE -11
STD_ERROR_HANDLE -12
Returns
nHandle .T. handle if the function is successful; .F. if not. The handle can be used in subsequent calls
to FIL_Write() provided that FOCUS.FLL operates internally in the Win32 API mode instead
of the Fox mode (use FIL_SetOpenStrategy( 1 ) to set FOCUS.FLL in that mode).
Example
LOCAL nStdOutput
LOCAL nOldStrategy
ENDIF
ENDIF
Syntax
SYS_GetSysColor( nIndex ) nColor
Parameters
nIndex display element whose color is to be retrieved. This parameter must be one of the following
values:
Returns
nColor color of the display element.
Remark
System metrics are the dimensions (widths and heights) of Windows display elements. All dimensions retrieved by
SYS_GetSystemMetrics() are in pixels.
Syntax
SYS_GetSystemMetrics( nIndex ) nValue
Parameters
nIndex specifies the system metric or configuration setting to retrieve. All SM_CX* values are widths.
All SM_CY* values are heights. The following values are defined:
Returns
nValue If the function succeeds, the return value is the requested system metric or configuration
setting. If the function fails, the return value is zero.
Syntax
SYS_GetThreadLocale() nLocale
Parameters
None.
Returns
nLocale calling thread's 32-bit LCID locale identifier.
Example
? SYS_GetThreadLocale()
Syntax
SYS_GetTickCount() nMilliSeconds
Parameters
None.
Returns
nMilliSeconds number of milliseconds since Windows has started.
Example
? SYS_GetTickCount()
*-- You can also use SYS_GetTickCount() to form
*-- arbitrary names and numbers
Syntax
SYS_GetTimeZoneInformation( nInfo ) xInfo
Parameters
nInfo type of desired information. Can be one of the following values :
Bias
Specifies the current bias, in minutes, for local time translation on this computer. The bias is the
difference, in minutes, between Coordinated Universal Time (UTC) and local time.
StandardName
Specifies a null-terminated string associated with standard time on this operating system. For
example, this parameter could contain "W" to indicate Western Standard Time. This string can
be empty.
StandardDate
This member is a structure (SYSTEMTIME ). That's the reason why it isn't yet supported
because that would oblige us to pass a second parameter to inform FOCUS what member of this
structure should be returned.
This structure contains a date and UTC when the transition from daylight time to standard time
occurs on the operating system.
Local time translations done during the standard-time range are relative to the StandardBias
value.
StandardBias
Specifies a bias value to be used during local time translations that occur during standard time.
This value is added to the value of the Bias member to form the bias used during standard
time. In most time zones, the value of this member is zero.
DaylightName
Specifies a null-terminated string associated with daylight time on this operating system. For
example, this parameter could contain "PDT" to indicate Pacific Daylight Time. This string can be
empty.
Local time translations during the daylight-time range are relative to the supplied
DaylightBias value. This member supports the absolute and day-in-month time formats of
the StandardDate member.
DaylightBias
Specifies a bias value to be used during local time translations that occur during daylight time.
This value is added to the value of the Bias member to form the bias used during daylight
time. In most time zones, the value of this member is -60.
Returns
xInfo see the above table to have an idea of the result of the function.
Examples
? SYS_GetTimeZoneInformation(1) && -60
? SYS_GetTimeZoneInformation(2) && "W"
? SYS_GetTimeZoneInformation(3) && "Standard Date is not yet supported"
? SYS_GetTimeZoneInformation(4) && 0
? SYS_GetTimeZoneInformation(5) && "W"
? SYS_GetTimeZoneInformation(6) && "Daylight Date is not yet supported"
? SYS_GetTimeZoneInformation(7) && -60
? SYS_GetTimeZoneInformation(8) && "Don't know what you want"
Syntax
SYS_GetTmpPath() szPath
Parameters
None.
Returns
szPath temporary path.
Example
? SYS_GetTmpPath() && "C:\WINDOWS\TEMP\"
Alias
GlobalMemoryStatus(), MemoryStatus()
Parameters
nSetting type of requested information.
Returns
nMemory amount of memory.
Syntax
SYS_HideCaret( [nHwnd] ) lSuccess
Parameters
nHwnd optional window handle. If not passed, the main FoxPro window is used.
Returns
lSuccess .T. is the function is successful; .F. otherwise.
See also
SYS_ShowCaret() .
Syntax
SYS_inp( nPort ) nValue
Returns
nValue the value that is retrieved from the nPort port.
See also
SYS_outp() .
Example
? BITAND( SYS_inp( 0x379 ),16 ) == 16 && Pin 13 of LPT1 is set
Syntax
SYS_iscd( szDrive ) lCDROM
Parameters
szDrive root directory of drive to test.
Returns
lCDROM .T. if drive is a CD-ROM; .F. if not.
Example
IF ( SYS_iscd( "E:\" ) )
? "E is a CD-ROM."
ENDIF
See also
SYS_isremo() , SYS_isfixe() , SYS_isflop() , SYS_isram()
Syntax
SYS_IsCompressed( szRootDir ) lCompressed
Parameters
szRootDir root directory of drive to obtain information from.
Syntax
SYS_isDMA() lStatus
Parameters
None.
Returns
lStatus ????????.
Syntax
SYS_IsDriveReady( szRootDir ) lReady
Parameters
szRootDir root directory of drive to obtain information from.
If this parameter is a UNC name, you must follow it with a trailing backslash. For example, you
would specify \\MyServer\MyShare as \\MyServer\MyShare\ . However, a drive
specification such as "C:" cannot have a trailing backslash.
Windows 95: The initial release of Windows 95 did not support UNC paths for the szRootDir
parameter. To query the free disk space using a UNC path, temporarily map the UNC path to a
drive letter, query the free disk space on the drive, then remove the temporary mapping.
Windows 95 OSR2 and later: UNC paths are supported.
Returns
lReady .T. if drive is ready; .F. otherwise.
Example
DO WHILE ( .T. )
WAIT WINDOW "Please insert a formatted floppy in drive A: and press Enter"
IF ( SYS_IsDriveReady( "A:" ) )
EXIT
ENDIF
ENDDO
Alias
IsFileCaseSensitive()
Syntax
SYS_IsFileCaseSensitive( szRootDir ) lCaseSensitive
Parameters
szRootDir root directory of drive to obtain information from.
Returns
lCaseSensitive .T. if system makes a difference between upper and lower case filenames; .F. otherwise.
Example
LOCAL lCaseSensitive
lCaseSensitive = SYS_IsFileCaseSensitive()
IF ( SYS_LastError() != 0 )
? "FOCUS was not able to access root directory"
ELSE
? IIF( lCaseSensitive , ;
"Case Sensitive File System" , ;
"File system is not case sensitive" ;
)
ENDIF
Syntax
SYS_IsFileCasePreserved( szRootDir ) lCasePreserved
Parameters
szRootDir root directory of drive to obtain information from.
Returns
lCasePreserved .T. if system makes preserves filename case; .F. otherwise.
Syntax
SYS_isfixe( szDrive ) lFixed
Parameters
szDrive root directory of drive to test.
Returns
lFixed .T. if drive is a fixed disk; .F. if not.
Example
IF ( ! SYS_isfixe( SYS_curdri() + ":\" ) )
? "This program requires a fixed disk"
ENDIF
See also
SYS_iscd() , SYS_isremo() , SYS_isflop() , SYS_isram()
Syntax
SYS_IsFlop( szDrive ) lFloppy
Parameters
szDrive root directory of drive to test.
Returns
lFloppy .T. if disk can be removed from drive; .F. if not.
Example
IF ( SYS_IsFlop( "A:\" ) )
? "A is a floppy."
ENDIF
See also
SYS_IsCD() , SYS_isremo() , SYS_isfixe() , SYS_isram()
Alias
IsGame()
Syntax
SYS_IsGame() lPresent
Parameters
None.
Returns
lPresent .T. if a game adapter is found; .F. if not.
Parameters
szWin32Module name of a Win32 DLL or executable module. If the filename extension is omitted, the default
library extension .DLL is appended. The filename string can include a trailing point character (.)
to indicate that the module name has no extension. The string does not have to specify a path.
The name is compared (case independently) to the names of modules currently mapped into
the address space of the calling process.
Returns
lLoaded .T. if szWin32Module is loaded; .F. if not.
See also
SYS_ModuleHandle()
Alias
IsMath()
Syntax
SYS_IsMath() lPresent
Returns
lPresent .T. if a math coprocessor is found; .F. if not.
Alias
IsModem()
Syntax
SYS_IsModem() lPresent
Parameters
None.
Returns
lPresent .T. if a modem is found; .F. if not.
Alias
IsMutex()
Syntax
SYS_IsMutex( cMutex ) lExist
Parameters
cMutex string indicating the mutex name.
Returns
lExist .T. if the given mutex exists; .F. if not.
Example
&& This example checks whether a given mutex already exists;
&& if it exists, it measn that this application is in memory,
&& and consequently, already unloads
IF ( ! SYS_isMutex( "UniqueMutex" ) )
SYS_CreateMutex( "UniqueMutex" )
ELSE
QUIT
ENDIF
Syntax
SYS_isNT() lNT
Parameters
None.
Returns
lNT .T. if the application currently runs under Windows NT; .F. if not.
Example
LOCAL nMajor
LOCAL nMinor
LOCAL nBuild
nMajor = SYS_os(1)
nMinor = SYS_os(2)
nBuild = SYS_os(3)
IF ( SYS_isNT() )
DO CASE
CASE nMajor == 4 .AND nMinor == 0
? "Windows NT 4.0, Build",nBuild
CASE nMajor == 5 .AND nMinor == 0
? "Windows 2000, Build",nBuild
ENDCASE
ELSE
? "This application requires Windows NT."
ENDIF
Parameters
None.
Returns
lPenMachine .T. if machine is pen prepared; .F. otherwise.
Parameters
szDrive root directory of drive to test.
Returns
lRAMDisk .T. if drive is a RAM disk; .F. if not.
Example
IF ( SYS_isram( "F:\" ) )
? "You are copying on a volatile disk"
ENDIF
See also
SYS_iscd() , SYS_isremo() , SYS_isfixe() , SYS_isflop()
Syntax
SYS_isremo( szDrive ) lRemote
Parameters
szDrive root directory of drive to test.
Returns
lRemote .T. if drive is a remote drive; .F. if not. A remote drive is often a network drive.
Example
IF ( SYS_isremo( "J:\" ) )
? "J is a network drive."
ENDIF
See also
SYS_iscd() , SYS_isfixe() , SYS_isflop() , SYS_isram()
Parameters
szDrive root directory of drive to test.
Parameters
None.
Returns
nMilliSeconds number of milliseconds since Windows has started.
Example
? SYS_GetTickCount()
*-- You can also use SYS_GetTickCount() to form
*-- arbitrary names and numbers
Parameters
nJoy identifier of the joystick to be queried.
Returns
lSuccess .T. if successful; .F. if not.
Parameters
None.
Returns
nJoys number of joysticks.
Comment
SYS_Processes() and SYS_ProcessesId() are closely linked to each other in the sense that
SYS_ProcessesId() returns a string of process ids instead of a list of process names.
You can extract one of the process IDs in order to pass it to SYS_KillProcess() which is about to terminate the
task.
Syntax
SYS_KillProcesses( nID ) lSuccess
Parameters
nID process ID.
Returns
lSuccess .T. if the operation is successful; .F. if not.
Example
&& In this example, you can clearly see that we successively call
&& SYS_Processes() and SYS_ProcessesId(). These two function will
&& return the list of all the active tasks running on the system -
&& first the names, then the IDs.
&& In this example, WINWORD.EXE is loaded with the -93131 ID.
&& Finally, we can terminate WINWORD with a call to SYS_KillProcess() :
? SYS_Processes()
&& KERNEL32.DLL(32-bit)^MSGSRV32(16-bit)^MPREXE.EXE(32-bit)^VSHWIN32.EXE(32-
&& bit)^MMTASK(16-bit)^EXPLORER.EXE(32-bit)^POINTEXE(16-bit)^SYSTRAY.EXE(32-
&& bit)^SAGE.EXE(32-bit)^INTERNAT.EXE(32-bit)^FINDFAST.EXE(32-bit)^SPOOL32.EXE(32-
&& bit)^WINWORD.EXE(32-bit)^WINOLDAP(16-bit)^VFP.EXE(32-bit)
? SYS_ProcessesId()
&& -3178599^-47519^-18475^-31943^
&& -29199^-120175^-130915^-101511^
&& -106339^-108707^-82779^-86339^
&& -93131^-186587^-190975
? SYS_KillProcess( -93131 )
See also
SYS_Processes() , SYS_ProcessesId()
Syntax
SYS_LastError() nLastError
Returns
nLastError 1 if the last system operation raised an error; 0 otherwise.
Example
LOCAL lCaseSensitive
lCaseSensitive = SYS_IsFileCaseSensitive()
IF ( SYS_LastError() != 0 )
? "FOCUS was not able to access root directory"
ELSE
? IIF( lCaseSensitive , ;
"Case Sensitive File System" , ;
"File system is not case sensitive" ;
)
ENDIF
Syntax
SYS_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\SYS.C-Mon Oct 19 15:55:22 1998" .
Syntax
SYS_LoadLibrary( szDLL ) nInstanceHandle
Parameters
szDLL name of the DLL that must be loaded.
Example
LOCAL nInst
IF ( nInst != -1 )
? "MQSeries server is installed"
ELSE
nInst = SYS_LoadLibrary( "MQIC32.DLL" )
IF ( nInst != -1 )
? "MQSeries client is installed"
ELSE
? "MQSeries is not installed"
ENDIF
ENDIF
IF ( nInst != -1 )
SYS_FreeLibrary( nInst )
ENDIF
Syntax
SYS_LookupDomain( szUser ) szDomain
Parameters
cUser user name.
Returns
szDomain domain on which the given user is known. This function, although returning an empty string
(which is what can be expected), is useless with Win95, because there is no notion of a domain
with Win95.
Parameters
nDrive drive number (1=A,2=B, etc.)
Returns
szDrive drive letter.
Syntax
SYS_MaxApplAddress() nAddress
Parameters
None.
Returns
nAddress highest memory address accessible to applications and dynamic-link libraries (DLLs).
Syntax
SYS_MaxFileLength( szRootDir ) nLength
Parameters
szRootDir root directory of drive to obtain information from.
Returns
nLength maximum filename length or -1 if function was unsuccessful.
Example
? SYS_MaxFileLength( "C:\" ) && 255
Syntax
SYS_MediaType( szDrive ) nMediaType
Parameters
szDrive drive in which the media to be tested has been placed.
Syntax
SYS_MinApplAddress() nAddress
Parameters
None.
Returns
nAddress lowest memory address accessible to applications and dynamic-link libraries (DLLs).
Comment
The user cannot drag the windows frame to a size smaller than this dimension.
Syntax
SYS_MinimumDragHeight() nPixels
Parameters
None.
Returns
nPixels number of pixels.
Syntax
SYS_MinimumDragWidth() nPixels
Parameters
None.
Returns
nPixels number of pixels.
Syntax
SYS_ModuleHandle( szWin32Module ) nModule
Internal Call
GetModuleHandle()
Parameters
szWin32Module name of a Win32 DLL or executable module. If the filename extension is omitted, the default
library extension .DLL is appended. The filename string can include a trailing point character (.)
to indicate that the module name has no extension. The string does not have to specify a path.
The name is compared (case independently) to the names of modules currently mapped into
the address space of the calling process.
Returns
nModule if the function succeeds, the return value is a handle to the specified module. If the function
fails, the return value is -1.
Special
The SYS_ModuleHandle() function returns a module handle for the specified module if the file has been mapped
into the address space of the calling process.
There is no guarantee that the module handle remains valid between the time this function returns the handle and the
time it is used by another function. For example, a thread might retrieve a module handle by calling
SYS_ModuleHandle() . Before the thread uses the handle in another function, a second thread could free the
module and the system could load another module, giving it the same handle as the module that was recently freed.
The first thread would then be left with a module handle that refers to a module different than the one intended.
See also
SYS_ModuleName() , SYS_IsLoaded()
Syntax
SYS_ModuleName( nModule ) szFileName
Internal Call
GetModuleFileName()
Parameters
nModule identifies the module whose executable filename is being requested.
Returns
szFileName filled in with the path and filename of the given module.
Example
* This example will request the module number of the
* FOCUS library loaded in the address space of the
* current process. Thereafter, the SYS_ModuleName()
* will retrieve the full path and filename
* This second example will simply retrieve the full path and
* filename of the current process. This technique can
* successfully be applied to find out the executable file name
? SYS_ModuleName( SYS_ModuleHandle( "" ) )
See also
SYS_ModuleHandle()
Parameters
None.
Example
* This could be used in an About dialog box
? "Mouse driver : ",SYS_mouse()
Parameters
None.
Returns
szNetworkDrv network driver used by the system.
Example
* This could be used in an About dialog box
? "Network driver : ",SYS_networ()
Parameters
None.
Returns
nFloppies number of floppy disks installed.
Syntax
SYS_numprn() nPrns
Parameters
None.
Returns
nPrns number of printers installed.
Parameters
nSetting identifies the type of information the SYS_os() function must return.
Returns
xInfo when called, the SYS_os() function places OS information into a C structure. This information
includes major and minor version numbers, a build number, a platform identifier, and possibly
some descriptive text.
Example
IF ( SYS_os(1) == 4 .AND. SYS_os(2) == 0 .AND. ! SYS_IsNT() )
? "You are running under Windows 95"
ENDIF
szAdditional = SYS_os(5)
IF ( ! EMPTY( szAdditional ) )
? "Additional infor: " + szAdditional
ENDIF
Parameters
None.
Returns
szErrorString a string about the last operation.
Syntax
SYS_outp( nPort,szValue|nValue ) .T.
Parameters
nPort the port number.
szValue|nValue numeric or character string (only the first char will be taken into account).
Returns
.T. the function always returns .T. .
See also
SYS_inp() .
Syntax
SYS_P3Serial() szSerial
Parameters
None.
Returns
szSerial Pentium III serial number or an empty string ( "") if the serial number cannot be determined
(use SYS_LastError() to obtain the details of the failure).
Parameters
None.
Returns
Please notice that SYS_Processes() operates differently under Windows 9x and NT. In Windows 9x, the
function uses the ToolHelp32 functions that reside in the kernel32.dll whereas with NT it uses the
psapi.dll. This DLL isn't always distributed with Windows.
You can use the DLL Help Database of Microsoft. The DLL Help exists to assist developers, system administrators, and other
IT professionals who face file version conflicts with Microsoft software. Use DLL Help to identify which software installed a
specific version of a DLL (http://support.microsoft.com/servicedesks/fileversion/dllinfo.asp?sd=MSDN).
16-bit processes:
In Windows 9x, 32-bit processes and 16-bit processes are equal citizens … as far as ToolHelp32 is concerned. This is
far from being the case under Windows NT. Therefore, 16-bit processes aren't enumerated under Windows NT which
makes the nAppType parameter of the function useless: the parameter is simply ignored.
Alias
EnumProcesses()
Syntax
SYS_Processes( nAppTypes ) szList
Parameters
nAppTypes optional parameter: 0 by default. Can be 16 if you want to list 16-bit applications, or 32 for 32-
bit applications. This parameter is completely ignored when the function operates on the
Windows NT platform.
Returns
szList list of all active tasks running on the system. Each task is separated by each other by a caret
(^) like in this example :
"KERNEL32.DLL(32-bit)^MSGSRV32(16-bit)^MPREXE.EXE(32-bit)^VSHWIN32.EXE(32-
bit)^MMTASK(16-bit)^EXPLORER.EXE(32-bit)^POINTEXE(16-bit)^SYSTRAY.EXE(32-
bit)^SAGE.EXE(32-bit)^INTERNAT.EXE(32-bit)^FINDFAST.EXE(32-bit)^SPOOL32.EXE(32-
bit)^INFOVIEW.EXE(32-bit)^MSVC.EXE(32-bit)^WINOLDAP(16-bit)^VFP.EXE(32-
bit)^CTCD(16-bit)^WINWORD.EXE(32-bit)"
When no parameter has been passed to the function, or when this parameter was 0, then each
process is clearly shown as a 32-bit or 16-bit process when run under Windows 9x. When run in
NT, the function does not add any process information (16-bit or 32-bit).
Example
? SYS_Processes() under Windows 95 or Windows 98 (Windows 9x)
&& KERNEL32.DLL(32-bit)^MSGSRV32(16-bit)^MPREXE.EXE(32-bit)^VSHWIN32.EXE(32-
&& bit)^MMTASK(16-bit)^EXPLORER.EXE(32-bit)^POINTEXE(16-bit)^SYSTRAY.EXE(32-
&& bit)^SAGE.EXE(32-bit)^INTERNAT.EXE(32-bit)^FINDFAST.EXE(32-bit)^SPOOL32.EXE(32-
&& bit)^INFOVIEW.EXE(32-bit)^MSVC.EXE(32-bit)^WINOLDAP(16-bit)^VFP.EXE(32-
&& bit)^CTCD(16-bit)^WINWORD.EXE(32-bit)
See also
SYS_tasks(), SYS_EnumDeviceDrivers()
Comment
SYS_Processes() and SYS_ProcessesId() are closely linked to each other in the sense that
SYS_ProcessesId() returns a string of process ids instead of a list of process names.
You can extract one of the process IDs in order to pass it to SYS_KillProcess() which is about to terminate the
task.
Please notice that SYS_ProcessesId() does not work under Windows NT.
Syntax
SYS_ProcessesId() szList
Parameters
None.
Returns
szList list (IDs) of all active tasks running on the system. Each task is separated by each other by a
caret (^).
Example
&& In this example, you can clearly see that we successively call
&& SYS_Processes() and SYS_ProcessesId(). These two function will
&& return the list of all the active tasks running on the system -
&& first the names, then the IDs.
&& In this example, WINWORD.EXE is loaded with the -93131 ID.
&& Finally, we can terminate WINWORD with a call to SYS_KillProcess() :
? SYS_Processes()
&& KERNEL32.DLL(32-bit)^MSGSRV32(16-bit)^MPREXE.EXE(32-bit)^VSHWIN32.EXE(32-
&& bit)^MMTASK(16-bit)^EXPLORER.EXE(32-bit)^POINTEXE(16-bit)^SYSTRAY.EXE(32-
&& bit)^SAGE.EXE(32-bit)^INTERNAT.EXE(32-bit)^FINDFAST.EXE(32-bit)^SPOOL32.EXE(32-
&& bit)^WINWORD.EXE(32-bit)^WINOLDAP(16-bit)^VFP.EXE(32-bit)
? SYS_ProcessesId()
&& -3178599^-47519^-18475^-31943^
&& -29199^-120175^-130915^-101511^
&& -106339^-108707^-82779^-86339^
&& -93131^-186587^-190975
? SYS_KillProcess( -93131 )
See also
SYS_Processes() , SYS_KillProcess()
Parameters
None.
Returns
szArchitecture specifies the system's processor architecture. This value can be one of the following values:
Value Description
Intel PROCESSOR_ARCHITECTURE_INTEL
Mips PROCESSOR_ARCHITECTURE_MIPS
Alpha PROCESSOR_ARCHITECTURE_ALPHA
PowerPC PROCESSOR_ARCHITECTURE_PPC
Unknown PROCESSOR_ARCHITECTURE_UNKNOWN
Parameters
None.
Returns
nMask set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31.
Syntax
SYS_RealExecutableName() szName
Parameters
None.
Returns
szName Name of the running executable name.
Example
? SYS_RealExecutableName() && "D:\PROGRAM FILES\DEVSTUDIO\VFP\VFP.EXE"
Alias
RemoteShutdown()
Syntax
SYS_RemoteShutdown( szComputer[,szMsg[,nTimeout[,lForce[,lReboot]]]]) lAccepted
Parameters
szComputer Network name of the computer to shut down.
nTimeout Specifies the time (in seconds) that the shutdown dialog box should be displayed.
lForce Specifies whether applications with unsaved changes are to be forcibly closed. If this parameter
is TRUE, such applications are closed. If this parameter is FALSE, a dialog box is displayed
prompting the user to close the applications.
lReboot Specifies whether the computer is to restart immediately after shutting down. If this parameter
is TRUE, the computer is to restart. If this parameter is FALSE, the system flushes all caches to
disk, clears the screen, and displays a message indicating that it is safe to power down.
Returns
lAccepted .T. if the function is successful; .F. otherwise.
Example
? SYS_RemoteShutdown( "ORION","System shutdown in 60 seconds",60 )
Alias
SectorsPerCluster() .
Syntax
SYS_secclu( szDrive ) nSectors
Parameters
szDrive drive letter from which to obtain the number of sectors per cluster.
Example
LOCAL nClusters
LOCAL nSectors
LOCAL nBytes
LOCAL szDrive
See also
SYS_totclu(), SYS_avaclu()
Alias
SendMessage() .
Syntax
SYS_SendMessage( nHwnd,nMsg,nParam1,nParam2 ) nResult
Parameters
nHwnd window handle to which the message should be sent. If the same message has to be sent to
multiple windows, use the HWND_BROADCAST ( (HWND) 0xffff ) value.
nMsg message to send. Basically, all messages provided by Windows are supported by FOCUS.
Unfortunately, the list of such messages is so long that it could hardly fit in this documentation.
Report yourself to WM_* messages of the Win32 API. Here's a very short (very, very short) of
messages that can be used to send keystrokes to a window:
Returns
nResult the return value specifies the result of the message processing and depends on the message
sent.
See also
SYS_PostMessage(), SYS_PostThreadMessage()
Syntax
SYS_SetCaretBlinkTime( nMilliSeconds ) lSuccess
Parameters
nMilliSeconds specifies the new blink time, in milliseconds
Returns
lSuccess .T. if function was successful; .F. otherwise.
Example
? SYS_SetCaretBlinkTime( 200 )
See also
SYS_GetCaretBlinkTime()
Syntax
SYS_SetCaretPos( x,y ) lSuccess
Parameters
x horizontal position.
y vertical position.
See also
SYS_GetCaretPosX() , SYS_SetCaretPos()
Parameters
szTitle title of the console window.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
&& If we can allocate a new console
IF ( SYS_AllocConsole( "FOCUS Debugging Window" ) != 0 )
? SYS_GetConsoleTitle() && Should be "FOCUS Debugging Window"
SYS_SetConsoleTitle( "My new debugging window" )
ENDIF
Parameters
szDrive drive letter to test. It can be a full path with a drive specifier because the function will only pay
attention to the leftmost character.
Returns
.T. the function always returns a logical .T. . If you want to test the function result, you should
issue a SYS_curdri() call. If the drive you attempted to log onto and the current drive are
the same, it means that the call to SYS_setdri() was successful.
Example
SYS_setdri( "A" )
IF ( LEFT( SYS_curdri(),1 ) != "A" )
? "Attempt to log onto drive A failed"
ENDIF
szValue the value of the specified environment variable. new value of the specified environment
variable. If this parameter is .NULL. , the variable is deleted from the current process’s
environment.
Returns
lSuccess .T. if the environment variable has been successfully added or set to the current process. .F.
if not.
Example
IF ( SYS_SetEnvironmentVariable( "Hello World","This is Hello" ) )
? SYS_GetEnvironmentVariable( "Hello World" ) && "This is Hello"
? GETENV( "Hello World" ) && ""
IF ( SYS_SetEnvironmentVariable( "Hello World",.NULL. ) )
? "The environment variable has been eliminated"
ENDIF
ENDIF
See also
SYS_GetEnvironmentVariable() .
Syntax
SYS_SetErrorMode( nMode ) nPrevious
Parameters
nMode can be one of the following modes:
Syntax
SYS_SetFileAPIsToANSI() .T.
Parameters
None.
Returns
.T. the function always returns .T. .
See also
SYS_SetFileAPIsToOEM() .
Syntax
SYS_SetFileAPIsToOEM() .T.
Parameters
None.
Returns
.T. the function always returns .T. .
See also
SYS_SetFileAPIsToANSI() .
Parameters
nYear hour.
nMonth month.
nDay day.
nHour hour.
nMinute minute.
nSecond second.
nMilli milliseconds.
Returns
lSuccess .T. if the function is successful; .F. otherwise.
Syntax
SYS_setvol( szRootDir,szVolume ) lSuccess
Parameters
szRootDir root directory of drive to change volume label.
Returns
lSuccess .T. if function was successful; .F. otherwise.
Example
IF ( SYS_SetVolumeLabel( "C:\","PAT_C_586" ) )
? "Volume has been successfully changed to " + ;
SYS_volume( "C:\",1 ) && "PAT_C_586"
ENDIF
Caution
Do not use volume labels larger than 11 characters, because that generates General Protection Faults.
Syntax
SYS_ShellAbout( cTitle,szAdditional ) .T.
szAdditional text displayed in the dialog box after the version and copyright information.
Returns
.T. the function always returns .T..
Example
? SYS_ShellAbout( "VFP Word Magician","Author : Pat Y. Boens" )
Alias
ShellExecute() .
Syntax
SYS_ShellExecute( szOperation,szFile,szParameters,szDir,nMode ) nError
Parameters
nHwnd window handle that will own the execution (in SYS_ShellExecute() , this parameter is
always assumed to be the main FoxPro window, which can cause some trouble if used with top-
level forms).
szFile file to open, to explore or to print. Please note that can open an executable file or a document
file. Shortcuts can also be mentioned.
Returns
nError if the function succeeds, the return value is the instance handle of the application that was run,
or the handle of a DDE server application.
If the function fails, the return value is then less than or equal to 32.
Example
? SYS_ShellExecute( "explore","C:\MY DOCUMENTS","","",5 )
? SYS_ShellExecute( "open" ,"C:\WINDOWS\DESKTOP\Power Management.doc","","",3 )
? SYS_ShellExecute( "explore","DESKTOP","","",5 )
See also
SYS_WinExec() , FIL_Explore()
Parameters
SYS_ShellExecuteEx( nHwnd,szOperation,szFile,szParameters,szDir,nMode ) nError
Parameters
nHwnd window handle that will own the execution (in SYS_ShellExecute() , this parameter is
always assumed to be the main FoxPro window, which can cause some trouble if used with top-
level forms).
Returns
nError if the function succeeds, the return value is the instance handle of the application that was run,
or the handle of a DDE server application.
If the function fails, the return value is then less than or equal to 32.
See also
SYS_WinExec() , FIL_Explore() , SYS_ShellExecuteEx() ,
Syntax
SYS_ShowCaret( [nHwnd] ) lSuccess
Returns
lSuccess .T.. if the function is successful; .F. otherwise.
See also
SYS_HideCaret() .
Syntax
SYS_sleep( nMilliSeconds ) .T.
Parameters
nMilliSeconds sleep time in milliseconds
Returns
.T. the function always returns .T..
Example
Try both examples to notice the difference:
Syntax
SYS_SplitTime( @nYear,@nMonth,@nDay,@nHour,@nMinute,@nSecond,@nMilli ) .T.
Parameters
nYear year. Must be passed by reference.
Returns
.T. the function always returns .T..
Example
LOCAL nYear,nMonth ,nDay,
LOCAL nHour,nMinute,nSecond,nMilli
nYear = 0
nMonth = 0
nDay = 0
nHour = 0
nMinute = 0
nSecond = 0
nMilli = 0
SYS_SplitTime( @nYear,@nMonth,@nDay,@nHour,@nMinute,@nSecond,@nMilli )
Syntax
SYS_StartService( szMachine,szService ) lSuccess
Parameters
szMachine the machine on which szService must be started. If this parameter is .NULL., the local
machine is used.
Returns
lSuccess .T. if the function was successful; .F. otherwise. Use The SYS_GetlastError() function to
know why the function has failed.
Example
LOCAL szAction,szServiceName
m.szAction = "START"
m.szServiceName = "My Web Server"
IF ( m.szAction == "START" )
&& Start the service now
IF ( SYS_StartService( .NULL.,m.szServiceName ) )
? "The service was started successfully"
ELSE
See also
SYS_StopService()
Syntax
SYS_StopService( szMachine,szService ) lSuccess
Parameters
szMachine the machine on which szService must be stopped. If this parameter is .NULL., the local
machine is used.
Returns
lSuccess .T. if the function was successful; .F. otherwise. Use The SYS_GetlastError() function to
know why the function has failed.
Example
LOCAL szAction,szServiceName
m.szAction = "STOP"
m.szServiceName = "My Web Server"
IF ( m.szAction == "START" )
&& Start the service now
IF ( SYS_StartService( .NULL.,m.szServiceName ) )
? "The service was started successfully"
ELSE
? "The service could not be started", SYS_GetLastError()
ENDIF
ELSE
&& Stop the service now
IF ( SYS_StopService( .NULL.,m.szServiceName ) )
? "The service was stopped successfully"
ELSE
? "The service could not be stopped", SYS_GetLastError()
ENDIF
ENDIF
See also
SYS_StartService()
Parameters
None.
Returns
szSwapFile swap file used by the system.
Example
* This could be used in an About dialog box
? "Swap file : ",SYS_swap()
Syntax
SYS_sysdir() szWinSysDir
Parameters
None.
Returns
szWinSysDir path of the Windows startup directory. The pathname does not end with a backslash ( \), unless
the Windows system directory is in the root directory. The Windows System directory generally
contains the Windows libraries, drivers, font files, etc.
Example
? "Windows system directory : " + SYS_sysdir()
The SYS_tasks() function of FOCUS does differ from SYS_Processes() in the sense that it lists all applications
based on their window title whereas SYS_Processes() maps the loaded tasks into their EXE name.
Alias
Tasks()
Syntax
SYS_tasks( lTakeCurrent,lTakeInvisible) szList
Returns
szList list of all active tasks running on the system. Each task is separated by each other by a caret
like in this example:
Example
&& Assuming that the current window title is ...
&& Datasoft - Medical Manager
LOCAL szCurrentTitle
LOCAL szTasks
IF ( AT( szCurrentTitle,szTasks ) != 0 )
WAIT WINDOW "Current application already in memory." + ;
CHR(13) + "Quit immediately!"
ENDIF
See also
SYS_Processes()
Syntax
SYS_totclu( szDrive ) nClusters
Parameters
szDrive drive letter form which to obtain the number of bytes per sector.
Returns
nClusters number of clusters on disk.
See also
SYS_avaclu()
Parameters
None.
Returns
nVideo initial video mode.
Value Meaning
0 Reserved
1 40 x 25 color
2 80 x 25 color
3 80 x 25 monochrome
Syntax
SYS_volume( szRootDir,nSetting ) xInfo
Parameters
szRootDir root directory of drive to obtain information from.
Value Description
1 Volume name
2 Volume serial number
3 Maximum component length
(maximum filename length)
4 File system flags
5 File system name
Returns
xInfo requested information or .F. if function was unsuccessful.
Example
? SYS_volume( "C:\",1 ) && "PAT_C_586"
? SYS_volume( "C:\",2 ) && 123456789
? SYS_volume( "C:\",3 ) && 255
? SYS_volume( "C:\",4 ) && 457812
? SYS_volume( "C:\",5 ) && "FAT"
Syntax
SYS_VolumeName( szRootDir ) szVolumeName
Parameters
szRootDir root directory of drive to obtain information from.
Returns
szVolumeName volume name or empty string if function was unsuccessful.
Example
? SYS_VolumeName( "C:\" ) && "PAT_C_586"
Syntax
SYS_VolumeSerial( szRootDir ) nSerial
Parameters
szRootDir root directory of drive to obtain information from.
Returns
nSerial volume serial number or -1 if function was unsuccessful.
Example
? SYS_VolumeSerial( "C:\" ) && 47589456
Syntax
SYS_winBuil() nBuildNumber
Parameters
None.
Example
* Under NT 4.0 for example
? "OS Build Number : " + LTRIM(STR(SYS_winBuild())) && "OS Build Number : 1381"
Syntax
SYS_windir() szDir
Parameters
None.
Returns
szDir path of the Windows startup directory. The pathname does not end with a backslash (\), unless
the Windows directory is in the root directory.
Example
? "Windows directory : " + SYS_windir()
Syntax
SYS_WinExec( szApplication[,nMode] ) lSuccess
Parameters
szApplication command line.
Returns
lSuccess .T. if application loaded successfully; .F. otherwise.
Example
&& Try to load MS-Word
? SYS_WinExec( "C:\MSOFFICE\WINWORD\WINWORD.EXE" )
See also
SYS_ShellExecute()
Syntax
SYS_WinExecEx( szApplication[,nMode] ) nPID
Parameters
szApplication command line.
Returns
nPID Process identifier or 0 if error.
Example
LOCAL nPID
See also
SYS_ShellExecute(), SYS_WinExec()
Syntax
SYS_winmaj() nMajor
Parameters
None.
Returns
nMajor Windows major version number.
Syntax
SYS_winmin() nMinor
Parameters
None.
Returns
nMinor Windows minor version number.
Example
? "Win ver : " + LTRIM( STR( SYS_winmaj() ) ) + "." + ;
LTRIM( STR( SYS_winmin() ) )
Parameters
szString string to be written to current console.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
SYS_FreeConsole() && Free the current console if any
Time Functions
Functions Synopsis
Due to a lack of design when starting FOCUS, timer functions and time functions share the same function prefix :
TIM_*() . We apologize for this mess !
The Windows environment gives the developer a bunch of time oriented functions to work with. With few functions,
FOCUS sets major services at your disposal.
It's a marvelous opportunity for us to tell you that the Windows environment handles dates as times. It basically
means that working with times means working with dates.
In order to maintain the necessary consistency, times and dates are now all handled through their UTC (Universal Time
Coordinated) value. This makes it more convenient to distinguish the last update of a file, certainly when it comes to
compare time stamps of two files that are updated at two different places, Paris and Los Angeles for example.
So we come to this bottom line : dates and times are equivalent (time type, or DateTime type for Visual FoxPro), and
what's more all times are UTC values.
Therefore, we felt obliged to provide a lot of TIME functions whereas FoxPro only provides local time functions.
Please be aware that FOCUS time functions cannot operate on dates before 01-01-1970 !
Notice that all local times are determined by taking into account the daylight saving setting.
? DATE(), TIME()
Focus
nTime = TIM_time()
? TIM_date( nTime ), "Local time :" + TIM_localT( nTime ), ;
"UTC : " + TIM_gmT( nTime )
Parameters
nTime current time with a number form.
Returns
szTime converted time.
Example
LOCAL nCurrentTime
Parameters
nMilliSeconds number of milliseconds to turn into a time string.
Returns
szTimeString converted time.
Example
? TIM_FormatMilli( 3600000 ) && "01:00:00.000"
? TIM_FormatMilli( 24 * 60 * 60 * 1000 ) && "24:00:00.000"
See also
TIM_FormatTimeInterval() .
Parameters
n integer to treat as a time interval in milliseconds.
Example
? TIM_FormatTimeInterval(400) && "0 sec"
? TIM_FormatTimeInterval(4000) && "4 sec"
? TIM_FormatTimeInterval(4400) && "4 sec"
? TIM_FormatTimeInterval(86400) && "1 min 26 sec"
? TIM_FormatTimeInterval(86400000) && "24 hr 0 sec"
? TIM_FormatTimeInterval(86460000) && "24 hr 1 min 0 sec"
See also
TIM_FormatMilli() .
Parameters
dDate1 first date to consider.
Returns
nDays the number of days between dDate1 and dDate2 .
Example
? TIM_GetNumberOfDays( DATE(),{18/11/59} ) && 13872
Parameters
nTime current time with a number form.
Returns
szTime converted time.
Example
LOCAL nCurrentTime
Syntax
TIM_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\FWTIME.C-Mon Oct 19 15:55:22 1998" .
Parameters
nTime current time with a number form.
Returns
szTime converted time.
Example
LOCAL nCurrentTime
Parameters
cTime first date to consider.
Example
? TIM_MakeSeconds( TIME() ) && 64972
Parameters
dDate date to transform to a time value.
Returns
nTime the number of seconds expressed by cTime .
Example
? TIM_MakeTime( DATE(),TIM_MakeSeconds( TIME() ) ) && 879189312
? TIM_time() && Identical !!!
In order for TIM_UserTime() to return an appropriate format, you can should use the TIM_SetFormat() function.
Syntax
TIM_SetFormat( szFormat ) szCurFormat
Parameters
szFormat time format string. By default, the internal setting is set to "%d-%m-%Y at %H:%M:%S" .
Returns
szCurFormat the function returns the previous setting.
Example
LOCAL nTime
Parameters
UCTime universal coordinated time string.
Returns
lSuccess .T. if operation is successful; .F. otherwise.
Example
* This example won't change anything as far as the system time
* is concerned. This is due to the fact that it sets the system
* time at what it was. However, you have the basic principles
* that must be used to control these settings.
LOCAL nUCTime
LOCAL cUCTime
nUCTime = TIM_time()
cUCTime = TIM_gmt( nUCTime )
? TIM_SetSystemTime( cUCTime )
Parameters
nMilliSeconds number of milliseconds to split.
Returns
szTimeString converted time.
Example
LOCAL nHH,nMM,nSS,nm
nHH = 0
nMM = 0
nSS = 0
nm = 0
? nHH && 1
? nMM && 0
? nSS && 0
? nm && 0
Returns
nTicks number of milliseconds elapsed since Windows was started.
Parameters
None.
Returns
nTime current time with a number form.
Example
See TIM_localt(), TIM_gmt(), TIM_ctime().
In order for TIM_UserTime() to return an appropriate format, you can should use the TIM_SetFormat() function.
Syntax
TIM_UserTime( tTime ) szTime
Parameters
tTime a time value like the one returned by TIM_time() .
Returns
szTime resulting string compliant to TIM_SetFormat() setting.
Example
LOCAL nTime
Timer Functions
Functions Synopsis
Timer functions can definitely help you designing procedures that will be interrupted at a regular time interval.
Examples of such timer functions are numerous: alarms, CD front panel update, stopwatch, etc. These functions were
existing in FOCUS.FLL for FoxPro 2.5 already. They are provided for backward compatibility because, with the advent
of Visual FoxPro 3.0, the developer has now native timers at his disposal.
Timers
The use of timers implies 3 basic steps:
1. to tell FOCUS which command to launch at given time interval (TIM_proc() )
Unlike other libraries, with FOCUS.FLL you can customize the command that must be executed at a regular time
interval. This command can be any valid FoxPro statement such as DO MYPROC , @ 10,10 SAY TIME() , etc.
TIM_proc() provides this service to you.
After you told FOCUS.FLL the command to be executed, you should specify the time interval you want to set. For this
purpose, use the TIM_set( TimeInterval ) function. It will return a timer identifier, which you’ll have to use to
kill the given timer when you want to stop it.
When you definitely want to change the timer or if you simply want to stop it, please use the TIM_kill() function
and pass it the timer identifier that was returned by TIM_set() .
Make sure when you quit your FoxPro application to kill the timer otherwise you may hang up the computer.
Limitations
So far, FOCUS accepts to position only 1 timer at a time. For this reason, we call it the global application timer. In the
future, more timers will be available.
Example
Coming up is an example of a routine that sets the global timer to a command whose aim is to display a clock during
GET editing.
Syntax
TIM_kill( tTimer ) .T.
Parameters
tTimer timer identifier. This identifier identifies the timer that must be killed.
Returns
.T. the function always returns a logical .T.
Example
LOCAL tTimer
<more instructions>
TIM_kill( tTimer )
Syntax
TIM_proc( szCommand ) .T.
Parameters
szCommand FoxPro command.
Returns
.T. the function always returns .T. .
Example
LOCAL tTimer
<more instructions>
TIM_kill( tTimer )
Syntax
TIM_set( nMilliSeconds ) tTimer
Parameters
nMilliSeconds time interval in milliseconds.
Returns
tTimer the function returns the timer identifier.
Example
LOCAL tTimer
<more instructions>
TIM_kill( tTimer )
Syntax
TMR_Create( nMilliSeconds,szCommand[,xHighPrecision] ) nHandle
Parameters
nMilliSeconds time interval in milliseconds.
xHighPrecision this parameter is optional. If passed, the function creates a "High Precision" timer; if not
passed, the function creates a "Normal Precision" timer.
Returns
nHandle handle to a timer, or –1 if no timer could be created.
Example
&& This example will create a timer that will display the current time
&& while waiting for a key during 10 seconds.
LOCAL nHandle
TMR_Destroy( nHandle )
Syntax
TMR_Destroys( nHandle ) lSuccess
Parameters
nHandle handle of the timer to destroy.
Returns
lSuccess .T. if the timer was successfully destroyed; .F. if not.
Example
&& This example will create a timer that will display the current time
&& while waiting for a key during 10 seconds.
LOCAL nHandle
INKEY( 10,"HM" )
TMR_Destroy( nHandle )
Parameters
None.
Returns
nHandles maximum umber of timer handles.
Parameters
None.
Parameters
nHandle handle identifying the timer to be queried. Be careful to pass a handle whose value is comprised
between TMR_MinHandle() and TMR_MaxHandle() ; otherwise illegal operations can
appear.
VALUE DESCRIPTION
1 Command associated with the timer. Return type: character string.
2 Internal timer identifier. Return type: numeric.
3 Timer interval. Return type: numeric.
4 Timer precision: 0 for NORMAL_PRECISION, 1 for HIGH_PRECISION. Return type:
numeric.
5 Timer suspended or not; .T. if timer is suspended, .F. if not. Return type:
logical.
Returns
xInfo the info as it is queried, depending on the nType parameter.
nType DESCRIPTION
1 Command associated with the timer. Return type: character string.
2 Internal timer identifier. Return type: numeric.
3 Timer interval. Return type: numeric.
4 Timer precision: 0 for NORMAL_PRECISION, 1 for HIGH_PRECISION. Return type:
numeric.
5 Timer suspended or not; .T. if timer is suspended, .F. if not. Return type:
logical.
Example
LOCAL nHandle
Returns
szError last error string.
Syntax
TMR_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\TIMER.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
nHandle highest potential handle.
Parameters
None.
Returns
nHandle lowest potential handle.
Parameters
nHandle handle identifying the timer to be resumed. Be careful to pass a handle whose value is
comprised between TMR_MinHandle() and TMR_MaxHandle() ; otherwise illegal operations
can appear.
Returns
lSuccess .T. if the timer is successfully resumed; .F. if not.
Example
LOCAL nHandle
IF ( nHandle != -1 )
INKEY( 20,"HM" ) && Let the timer be active for 20 seconds
TMR_Suspend( nHandle ) && Suspend the timer now
INKEY( 10,"HM" ) && Let the timer be suspended for 10 seconds
TMR_Resume( nHandle ) && Resume it now
ENDIF
Parameters
nHandle handle identifying the timer to be suspended. Be careful to pass a handle whose value is
comprised between TMR_MinHandle() and TMR_MaxHandle() ; otherwise illegal operations
can appear.
Returns
lSuccess .T. if the timer is successfully suspended; .F. if not.
Example
LOCAL nHandle
IF ( nHandle != -1 )
INKEY( 20,"HM" ) && Let the timer be active for 20 seconds
TMR_Suspend( nHandle ) && Suspend the timer now
INKEY( 10,"HM" ) && Let the timer be suspended for 10 seconds
TMR_Resume( nHandle ) && Resume it now
ENDIF
Functions Synopsis
Application tracing functions are especially helpful at the debugging stage of an application. It provides easy methods
to set up a new tracing file, to log strings to the tracing log file, and to stop and start tracing the program on the fly.
When mixed with DDA techniques, you easily trace all program activity thanks to TRA_*() functions.
In version 5.17 of FOCUS.FLL , these functions, although totally operational, are in a kind of review process.
Internally, up to now, these functions were using their own code. In the future, they will use the common code of the
LOG_*() functions. So will the DDA_*() functions that report their activity in log files.
In the future you will see more Tracing functions also.
Syntax
TRA_getlog() szTracingLogFile
Parameters
None.
Returns
szTracingLogFile name of the file tracing process is directed to.
Example
TRA_setlog( "" )
? TRA_getlog() && ""
TRA_setlog( "TRACING.LOG" )
? TRA_getlog() && "TRACING.LOG"
Syntax
TRA_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\TRACING.C-Mon Oct 19 15:55:22 1998" .
Parameters
szString string to write to tracing log file
Returns
.T. the function always returns .T.
Syntax
TRA_setlog( szLogFile ) lSuccess
Parameters
szLogFile application tracing file name.
Returns
lSuccess .T. if operation was successful, .F. otherwise.
Example
TRA_setlog( "" )
? TRA_getlog() && ""
TRA_setlog( "TRACING.LOG" )
? TRA_getlog() && "TRACING.LOG"
Version
Functions Synopsis
Application version functions are designed to control features that are somehow related to the version of the
application (author name, application name, application major version number, application minor version number, beta
flag, alpha flag, application INI file, and application date, company name, copyrights, etc.).
The entire information is held in a C structure:
typedef struct {
int VerMajor;
int VerMinor;
TCHAR Revision[11];
int Counter;
BOOL Alpha;
BOOL Beta;
BOOL PreRelease;
BOOL Release;
BOOL ReleaseCandidate;
BOOL FinalRelease;
BOOL Demo;
TCHAR Cargo[VER_BUFFER_SIZE];
TCHAR Author[MAX_PATH];
TCHAR Name[MAX_PATH];
TCHAR Date[21];
TCHAR IniFile[MAX_PATH];
TCHAR Copyrights[MAX_PATH];
TCHAR Company[MAX_PATH];
} FOCUSVersion;
Usually, an application resides in its alpha phase when not all the expected functionalities are implemented. An
application resides in its beta phase when all the functionalities and features are included in the project but should still
be fully tested.
When FOCUS.FLL is used in conjunction with FOCUS.VCX , the Program class parses version information from the
classes themselves and put these values in the corresponding FOCUS.FLL slots. For example, when setting up the
Version.Major property of the Program class, when the program is run, FOCUS.VCX puts the Version.Major
property value in FOCUS.FLL thanks to the VER_major() version. This makes it possible for FOCUS.FLL to gather
information about the applications that are written and that use it. This information is later on stored in FDB files (see
FDB_*() functions).
Parameters
lSetting new alpha setting. Setting this flag affects the beta and PreRelease flags.
Returns
lCurSetting current alpha setting.
Example
VER_alpha( .T. )
? VER_alpha() && .T.
? VER_beta() && .F.
? VER_prerel() && .F.
Parameters
szNewAuthor name of author of the application. Parameter may not exceed 40 characters.
Returns
szCurAuthor current author setting.
Example
VER_author( "Dave Kallander" )
? VER_auhor() && "Dave Kallander"
Parameters
lSetting new beta setting. Setting this flag affects the alpha and PreRelease flags.
Returns
lCurSetting current beta setting.
Example
VER_beta( .T. )
? VER_beta() && .T.
? VER_alpha() && .F.
? VER_prerel() && .F.
Parameters
szNewCargo new string to write to cargo member. Parameter may not exceed 256 characters.
Returns
szCurCargo current string contained in cargo member.
Example
VER_cargo( "This application is a test" )
? VER_cargo() && "This application is a test"
Syntax
VER_cpyrig( [szNewRights] ) szCurRights
Parameters
szNewRights copyrights of application. Parameter may not exceed 40 characters.
Returns
szCurRights current copyrights setting.
Example
VER_cpyrig( "Copyrights 1994 - FastWrite SC" )
? VER_cpyrig() && " Copyrights 1994 - FastWrite SC "
Syntax
VER_counte( [nCounter] ) nCurCounter
Parameters
nCounter the internal application counter.
Returns
nCurCounter current application counter.
Parameters
szCompany the company that created the application.
Returns
szCurCompany current company.
Example
VER_company( "Double Team Co., Ltd." )
Parameters
szDateTime new date and time setting.
Returns
szCurDateTime current date and time setting. Parameter may not exceed 20 characters.
Example
VER_date( "25-04-1994 12:33" )
? VER_date() && "25-04-1994 12:33"
Parameters
lSetting new demo setting. Setting this flag affects all related flags (alpha, beta, release, etc.).
Returns
lCurSetting current demo setting.
Example
VER_demo( .T. )
? VER_demo() && .T.
Parameters
lSetting new Final Release setting. Setting this flag affects all related flags (alpha, beta, release, etc.).
Returns
lCurSetting current Final Release setting.
Example
VER_FinalRelease( .T. )
? VER_FinalRelease() && .T.
? VER_alpha() && .F.
? VER_beta() && .F.
When this function was originally created, Visual FoxPro didn't get any function of that type. With the advent of Visual
FoxPro 6.0, the AGETFILEVERSION() function appeared, which basically can do the same thing although there is no
exact match between FOCUS.FLL and VFP.
Executable files such as .EXE, .DLL, .FLL and others, can contain multiple version information structures. For example,
the copyrights might be stored in French, Dutch English, etc. Each language (I should say "Each language and code
page combination"), the executable can contain a unique versioin information structure.
There is a significant difference between FOCUS.FLL and Visual FoxPro, because FOCUS.FLL makes it easy to extract
any language information where VFP only returns the first information it gets out of the executable.
Because DLLs are not re-entrant you cannot use VER_GetFileVersionInfo() of FOCUS.FLL to determine
version information of FOCUS.FLL itself.
Alias
GetFileVersionInfo() , GetFileVersion() .
Syntax
VER_GetFileVersionInfo( szFile,nSetting[,szLangCP] ) szSetting
Parameters
szFile filename string.
szLangCP combination of Language ID + code page. Optional parameter. If this parameter is not passed,
FOCUS.FLL always retrieves the file version information in the following order:
2. French Belgian
3. French Standard
4. Dutch Belgian
5. Dutch Standard
6. English US
Should you wish to retrieve other file version info for additional languages, just mention it to us,
and we'll implement thse new numbers.
Returns
szSetting file-version info member.
Example
LOCAL szFile
szFile = "FOCUS.FLL"
&& We are not going to use any language setting. Therefore, FOCUS.FLL will retrieve
&& the French Belgian information first, and that's what will be returned
? VER_GetFileVersionInfo( szFile,1 ) && FastWrite FOCUS
? VER_GetFileVersionInfo( szFile,2 ) && 6, 5, 3015a, 0
? VER_GetFileVersionInfo( szFile,3 ) && FOCUS.fll
? VER_GetFileVersionInfo( szFile,4 ) && FOCUS.FLL pour Visual FoxPro 5.0 et 6.0
? VER_GetFileVersionInfo( szFile,5 ) && 6, 5, 3015a, 0
? VER_GetFileVersionInfo( szFile,6 ) && FastWrite
? VER_GetFileVersionInfo( szFile,7 ) && Droits réservés © 1995-1999 FastWrite Belgium
? VER_GetFileVersionInfo( szFile,8 ) &&
? VER_GetFileVersionInfo( szFile,9 ) && FOCUS
? VER_GetFileVersionInfo( szFile,10 ) &&
? VER_GetFileVersionInfo( szFile,11 ) &&
? VER_GetFileVersionInfo( szFile,12 ) && Auteur : Pat Y. Boens
&& Now, we are going to extract the File Version Information in English US,
&& Code Page: Windows Multilingual
? VER_GetFileVersionInfo( szFile,1 ,"040904E4" ) && FastWrite FOCUS
? VER_GetFileVersionInfo( szFile,2 ,"040904E4" ) && 6, 5, 3015a, 0
? VER_GetFileVersionInfo( szFile,3 ,"040904E4" ) && FOCUS.fll
? VER_GetFileVersionInfo( szFile,4 ,"040904E4" ) && FOCUS.FLL for Visual FoxPro 5.0
&& and 6.0
? VER_GetFileVersionInfo( szFile,5 ,"040904E4" ) && 6, 5, 3015a, 0
? VER_GetFileVersionInfo( szFile,6 ,"040904E4" ) && FastWrite
? VER_GetFileVersionInfo( szFile,7 ,"040904E4" ) && Copyrights © 1995-1999
&& FastWrite Belgium
? VER_GetFileVersionInfo( szFile,8 ,"040904E4" ) &&
? VER_GetFileVersionInfo( szFile,9 ,"040904E4" ) && FOCUS
? VER_GetFileVersionInfo( szFile,10,"040904E4" ) &&
? VER_GetFileVersionInfo( szFile,11,"040904E4" ) &&
? VER_GetFileVersionInfo( szFile,12,"040904E4" ) && Author : Pat Y. Boens
Syntax
VER_ini( [szINIFile] ) szCurINIFile
Parameters
szINIFile new INI file setting.
Returns
szCurINIFile current INI file setting. Parameter may not exceed 64 characters.
Example
VER_ini( "POWER.INI" )
? VER_ini() && "POWER.INI"
Parameters
None.
Returns
.T. the function always returns .T. . The VER_init() function initializes all the members of the
internal C structure. It is called upon load of FOCUS.FLL .
Example
VER_init()
VER_name( "Commercial Companion" )
VER_ini( "COMP.INI" )
VER_alpha( .T. )
VER_major( 3 )
VER_minor( 11 )
VER_date("1994/01/21 02:30 pm" )
VER_author( "Marco Polo" )
VER_demo( .T. )
VER_cargo( "DEMO version. Copyrights Plus Soft, Inc." )
Syntax
VER_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\VERSION.C-Mon Oct 19 15:55:22 1998" .
Parameters
nMajor major version number.
Example
VER_major( 3 )
VER_minor( 10 )
? ALLTRIM( STR( VER_minor() ) ) + "." + ;
ALLTRIM( STR( VER_minor() ) ) && "3.10"
Parameters
nMinor minor version number.
Returns
nCurMinor current minor version number.
Example
VER_major( 3 )
VER_minor( 10 )
? ALLTRIM( STR( VER_minor() ) ) + "." ;
ALLTRIM( STR( VER_minor() ) ) && "3.10"
Syntax
VER_name( [szApplName] ) szCurApplName
Parameters
szApplName application name. Parameter may not exceed 60 characters.
Returns
szCurApplName current application name.
Example
VER_name( "Easy Learning - Home Library" )
? VER_name() && "Easy Learning - Home Library"
Syntax
VER_prerel( [lSetting] ) lCurSetting
Returns
lCurSetting current PreRelease setting.
Example
VER_prerel( .T. )
? VER_prerel() && .T.
? VER_alpha() && .F.
? VER_beta() && .F.
Parameters
lSetting new Release setting. Setting this flag affects all related flags (alpha, beta, final release, etc.).
Returns
lCurSetting current Release setting.
Example
VER_FinalRelease( .T. )
? VER_FinalRelease() && .T.
? VER_alpha() && .F.
? VER_beta() && .F.
Parameters
lSetting new Release Candidate setting. Setting this flag affects all related flags (alpha, beta, final
release, etc.).
Returns
lCurSetting current Release Candidate setting.
Example
VER_ReleaseCandidate( .T. )
? VER_ReleaseCandidate() && .T.
? VER_alpha() && .F.
? VER_beta() && .F.
Parameters
szRevision revision number.
Returns
szCurRevision current revision number.
Example
VER_name( "My Application" )
VER_major( 3 )
VER_minor( 1 )
VER_revision( "0017a" )
? VER_name() + " " + ALLTRIM(STR(VER_major())) + "." + ;
PADL( VER_minor(),2,"0" ) + "." + ;
VER_revision() && "My Application 3.01.0017a"
Video Functions
Parameters
None.
Returns
szReturn ????.
Parameters
None.
Returns
szReturn ????.
Parameters
None.
Returns
szReturn ????.
Syntax
VID_LastError() szLastError
Returns
szLastError string describing the last error that occurred using the CD_*() functions.
Syntax
VID_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\MCI.C-Mon Oct 19 15:55:22 1998" .
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
szDevice device to open.
Returns
szReturn ????.
Parameters
None.
Returns
szReturn ????.
Parameters
None.
Returns
.T. the function always returns .T..
Parameters
None.
Returns
.T. the function always returns .T..
WHOIS Functions
Functions Synopsis
WHOIS functions of FOCUS.FLL allow users to query information in central databases regarding users, hosts, company
addresses, and phone numbers.
The WHOIS protocol is part of the TCP/IP stack in that it is a service based on TCP/IP (port 43). Its primary purpose is
to extract information from a central repository that resides on the InterNIC server (Internet Network Information
Center).
The WHOIS protocol is based on the query/response model: when a query is sent, the recipient sends a response back
and drops the connection.
The string that is sent as a request to the server must be terminated with a carriage return/line feed (<CRLF>,
CHR(13) + CHR(10) ).
Parameters
None.
Returns
szLastError last error that occurred while using the WHOIS_*() functions.
Example
Syntax
WHOIS_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set.
Syntax
WHOIS_query( szHost,szQuery ) szInfo
Parameters
szHost WHOIS Server
Returns
szInfo Server response or an empty string if an error occurred. You can use the
WHOIS_LastError() function to retrieve a more detailed explanation.
Example
LOCAL szHost
LOCAL szDomain
m.szHost = "whois.tucows.com"
m.szDomain = "www.fastwrite.com"
? WHOIS_whois( m.szHost,m.szDomain )
Administrative Contact:
Boens, Pat pat.boens@fastwrite.com
rue A. Bracke 9
Kraainem, 1950
BE
+32.27208228
Technical Contact:
DNS Masters, Belgacom Skynet dnsmaster@skynet.be
Carlistraat 2
Brussels, 1140
BE
+32.27061311 Fax: +32.27061312
The Data in the Tucows Registrar WHOIS database is provided to you by Tucows
for information purposes only, and may be used to assist you in obtaining
information about or related to a domain name's registration record.
Tucows makes this information available "as is," and does not guarantee its
accuracy.
By submitting a WHOIS query, you agree that you will use this data only for
lawful purposes and that, under no circumstances will you use this data to:
a) allow, enable, or otherwise support the transmission by e-mail,
telephone, or facsimile of mass, unsolicited, commercial advertising or
solicitations to entities other than the data recipient's own existing
customers; or (b) enable high volume, automated, electronic processes that
send queries or data to the systems of any Registry Operator or
ICANN-Accredited registrar, except as reasonably necessary to register
domain names or modify existing registrations.
Tucows reserves the right to terminate your access to the Tucows WHOIS
database in its sole discretion, including without limitation, for excessive
querying of the WHOIS database or for failure to otherwise abide by this
policy.
Windows Functions
Functions Synopsis
FOCUS.FLL gives the developer tighter control over FoxPro and non FoxPro windows through an impressive set of
functions.
Visual FoxPro works with window handles that are WHANDLE values. Windows works with handles that are HWND
values. These two types of window handles are not compatible. You can easily turn a WHANDLE to a HWND thanks to
the WIN_WHandleToHwnd() function of FOCUS. The contrary is not possible. Don't use WHANDLE s for HWND s nor the
opposite : this would generate illegal operations.
Syntax
WIN_bottom( nWHandle|szTitle ) nBottom
Parameters
nWHandle window handle (WHANDLE).
or…
Returns
nBottom window bottom border position in pixels or –1 if error.
Parameters
nHwnd Window handle (can be obtained by a call to WIN_hwnd() ).
Returns
lSuccess .T. if the elliptic region was successfully deleted; .F. if the function failed.
Example
&& INIT event of the form ===============================================================
LOCAL hWnd
WITH ThisForm
.Width = 324
.Height = 146
DODEFAULT()
WIN_MakeOval( m.hWnd )
ENDWITH
The example of above creates the an elliptical form. The elliptical form is created in a similar way than the
GDI_CreateEllipticRegion() function but this time we use the WIN_MakeOval() function that is much simpler
to use. To beautify the presentation of the form, we have created a JPG file that fills perfectly the ellipse.
Remarks
The WIN_Destroy() function does not support the WM_NCDESTROY or the WM_PARENTNOTIFY message. It does not
destroy children of the specified window. It does not flush the thread message queue. A thread cannot use
WIN_Destroy() to destroy a window created by a different thread.
Syntax
WIN_Destroy( nHwnd ) lSuccess
Parameters
nHwnd window handle (HWND).
Returns
lSuccess .T. if the nHwnd window has been destroyed; .F. if not.
Parameters
nIcon icon handle (typically returned by WIN_GetIcon() ).
Returns
lSuccess .T. if the icon was successfully destroyed; .F. if not.
Example
LOCAL hwnd
LOCAL hdc
Parameters
nColorScheme color scheme to use.
Returns
nButton the button number that was pressed to quit the dialog.
Example
WIN_dialog( 0,"Text in dialog","1","2","3" )
Returns
lSuccess .T. if the window was properly animated; .F. if not.
Example
LOCAL hwnd
WIN_DrawAnimateRects( hwnd,0,0,0,0,300,300,600,600,3 )
Parameters
nTop y-coordinate of the upper-left corner of the rectangle.
For diagonal lines, the BF_RECT flags specify the end point of the vector bounded by the
rectangle parameter.
Returns
lSuccess .T. indicates that the function was successful; .F. if not.
Syntax
WIN_DrawIcon( nDC,nX,nY,nIcon ) lSuccess
Parameters
nDC handle to device context.
Example
LOCAL hwnd
LOCAL hdc
LOCAL hIcon
LOCAL szFile
Alias
EnumChildren()
Syntax
WIN_EnumChildren( [nHwnd] ) lSuccess
Parameters
nHwnd optional window handle (HWND). If not passed, the function uses the active window.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL szWindows
LOCAL OldSep
LOCAL szTitle
LOCAL nTokens
LOCAL i
&& This example starts by enumerating all the child windows of the Desktop of Windows.
&& If the EnumChildren() call is successful, it asks FOCUS.FLL to return all the
&& handles that were found (WIN_GetChildren()). This function actually returns a
&& string where each Window Handle is separated from the other by a caret
&& ("2080^344^612^2572", for example). We then use token functions to extract each
&& window handle (STR_numtok() to determine how many window handles were found, and
&& STR_ntoken() to extract each separate handle). Once the handle is excerpted from
&& the string, it is used by the GetWindowTitle() function to determine the Title
&& of each window. If the titkle is not empty (case when a window is hidden, or when
&& it has no title), it is displayed along with the associated window handle.
IF ( WIN_EnumChildren( GetDesktopWindow() ) )
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 703
Window Functions
szWindows = WIN_GetChildren()
OldSep = STR_setsep( "^" )
nTokens = STR_numtok( szWindows )
FOR i = 1 TO nTokens
szHandle = STR_ntoken( i,szWindows )
szTitle = GetWindowTitle( VAL( szHandle ) )
IF ( ! EMPTY( szTitle ) )
? szTitle,szHandle
ENDIF
NEXT
ENDIF
STR_setsep( OldSep )
Alias
EnumWindows()
Syntax
WIN_EnumWindows() lSuccess
Parameters
None.
Returns
lSuccess .T. if the function is successful; .F. if not.
Example
LOCAL szWindows
LOCAL OldSep
LOCAL szTitle
LOCAL nTokens
LOCAL i
&& This example starts by enumerating all the top level windows.
IF ( WIN_EnumWindows() )
m.szWindows = WIN_GetWindows()
m.OldSep = STR_setsep( "^" )
m.nTokens = STR_numtok( m.szWindows )
FOR i = 1 TO nTokens
m.szHandle = STR_ntoken( i,m.szWindows )
m.szTitle = GetWindowTitle( VAL( m.szHandle ) )
IF ( ! EMPTY( m.szTitle ) )
? m.szTitle,m.szHandle
ENDIF
NEXT
STR_setsep( OldSep )
FOCUS.FLL Version 8.10
/conversion/tmp/scratch/385945009.doc
Last Revision: 4 August 2004 - 22:44
© 1990-2004 FastWrite Page 704
Window Functions
ENDIF
Parameters
nHwnd window handle (HWND)
or
Returns
lSuccess the return value specifies the window's state before the call to the WIN_Flash() function. If
the window was active before the call, the return value is .T. . If the window was not active
before the call, the return value is .F..
Syntax
WIN_GetActiveWindow() nHwnd
Parameters
None.
Returns
nHwnd window handle (HWND).
Syntax
WIN_GetChildren() szChildren
Parameters
None.
Returns
szChildren a tokenized string with all window handles or an empty string ( "") if no child window is found.
Each token is separated from the other by a caret (^).
Example
LOCAL szWindows
LOCAL OldSep
LOCAL szTitle
LOCAL nTokens
LOCAL i
&& This example starts by enumerating all the child windows of the Desktop of Windows.
&& If the EnumChildren() call is successful, it asks FOCUS.FLL to return all the
&& handles that were found (WIN_GetChildren()). This function actually returns a
&& string where each Window Handle is separated from the other by a caret
&& ("2080^344^612^2572", for example). We then use token functions to extract each
&& window handle (STR_numtok() to determine how many window handles were found, and
&& STR_ntoken() to extract each separate handle). Once the handle is excerpted from
&& the string, it is used by the GetWindowTitle() function to determine the Title
&& of each window. If the titkle is not empty (case when a window is hidden, or when
&& it has no title), it is displayed along with the associated window handle.
IF ( WIN_EnumChildren( GetDesktopWindow() ) )
szWindows = WIN_GetChildren()
OldSep = STR_setsep( "^" )
nTokens = STR_numtok( szWindows )
FOR i = 1 TO nTokens
szHandle = STR_ntoken( i,szWindows )
szTitle = GetWindowTitle( VAL( szHandle ) )
IF ( ! EMPTY( szTitle ) )
? szTitle,szHandle
ENDIF
NEXT
ENDIF
STR_setsep( OldSep )
Syntax
WIN_GetClassName( nHwnd ) szClass
Parameters
nHwnd the handle to the window and, indirectly, the class to which the window belongs.
Example
LOCAL nHwnd
IF ( nHwnd != 0 )
szClass = GetClassName( nHwnd ) && "OpusApp"
ENDIF
Each time a window is moved, you need to reissue the WIN_GetClientArea() function.
Alias
GetClientArea()
Syntax
WIN_GetClientArea( nHwnd,@nTop,@nLeft,@nBottom,@nRight ) lSuccess
Parameters
nHwnd window handle (HWND).
nTop y-coordinate of the upper-left corner of the window. Must be passed by reference.
nLeft x-coordinate of the upper-left corner of the window. Must be passed by reference.
nBottom y-coordinate of the lower-right corner of the window. Must be passed by reference.
nRight x-coordinate of the lower-right corner of the window. Must be passed by reference.
Returns
lSuccess .T. indicates that the function was successful; .F. if not.
Example
LOCAL hwnd && HWND handle
LOCAL top && y-coordinate of the upper-left corner of the window
LOCAL left && x-coordinate of the upper-left corner of the window
LOCAL bottom && y-coordinate of the lower-right corner of the window
LOCAL right && x-coordinate of the lower-right corner of the window
top = 0
left = 0
bottom = 0
right = 0
DO FORM "testDC"
? top
? left
? bottom
? right
Parameters
nHwnd window handle (HWND).
Returns
nExtendedStyle extended style. If the function fails, the return value is set to zero.
Example
LOCAL hwnd
? WIN_GetExStyle( hwnd )
See also
WIN_GetHInstance() , WIN_GetStyle() , WIN_GetWndProc() , WIN_GetHwndParent()
Syntax
WIN_GetForegroundWindow() nHwnd
Parameters
None.
Returns
nHwnd window handle (HWND).
See also
WIN_SetForegroundWindow() .
Alias
WIN_GetHwnd()
Syntax
WIN_GetHandle( szTitle ) nHwnd
Parameters
szTitle title of the window that is to be found.
Returns
nHwnd window handle (HWND), or 0 if not found.
Example
LOCAL hwnd
hwnd = WIN_hwnd("Command")
? WIN_GetHInstance( hwnd )
See also
WIN_hwnd() .
Parameters
nHwnd window handle (HWND).
Returns
nInstance application instance. If the function fails, the return value is set to zero.
Example
LOCAL hwnd
? WIN_GetHInstance( hwnd )
See also
WIN_GetExStyle() , WIN_GetStyle() , WIN_GetWndProc() , WIN_GetHwndParent()
Parameters
nHwnd window handle (HWND).
Returns
nHwndParent handle of the parent window, if any. If the function fails, the return value is set to zero.
Example
LOCAL hwnd
hwnd = WIN_hwnd("Command")
? WIN_GetHwndParent( hwnd )
See also
WIN_GetHInstance() , WIN_GetStyle() , WIN_GetExStyle() , WIN_GetHwndParent()
Parameters
szFile file to get an icon from.
Returns
nIcon icon handle or 0 if error. Use WIN_DestroyIcon() to release the icon and to free all the
memory associated with it.
Example
LOCAL hwnd
LOCAL hdc
LOCAL hIcon
LOCAL szFile
Parameters
None.
Returns
nWHandle FoxPro window handle (WHANDLE).
Example
WIN_setPort(29431904) && This is Form1
? "WHANDLE is",WIN_getPort() && Display the value of WHANDLE in Form1
&& The switch will appear as two distinct elements ... first
&& words will appear on Form2, then the switch will take place,
&& then the rest will appear on Form1
? "Switching port",WIN_setPort(29431904),"at",TIME()
Parameters
nHwnd window handle (HWND). Identifies the window and, indirectly, the class to which the window
belongs.
Returns
nStyle style. If the function fails, the return value is set to zero.
Example
LOCAL hwnd
m.hwnd = WIN_hwnd("Command")
? WIN_GetStyle( m.hwnd )
See also
WIN_GetHInstance() , WIN_GetExStyle() , WIN_GetWndProc() , WIN_GetHwndParent()
After painting is complete, the WIN_ReleaseDC() function must be called to release the device context. Not
releasing the window device context has serious effects on painting requested by applications.
Syntax
WIN_GetWindowDC( nHwnd ) nDC
Parameters
nHwnd window handle (HWND).
Returns
nDC device context.
Example
LOCAL hwnd
LOCAL hdc
LOCAL hIcon
LOCAL szFile
Alias
GetWindows()
Syntax
WIN_GetWindows() szWindows
Parameters
None.
Returns
szWindows a tokenized string with all window handles or an empty string ( "") if no top-level window is
found. Each token is separated from the other by a caret (^).
Example
LOCAL szWindows
LOCAL OldSep
LOCAL szTitle
LOCAL nTokens
LOCAL i
&& This example starts by enumerating all the top level windows.
IF ( WIN_EnumWindows() )
m.szWindows = WIN_GetWindows()
m.OldSep = STR_setsep( "^" )
m.nTokens = STR_numtok( m.szWindows )
FOR i = 1 TO nTokens
m.szHandle = STR_ntoken( i,m.szWindows )
m.szTitle = GetWindowTitle( VAL( m.szHandle ) )
IF ( ! EMPTY( m.szTitle ) )
? m.szTitle,m.szHandle
ENDIF
NEXT
STR_setsep( OldSep )
ENDIF
Syntax
WIN_GetWindowText( nHwnd ) szTitle
Parameters
nHwnd window handle (HWND).
Returns
szTitle title of the window.
Example
n = WIN_GetHandle( "Microsoft Word - FOCUS.FLL (1999).doc" )
? WIN_GetWindowText( n ) && "Microsoft Word - FOCUS.FLL (1999).doc"
Parameters
nHwnd window handle (HWND).
Returns
nWndProc window procedure. If the function fails, the return value is set to zero.
Example
LOCAL hwnd
hwnd = WIN_hwnd("Command")
? WIN_GetWndProc( hwnd )
See also
WIN_GetHInstance() , WIN_GetStyle() , WIN_GetExStyle() , WIN_GetHwndParent()
Parameters
szTitle title of the window of which we want to determine the handle.
Returns
nHandle window handle (WHANDLE).
See Also
WIN_hwnd() .
Parameters
nWHandle window handle (WHANDLE).
Returns
nHeight height of window in pixels.
WIN_GetHandle() differs from WIN_hwnd() in the way both functions search for the window: WIN_GetHandle()
uses the FindWindow() Win32 API function while WIN_hwnd() uses the FoxPro API function (_WfindTitle() ).
Also WIN_GetHandle() can only retrieve top-level window handles.
Syntax
WIN_hwnd( szTitle ) nHwnd
Parameters
szTitle window name (window title or form caption).
Returns
nHwnd window handle (HWND). 0 is returned for an invalid window handle.
Syntax
WIN_IsWindow( nHwnd ) lExist
Parameters
nHwnd window handle (HWND).None.
Returns
lExist if the window handle identifies an existing window, the return value is .T.; otherwise it is.F. .
Syntax
WIN_IsWindowEnabled( nHwnd ) lEnabled
Parameters
nHwnd window handle (HWND).None.
Returns
lEnabled if the window is enabled, the return value is .T. ; otherwise it is .F..
Syntax
WIN_IsWindowUnicode( nHwnd ) lUnicode
Parameters
nHwnd window handle (HWND).None.
Syntax
WIN_IsWindowVisible( nHwnd ) lVisible
Parameters
nHwnd window handle (HWND).None.
Returns
lVisible if the window is visible on the screen, the return value is .T. ; otherwise it is .F. . The return
value may be .T. even if the window is totally overlapped by other windows.
Syntax
WIN_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"C:\Focus\5.0\WIN.C-Mon Oct 19 15:55:22 1998" .
Parameters
nWHandle window handle (WHANDLE).
Returns
nLeft window left border position in pixels.
Syntax
WIN_Lock( nHwnd ) lSuccess
Parameters
nHwnd window handle (HWND). Call WIN_lock(0) to unlock the window that's currently locked.
Returns
lSuccess .T. if the window was locked properly; .F. if not.
Example
&& Taken from the dvlForm Load() and Init() events :
PROCEDURE Load()
WITH This
IF ( .IsFocus() )
.hwnd = WIN_hwnd( This.caption )
IF ( .hwnd != 0 )
.IsLocked = WIN_Lock( .hwnd )
ENDIF
ENDIF
ENDWITH
ENDPROC
PROCEDURE Init()
WITH This
<tons of things to do>
IF ( .IsLocked ) && If the window was properly locked
WIN_Lock(0) && Unlock it now
ENDIF
ENDWITH
ENDPROC
Syntax
WIN_main() nHandle
Parameters
None.
Returns
nHandle main window handle (WHANDLE) : desktop.
Parameters
nHwnd Window handle (can be obtained by a call to WIN_hwnd() ).
Please remember that, when you do no need the elliptic region anymore, you MUST
release it with a call to the WIN_ClearOval() function.
Returns
lSuccess .T. if the elliptic region was successfully attached to the form; .F. if the function failed.
Example
&& INIT event of the form ===============================================================
LOCAL hWnd
WITH ThisForm
.Width = 324
.Height = 146
DODEFAULT()
WIN_MakeOval( m.hWnd )
ENDWITH
The example of above creates the an elliptical form. The elliptical form is created in a similar way than the
GDI_CreateEllipticRegion() function but this time we use the WIN_MakeOval() function that is much simpler
to use. To beautify the presentation of the form, we have created a JPG file that fills perfectly the ellipse.
Parameters
szText the message to be displayed.
nType specifies a set of bit flags that determine the contents and behavior of the dialog box. This
parameter can be a combination of flags from the following groups of flags :
Button Indication
Icon Indication
Default Button
Note that each localized release of Windows 95/98 and Windows NT/Windows 2000 typically
contains resources only for a limited set of languages. Thus, for example, the U.S. version offers
LANG_ENGLISH , the French version offers LANG_FRENCH , the German version offers
LANG_GERMAN , and the Japanese version offers LANG_JAPANESE . Each version offers
LANG_NEUTRAL . This limits the set of values that can be used with the nLanguageId
parameter. Before specifying a language identifier, you should enumerate the locales that are
installed on a system (LOC_EnumSystemLocales() and LOC_GetSystemLocales() of
FOCUS.FLL ).
Returns
nButton the return value of WIN_MsgBox() is identical to the standard MESSAGEBOX() function of
Visual FoxPro.
Example
#define DANISH 1030
Syntax
WIN_raised( nTop,nLeft,nBottom,nRight,nDC ) lSuccess
Parameters
nTop y-coordinate of the upper-left corner of the rectangle.
Returns
lSuccess .T. indicates that the function was successful; .F. if not.
Example
LOCAL hwnd && HWND handle
LOCAL nDC && Device Context
DO FORM "testDC"
WIN_raised( 10,100,50,140,nDC )
WIN_ReleaseDC( hwnd,nDC )
See also
WIN_sunken()
To each call to WIN_GetWindowDC() must correspond a WIN_ReleaseDC() to release the device context. Not
releasing the window device context has serious effects on painting requested by applications.
Parameters
nHwnd window handle (HWND).
Returns
lSuccess .T. indicates that the function was successful; .F. if not.
Parameters
nWHandle window handle (WHANDLE).
Returns
nRight window right border position in pixels.
Syntax
WIN_Select( szTitle ) lSuccess
Parameters
szTitle the title of the window that must be selected.
Returns
lSuccess .T. if the function is successful; .F. if not (no window has been found with that title).
Example
WIN_Select("Form1") && Select "Form1"
? TIME() && Display time
WIN_Select("Form2") && Select "Form2"
? TIME() && Display time
This example produces the following output with two forms that have been defined in VFP:
See also
WIN_GetHInstance() , WIN_GetStyle() , WIN_GetExStyle() , WIN_GetHwndParent()
Remark
The WIN_SetActiveWindow() function activates a window, but not if the application is in the background. The
window will be brought into the foreground (top of Z order) if its application is in the foreground when the system
activates the window.
If the window identified by the nHwnd parameter was created by the calling thread, the active window status of the
calling thread is set to nHwnd . Otherwise, the active window status of the calling thread is set to NULL .
By using the AttachThreadInput() Win32 API function (not available in FOCUS.FLL ), a thread can attach its input
processing to another thread. This allows a thread to call WIN_SetActiveWindow() to activate a window attached
to another thread's message queue.
Syntax
WIN_SetActiveWindow( nHwnd ) nHwnd
Returns
nHwnd if the function succeeds, the return value is the handle to the window that was previously
active. If the function fails, the return value is 0.
See also
WIN_SetFocusS(), WIN_SetFocus(), WIN_BringWindowToTop(), WIN_SetForegroundWindow()
Syntax
WIN_SetFocus( nHwnd ) nHwnd
Parameters
nHwnd handle of window to receive focus.
Returns
nHwnd If the function succeeds, the return value is the handle of the window that previously had the
keyboard focus. If there is no such window or if the nHwnd parameter is invalid, the return
value is 0.
See also
WIN_SetFocusS(), WIN_SetFocus(), WIN_BringWindowToTop(), WIN_SetForegroundWindow()
Parameters
szTitle caption of the form to set focus to.
Returns
nHwnd window handle (HWND).
Example
DO FORM "frmTopLevel" && This form should be a top-level form
&& If the caption of this form is "TestFocus"
WIN_SetFocusS( "TestFocus" ) && This gives the focus to the form
Alias
SetForegroundWindow()
Syntax
WIN_SetForegroundWindow( nHwnd ) lSuccess
Parameters
nHwnd window handle (HWND).
Returns
lSuccess .T. if the window was brought to the foreground. If the window was not brought to the
foreground, the return value is .F. .
See also
WIN_SetFocus(), WIN_SetFocusS(), WIN_SetActiveWindow(), WIN_BringWindowToTop(),
WIN_GetForegroundWindow()
Parameters
hwnd handle to the child window.
hwndParent handle to the new parent window.
Returns
hwndOld handle to the previous parent window.
Example
LOCAL nHwndOld, nHwndNew, nHwndChild
Syntax
WIN_setPort( nWHandle ) nWHandleOld
Parameters
nWHandle FoxPro window handle (WHANDLE).
Returns
nWHandleOld FoxPro window handle of the previous user output window (WHANDLE).
Example
WIN_setPort(29431904) && This is Form1
? "WHANDLE is",WIN_getPort() && Display the value of WHANDLE in Form1
&& The switch will appear as two distinct elements ... first
&& words will appear on Form2, then the switch will take place,
&& then the rest will appear on Form1
? "Switching port",WIN_setPort(29431904),"at",TIME()
The sunken effect will disappear each time that Visual FoxPro repaints the window or the form which forces you to call
the WIN_sunken() function (and possibly also the WIN_hwnd() , WIN_GetWindowDC() and WIN_ReleaseDC()
functions) each time the form is repainted (Paint() event).
Syntax
WIN_sunken( nTop,nLeft,nBottom,nRight,nDC ) lSuccess
Parameters
nTop y-coordinate of the upper-left corner of the rectangle.
Returns
lSuccess .T. indicates that the function was successful; .F. if not.
Example
LOCAL hwnd && HWND handle
LOCAL nDC && Device Context
DO FORM "testDC"
WIN_sunken( 10,100,50,140,nDC )
WIN_ReleaseDC( hwnd,nDC )
See also
WIN_raised()
Parameters
nWHandle window handle (WHANDLE).
or…
Returns
nTop window top border position in pixels.
Parameters
nWHandle window handle (WHANDLE).
Returns
nWidth window width in pixels.
Parameters
nWHandle window handle (WHANDLE).
Returns
nHwnd window handle( HWND).
ZIP Functions
Functions Synopsis
With version 8.05 of FOCUS.FLL , real ZIP functions have been incorporated in the
library. They are based on the fantastic work provided by zlib.
zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression).
Jean-loup is also the primary author/maintainer of gzip(1), the author of the
comp.compression FAQ list and the former maintainer of Info-ZIP's Zip; Mark is also
the author of gzip's and UnZip's main decompression routines and was the original
author of Zip. Not surprisingly, the compression algorithm used in zlib is essentially the
same as that in gzip and Zip, namely, the `deflate' method that originated in
PKWARE's PKZIP 2.x.
So far, only 2 functions have entered the world of FOCUS.FLL that provides a very
high level of abstraction to zlib, and hence to ZIP in general. You can expect more
functions in the future.
All the developers that would like to obtain further information about zlib can follow this URL:
http://www.gzip.org/zlib/.
Parameters
szString string to compress.
Returns
szResult the compressed string or an empty string in case of error (use ZIP_LastError() ).
Example
LOCAL szFile
LOCAL szOriginal
LOCAL szCompressed
LOCAL szDecompressed
IF ( ! EMPTY( m.szFile ) )
IF ( ! EMPTY( m.szOriginal ) )
IF ( ! EMPTY( m.szCompressed ) )
IF ( ! EMPTY( m.szDecompressed ) )
IF ( m.szDecompressed == m.szOriginal )
ELSE
ENDIF
ELSE
ENDIF
ELSE
ENDIF
ELSE
? "File is empty"
ENDIF
ELSE
Parameters
szString string to decompress.
Returns
szResult the decompressed string or an empty string in case of error (use ZIP_LastError() ).
Example
LOCAL szFile
LOCAL szOriginal
LOCAL szCompressed
LOCAL szDecompressed
IF ( ! EMPTY( m.szFile ) )
IF ( ! EMPTY( m.szOriginal ) )
IF ( ! EMPTY( m.szCompressed ) )
IF ( ! EMPTY( m.szDecompressed ) )
IF ( m.szDecompressed == m.szOriginal )
ELSE
ENDIF
ELSE
ENDIF
ELSE
ENDIF
ELSE
? "File is empty"
ENDIF
ELSE
Syntax
ZIP_Compress( szSkeleton,szZIP[,lAdd] ) nResult
Parameters
szSkeleton File skeleton so you can compress files that match a search criterion. Additional file skeletons
can be specified by cumulating them in a semicolon separated list ( ';').
lAdd optional parameter; if specified and if evaluates to a logical true ( .T. ), then the files
corresponding to szSkeleton will be added to the ZIP archive and the original ZIP file won't
be recreated.
Returns
nResult 0 if success; otherwise browse through the following values:
Return Meaning
0 Success
-1 Cannot add a file to the archive. Call
ZIP_LastError() to obtain further
information about the error.
-2 Cannot create the ZIP archive.
-3 Cannot allocate memory.
-4 Compression aborted by callback.
3 Error while reading a file that must be add the
archive. Call ZIP_LastError() to obtain
further information about the error.
4 Error while writing a file that must be added the
archive. Call ZIP_LastError() to obtain
further information about the error.
5 Error while closing a file that must be added the
archive. Call ZIP_LastError() to obtain
further information about the error.
-4
Example
*** EXAMPLE #1 ***
LOCAL nError
IF ( m.nError != 0 )
? "Error while compressing files:",m.nError,ZIP_LastError()
ENDIF
Syntax
ZIP_Expand( szZIP,[szDir] ) nResult
Parameters
szZIP the ZIP archive to expand. All individual files will be recreated.
Returns
nResult 0 if success; otherwise browse through the following values:
Return Meaning
0 Success
-100 Cannot locate a file in the archive.
-101 Cannot expand a file from the archive.
-102 Cannot set the current directory
-103 Cannot save current directory
-104 Cannot open archive.
-4 Expansion aborted by callback.
Example
LOCAL nError
Parameters
None.
Example
LOCAL nError
IF ( m.nError != 0 )
? "Error while compressing files:",m.nError,ZIP_LastError()
ENDIF
IF ( m.nError != 0 )
? "Error while compressing files:",m.nError,ZIP_LastError()
ENDIF
Syntax
ZIP_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersion string identifying the last version of the functions set. The string is similar to
"D:\Focus\6.0\FWZip.c-Tue Apr 15 07:54:54 2003" .
Parameters
szZIP the ZIP archive to list. For each entry found in the ZIP file, the callback function set with
ZIP_SetCallback() is fired.
Returns
nEntries -1 in case of error; otherwise, the function returns the number of entries (files and directories)
found in the ZIP file.
Example
LOCAL szCallback
LOCAL szZIPFile
LOCAL nEntries
&& In this example, we will list through an archive file and display
&& each entry found thanks to the callback function.
m.szCallback = ZIP_SetCallback( "MyCallback()" )
m.szZIPFile = "D:\MANAGE2100\SENTANAI\PROJECTTRACKER.ZIP"
Parameters
szFunc the new callback function. This function should return a logical value, .T. or .F.. If it returns
.F., the current compression/expansion is aborted.
Returns
szCurFunc the current callback function.
Example
LOCAL szCallback
<... here you would have code that calls the ZIP_Compress() or ZIP_Expand() function >
RETURN ( m.lRetVal )
Returns
lCurSetting the current internal setting as it is set in FOCUS.FLL , prior to call the function.
Example
ZIP_SetSubdirs( .F. ) && Don't include subdirs
IF ( ZIP_compress( "D:\xcase\*.*","d:\xcase1.zip" ) == 0 )
? FIL_size( "d:\xcase1.zip" ) && Display 19440063
ENDIF