Click Here to Install Silverlight*
Middle EastChange|All Microsoft Sites
Microsoft

Microsoft Visual FoxPro with Arabic Support



Introduction

Visual FoxPro 7.0 is a powerful data-centric object-oriented language for quickly creating high-performance desktop, rich client, distributed client and client/server. Visual FoxPro 7.0 offers powerful data-handling capabilities, rapid application development (RAD) tools for maximum productivity, and flexibility to build all types of database solutions.

This paper will discuss and demonstrate the extent Visual FoxPro support Arabic, including information about the features and useful workarounds for Arabic support. You can also checkout the download section for three interesting samples; these will provide quick hands-on experience to build Arabic applications.


Prerequisites

Before enabling Visual FoxPro to support Arabic language, you should use Arabic Enabled version of either Windows 98 or Windows 95. In case of Windows 2000 and Windows XP, you need to set the locale to Arabic, from the control panel, regional setting.

On Windows 2000:"Regional Options" in the "General" tab, add Arabic to the "Language setting for the system"



On Windows XP: "Regional and Language Options" go to the "Advanced" tab and change the "Language for non Unicode programs" to an Arabic language.


PS. This will not affect the user interface language.

For more information about Visual FoxPro general requirements, please check http://msdn.microsoft.com/vfoxpro/.


Customizing the Visual FoxPro Environment

After you install Visual FoxPro, you might want to customize your development environment. Environment settings include the main window title, default directory, project and many other options.

You can configure Visual FoxPro either interactively or programmatically. You can also establish configuration settings that are loaded when you start Visual FoxPro.

Interactive Environment Settings configuration
To view and change environment settings, you can use the Options dialog box.
To display the Options dialog box, From the Tools menu, choose Options.

  1. From the Tools menu, choose Options
  2. In the Options dialog box, choose Regional tab
  3. Select the Use system settings check box
  4. Choose Set as Default if you want the system regional settings to be used in subsequent sessions of Visual FoxPro.
  5. Press OK.

However you can set your own regional setting that overrides the system settings. As shown below. This is useful in setting Arabic specific cases, for example, most Arabic cultures use DMY date format and not MDY format.



Programmatic Environment Settings configuration
Most options displayed on the tabs in the Options dialog box can also be modified programmatically by using a SET command or by assigning a value to a system variable. For example, to use a year-month-date format for dates, you can change the Date Format setting in the Regional tab of the Options dialog box, or you can use the SET DATE command:

  SET DATE TO ANSI     && Sets format to yy.mm.dd


If you configure the environment using SET commands, the settings are in effect only for the current session of Visual FoxPro. When you quit the program, your settings are discarded, and you must reissue the SET commands. However, you can automate this process by issuing SET commands at startup or using a configuration file.

What is Configuration File?
A configuration file is a text file which contains Visual FoxPro settings. When Visual FoxPro loads a configuration file, the settings in that file takes precedence over corresponding default settings made in the Options dialog box. If you are creating a new configuration file, you can save it using any name you want. By convention, configuration files have the extension .fpw.
When you start Visual FoxPro you can use a default configuration file in the following locations (in order):
  • The current working directory
  • The directory where Visual FoxPro is installed
  • The directories listed in the path environment variable

If the default configuration file is not found in these locations, Visual FoxPro uses only the default settings established in the Options dialog box

Config.FPW

Config.fpw is the default name for the configuration file. Saving this file to Visual FoxPro startup directory will automatically load the defined settings within it upon starting Visual FoxPro.

 TITLE = فـوكـس بـرو 7     && Changing Visual FoxPro Title to فـوكـس بـرو 7
 COLLATE = ARABIC     && Changing the sorting order to Arabic
 DATE = BRITISH     && Changing date format to British (dd/mm/yy)
 CPDIALOG = ON     && Show the Code Page dialog box when opening a table created in earlier FoxPro versions and other products that create Visual FoxPro tables.
This allows you to specify a code page for such as these tables.
 CENTURY = ON     && Provide year 2000 compliance.
 STATUS BAR = OFF     && Hide Visual FoxPro Status bar.
 SET CURRENCY TO "رس"     && Set the currency symbol.
 CODEPAGE = 1256     && Set the codepage to Arabic Windows



Creating a Database

Because a database application is so dependent on the underlying data, the best way to begin designing your application is to start with the data. You can set up your database and determine what the relationships are between tables, what business rules you want to enforce, and so on, before you design any interface or data manipulation components. When you create a database, you gather tables together into one collection and gain the benefit of data dictionary features. A data dictionary gives you greater flexibility in designing and modifying the database, and frees you from having to write code to create field-level and row-level validation or to ensure the uniqueness of values within primary key fields.

Table Designer

Use the Table Designer to create and modify database tables, free tables, fields, and indexes. The Table Designer helps you implement advanced features, such as validation rules, default values, and default control classes. For more details read the Table Designer Visual FoxPro help topic. The main concern for creating Arabic tables is to set the codepage to an Arabic codepage because tables in Visual FoxPro are tagged with the code page that was in use when the table was created. When you use the table, Visual FoxPro checks the code page for the table against the current code page. If they match, Visual FoxPro displays the data as is. However, if they do not match, Visual FoxPro attempts to translate characters from the table code page into the current one. If there is no code page for the table (for example, the table was created in an earlier version of FoxPro), Visual FoxPro prompts you for a code page and then marks the file with it.

Sorting Data

After creating a table of data, check to see if your application sorts the data correctly. How the data sort depends on the code page associated with the table, because the code page specifies the available sort orders or collation sequences. Form more information about codepages and sorting orders read the Sorting Data section.


Forms

You can use forms to give your users a familiar interface for viewing and entering data into a database. The easiest way to define the user interface for a form is to place controls on its surface. Our main concern for Arabic development is to utilize the RightToLeft property for controls, so let's examine this property in more detail.

Reading Order

RightToLeft is the key property for Arabic support; the RightToLeft property specifies whether the text is displayed from right to left, such as when using Arabic fonts. The form itself supports the RightToLeft property, as do most of the controls.

The RightToLeft property takes one of the following values:

 Value  Description
 False (.F.)  Text is displayed in controls in a left-to-right reading order.
 True (.T.)  Text is displayed in controls in a right-to-left reading order.


When you set the RightToLeft property to True, text displayed in the form's title bar is right-aligned with RTL reading order as shown below.

Controls
Visual FoxPro controls are reusable components that encapsulate user interface functionality and are used in client-side Windows applications. Visual FoxPro provides many ready-to-use controls, in addition to the main infrastructure for developing your own controls.

Reading order

Most of Visual FoxPro Controls includes the RightToLeft property which in conjunction with the Alignment property provides the Arabic user interface look and feel.
The Alignment property used to specify the orientation of text in a control. Either you align your text to the left, to the right, or set it to automatic so that Visual FoxPro automatically aligns the text (For example, if the text is a numeric data it aligns it to right).

The following table explains how the RightToLeft property and the Alignment property affect the controls.

Control/Component RightToLeft = .T. Alignment = 1 Right
CheckBox Sets the right-to-left (RTL) reading order The check box is displayed on the right side of the text.
ComboBox Items in combo box control are right aligned and the drop-down arrow is displayed on the left side rather than right side ComboBox text is right aligned (Affect only if the Style property set to 0-DropDown Combo)
CommandButton Sets the RTL reading order Not Available.
CommandGroup Not Available. Not Available.
Container Not Available. Not Available.
EditBox Sets the RTL reading order.Vertical Scrollbar displayed on the left side rather than right side. Text is right aligned.
Grid Vertical Scrollbar displayed on the left side rather than right side.Horizontal Scrollbar start with the scroll box (thumb) right-aligned.Record marker is displayed on the right side rather than left side.Columns arranged in RTL order rather than left to right. Not Available.
Image Not Available. Not Available.
Label Sets the RTL reading order. Not Available.
ListBox Items in list box control are right aligned.Vertical Scrollbar displayed on the left side rather than right side. Not Available.
ListBox Items in list box control are right aligned.Vertical Scrollbar displayed on the left side rather than right side. Not Available.
OptionBotton Sets the RTL reading order The Radio button is displayed on the right side of the text.
OptionGroup Not Available. Not Available.
PageFrame Pages in the PageFrame are right aligned. Not Available.
Shape Not Available. Not Available.
Spinner Up and down buttons are left-aligned. The default value is right-aligned.
TextBox Sets the RTL reading order. Text is right aligned.
ColorDialog -
GETCOLOR()
Depends on the language of the operating system. Not Available.
FontDialog –
GETFONT()
Depends on the language of the operating system. Not Available.
OpenFileDialog –
GETFILE()
Depends on the language of the operating system. Not Available.
PageSetupDialog –
SYS(1037) or via the report print command.
Depends on the language of the operating system. Not Available.
SaveFileDialog –
PUTFILE()
Depends on the language of the operating system. Not Available.
Timer Not required. Not required.
ToolBar Not affect by this property. Not Available.
MessageBox –
MESSAGEBOX()
Not Available. Not Available.

Note: Blue-Bolded components are Visual FoxPro functions

Menus

You can use the Menu Designer and the Shortcut Designer to create menus, menu items, submenus, and separators. You can also use the Menu and Shortcut Designers, to customize your copy of Visual FoxPro menu or design your own menus for applications you intend to distribute. After planning your menu using the designer you can generate a menu code using the Generate option in the Visual FoxPro Menu pad.



Generated menu code is a set of DEFINE MENU, DEFINE PAD, and DEFINE POPUP commands that identify your menu options.

System Menu

Visual FoxPro allows you to customize its system menu (_MSYSMENU) you can enable or disable the Visual FoxPro system menu bar during program execution, and also you to reconfigure it. For more details see SET SYSMENU Visual FoxPro help topic.

Switching System Menu

You can easily switch the system menu from left to right and vice versa using the following two commands

  SET SYSMENU TO RTLJUSTIFY      && Sets the system menu to the right
 
  SET SYSMENU TO LTRJUSTIFY      && Sets the system menu to the left


RTLJUSTIFY switch your system menu to be started from the window's right corner and expanded to the left, in addition to changing the window's RightToLeft property to true.

Example


CLEAR
SET SYSMENU TO
SET SYSMENU AUTOMATIC
ON KEY LABEL ESC KEYBOARD CHR(13)
DEFINE PAD InvPad OF _MSYSMENU PROMPT "مـخـازن" COLOR SCHEME 3
DEFINE PAD RepPad OF _MSYSMENU PROMPT "تـقـاريـر" COLOR SCHEME 3
ON PAD InvPad OF _MSYSMENU ACTIVATE POPUP InvPop
ON PAD RepPad OF _MSYSMENU ACTIVATE POPUP RepPop
DEFINE POPUP InvPop MARGIN RELATIVE COLOR SCHEME 4
DEFINE BAR 1 OF InvPop PROMPT 'الأصـنـاف' KEY CTRL+S, '^S'
DEFINE BAR 2 OF InvPop PROMPT 'المـقـاسـات'
ON SELECTION POPUP InvPop DO choice WITH PROMPT(), POPUP()
DEFINE POPUP RepPop MARGIN RELATIVE COLOR SCHEME 4
DEFINE BAR 1 OF RepPop PROMPT 'مـبـيـعـات الأصـنـاف'
ON SELECTION POPUP RepPop DO choice WITH PROMPT(), POPUP()
SET SYSMENU TO RTLJUSTIFY && Sets the system menu to the right
ON KEY LABEL ESC
PROCEDURE choice
PARAMETERS mprompt, mpopup
WAIT WINDOW 'You chose ' + mprompt + ' from popup ' + mpopup NOWAIT
SET SYSMENU TO DEFAULT
SET SYSMENU TO LTRJUSTIFY

User-Defined Menu

To define your own Arabic right to left Top-Level menu you have two ways

  1. Use the _SCREEN Visual FoxPro system variable as your Top-Level Form and build your _MSYSMENU exactly like the above example
    Note: When using _SCREEN as your Top-Level form you should design all of your forms to be shown in the screen i.e. the form's ShowWindow property should equals 0-In Screen which is the default value.

  2. Design your menu the way you prefer then use the windows APIs to mirror your Top-Level Form. For more information check the Samples section.
    Note: When designing a Top-Level form you should design all of your forms to be shown in this Top-Level form i.e. the form's ShowWindow property should equals 1-In Top-Level Form.


Mirroring the Top-Level Form

Mirroring the window means making the horizontal origin on the right edge of it instead of the left edge. The following example explains how to develop mirrored Windows form control. The example uses two extended window styles:
  • WS_EX_LAYOUTRTL: Creates a window whose horizontal origin is on the right edge. Increasing horizontal values as you advance to the left.

  • WS_EX_NOINHERITLAYOUT: A window created with this style does not pass its window layout to its child windows.

To mirror the Top-Level form and its menu without affecting the child forms, you can add the following code in the form Load event



*-- Define extended Windows styles
#DEFINE GWL_EXSTYLE -20
#DEFINE WS_EX_LAYOUTRTL 0x400000
#DEFINE WS_EX_NOINHERITLAYOUT 0x100000
*-- Define the Get window long API
DECLARE INTEGER GetWindowLong IN user32;
INTEGER hWnd, INTEGER nIndex
*-- Define the Set window long API
DECLARE INTEGER SetWindowLong IN user32;
INTEGER hWnd, INTEGER nIndex, INTEGER dwNewLong
*-- Get this form's current style.
OldLong = GetWindowLong(ThisForm.HWnd, GWL_EXSTYLE)
*-- Set the window extended style RTL non-inheritable.
SetWindowLong(ThisForm.HWnd,GWL_EXSTYLE,;
BITOR(OldLong,WS_EX_LAYOUTRTL,WS_EX_NOINHERITLAYOUT))



Check the following figure for the mirrored form.


For a complete code listing, check out the sample in the Download section.


Report Designer

To design Arabic report, you have to let the interface flow from right to left. Visual FoxPro Report Designer supports Arabic via the Text Alignment and Reading Order properties. So, there are two main steps to designing an Arabic report:
  • Design and place the report's controls (Text Objects and Fields) to match the desired right to left layout

  • Set the Text Alignment and Reading Order properties, of the Text Objects and Fields controls of the report, to Right and Right to Left , respectively


Set Text Alignment Property

  • Select the desired control, go to the Format menu, and choose Text Alignment

  • From the submenu, select Right




Set Reading Order Property
  • Select the desired control, go to the Format menu, and choose Reading Order

  • From the submenu, select Right to Left.



Note

You may face a problem with control's alignment after saving the report and reloading it. However, this problem is in the designer but the preview and the printed report are still correctly aligned.

Preview Report

The following example illustrates how you can preview your designed report in a pre-defined window instead of using the normal report designer preview.

LOCAL lnScaleMode
lnScaleMode = _Screen.ScaleMode     && Save current scale mode.
_Screen.ScaleMode = 0      && Set scale mode to Foxel.
*-- Define the hosting window.
DEFINE WINDOW RepHost FROM 0,0 TO _Screen.Height - 2, _Screen.Width ;
TITLE "أوامـر تـوريـد" CLOSE FLOAT GROW ZOOM SYSTEM
_screen.ScaleMode = lnScaleMode    && Restore saved scale mode.
*-- Preview the report in the hosting window.
REPORT FORM REPORTA.FRX PREVIEW WINDOW RepHost NOWAIT




Notes
  • Normal preview window has a title of Report designer – Name of the report – Page #.
  • You can define a form object instead of defining a window like the following example and the result will be the same.


LOCAL oHostForm as Form
oHostForm = CREATEOBJECT("form")
oHostForm.Caption = " أوامـر تـوريـد"
oHostForm.AutoCenter = .T.
*-- Preview the report in the hosting window.
REPORT FORM g:\ms\ms\reporta.frx PREVIEW WINDOW (oHostForm.Name) NOWAIT





Label Designer

The Label Designer Arabic support is the same as the Report Designer, using the same menus, toolbars and functionality. The main difference is that the Label Designer automatically defines the page and its columns based on the size of label you select.

New Label Dialog Box

Displays predefined Avery label types. This dialog box appears when you select Label from the New dialog box and then choose New File. The type you select becomes the base for your new label. The Columns field refers to how many columns will fit on a page.

Note: You can add a new label size to the list using the ADDLABEL.APP application located in the Visual FoxPro …\Tools directory.




Object-Oriented Programming

Using Visual FoxPro object model, you can employ all the features of object-oriented programming including inheritance, encapsulation, polymorphism, and sub-classing. You can speed up application development by using classes. For example, you can create a basic form, toolbar, or page frame by using the form, toolbar, or page frame base class provided with Visual FoxPro. Then you can reuse your code and forms by sub-classing these classes. For example, you can subclass the Form base class to create a custom class that automatically gives all the forms in your application the look and feel you want.

Implementing Arabic Support Class Library Based on Visual FoxPro form and controls you can make your own Arabic custom controls which benefits from the sub-classes and inheritance object-oriented features. You can then reuse these controls during the development process of your application.

For example, these are the steps to create a simple custom Arabic support TextBox
  1. Create new class based on the Visual FoxPro TextBox (File menu\New Class or issue the CREATE CLASS command in the command window)
  2. The create class dialog box appears as shown below.




  3. In the "Class Name" field write the class name, select the class type to be based on Visual FoxPro from the "Based On" drop-down list; finally, write the class library name in the "Store In" text box, and then press OK.
  4. Visual FoxPro will then open the class designer allowing you to customize the inherited class properties, add new properties, and also you can override class methods or even add new methods and functionality to your custom class.
  5. Change the Alignment property to 1-Right, and the RightToLeft property to .T.True as shown below




  6. Finally, save the class

You can easily repeat these steps to sub-class all Visual FoxPro controls then adding the Arabic properties to them, and don't forget that the Form is considered a control.

Setting Form Templates

One of the great advantages of Visual FoxPro is the ability to make your own custom form class as a template for all your new forms.
When you create a new form, it is based on the template form that is set in the Options dialog box. If no template is specified, the new form is based on the Visual FoxPro Form base class.

Advantages of Using Form Templates

Form templates allow you to set default properties for your forms so that you can easily give all the forms in your application a consistent look and feel. You could include a company logo, for instance, and use a consistent color scheme in all your forms by designing a template form class with these attributes. If the company logo changes, you could change the picture in the template form class and all the forms you created based on the template would automatically inherit the new logo.
You can add custom properties and methods to the Visual FoxPro form class so that these properties and methods are available to each form in your application. If you are used to creating variables and user-defined procedures that are scoped to a form, using custom properties and methods provides this functionality, and also allows you to have a cleaner encapsulation model.

Specifying the Default Form Template

You can specify a form class from a registered class library for your form template.

To specify a default form template
  1. From the Tools menu, choose Options.
  2. In the Options dialog box, go to the Forms tab.
  3. In the Template Classes area, select the Form check box.
  4. If no form template has been selected, the Open dialog box opens so that you can choose a form class. If a form template has been selected, you can change it by choosing the dialog button and selecting another class.
  5. Choose Set as Default if you want the template to be used in subsequent sessions of Visual FoxPro.
  6. Choose OK.





Globalization

Globalization is the process of designing applications that can adapt to different cultures.
Visual FoxPro provides support for developing world-ready applications. In this section we are going to discuss the guidelines to adapting to the Arabic applications.

Sorting Data

After creating a table, you need to make sure that your application sorts the data correctly. How data is sorted depends on the code page associated with the table, because the code page specifies the available sort orders or collation sequences.

Understanding Sort Orders

Sort orders incorporate the sorting rules of different locales, making it possible for you to sort data in those languages correctly. In Visual FoxPro, the current sort order determines the results of character expression comparisons and the order in which records appear in indexed or sorted tables. It affects the results of string comparisons, SEEK, and SELECT - SQL, as described in the following sections.

Specifying Sort Orders

You can specify a sort order for character fields to be used in subsequent indexing and sorting operations.
To specify a sort order
  1. From the Tools menu choose Options.
  2. Select the Data tab.
  3. In the Collating sequence box, select the appropriate sort order (Arabic for Arabic language).
To save this setting for future sessions of Visual FoxPro, choose Set as Default.



Tip You can also specify a sort order with the SET COLLATE TO command or the COLLATE statement in your Config.fpw file.

The current sort order doesn't affect previously created indexes; however, it does affect the results of comparisons and commands such as SEEK and SELECT - SQL.

You can change the sort order at any time. For instance, after opening a customer table you can create index tags representing different sort orders, as shown in the following code. Then you can change the sort order by simply using a different tag:


USE customer
SET COLLATE TO "ARABIC"
INDEX ON fName TAG myArabic ADDITIVE
SET COLLATE TO "MACHINE"
INDEX ON custid TAG mymachine ADDITIVE



Note: The index sort order overrides the current sort order.

The current code page determines which sort orders are available. If you use SET COLLATE to specify a sort order not available by the current code page, Visual FoxPro generates an error "Collating sequence "< SORT ORDER NAME> "is not found". Also, if you specify a sort order in Config.fpw that isn't supported by the current code page, the sort order defaults to Machine.

Note: Machine is the default collation sequence option and is the sequence Xbase users are familiar with. Characters are ordered as they appear in the current code page, that means its binary order. For example, the following comparison will return false if you set Machine collation

?"خالد"="خـالــد"


But if you set the collation to ARABIC, the same expression will return true.

When using ARABIC collation the text comparison taking into consideration ignoring some special characters, such as kashida, diacritics and alef/alef-hamza.

Checking Sort Orders

You can determine the current sort order by using the SET ('COLLATE') function. For example, you can save the current sort order, set the current sort order to Machine, perform whatever work is necessary, and then restore the original sort order by using the following code:

cCurrentOrder=SET('COLLATE')
SET COLLATE TO 'MACHINE'
*
* code that requires the Machine sort order
*
SET COLLATE TO cCurrentOrder && return to the previous sort order


You can also determine the sort order of an index or index tag by using the IDXCOLLATE( ) function.

Comparing Strings

All sort orders except for Machine ignore letter case. This means that you don't have to use UPPER( ), LOWER(), or PROPER() functions in your index expressions.

The current sort order affects string comparisons. For example, when you set the sort order to ARABIC, the following statement return true:


SET COLLATE TO "ARABIC"
?"خالد"="خـالــد"



However the character string comparison operator (==) returns false regardless the set of collation sequence because it compares strings byte by byte.

Note Visual FoxPro ignores SET EXACT when you use the character string comparison operator (==).

Using SEEK

The following SEEK example will illustrate how the ARABIC collection affect seeking a key within a table

 CREATE TABLE ar_Test (ar_Key C(20))     && Create table have one character field (ar_Key)
 SET COLLATE TO "ARABIC"     && Set Collation to ARABIC
 INDEX ON ar_Key TAG ar_Tag ADDITIVE     && Create ARABIC collation index on ar_Key field.
 INSERT INTO ar_Test (ar_Key) VALUES ("أحمد")     && Insert new record value with Alef-Hamza
 ?IDXCOLLATE("ar_Test",1)     && Print the index collation to the screen.
 ?SEEK("احمد")     && Search for احمد without Alef-Hamza, it returns true means the value is the same.
 USE IN ar_Test     && Close the created table.


Tip: Visual FoxPro ignores diacritical marks when you perform a partial seek. A partial seek occurs when you make the length of the expression less than the length of the key. If diacritics are important, consider using SCAN FOR...ENDSCAN or LOCATE FOR...CONTINUE instead of SEEK.

The advantages of using SCAN and LOCATE instead of SEEK include the following:
  • SCAN and LOCATE are sensitive to diacritics.
  • Visual FoxPro fully optimizes the results of SCAN or LOCATE if the current sort order is Machine or Unique Weight like Arabic, whereas Visual FoxPro only partly optimizes the results of SEEK.
  • SCAN and LOCATE remember the condition that invoked them, making it possible for you to use them for looping on a condition. In contrast, SEEK positions you somewhere in the index, and SKIP continue down the index from that point. Accordingly, SEEK might not produce the results you want with Arabic data


SEEK versus LOCATE Example

Suppose you have a table include the keys "أحمر" and "احمر" and you want to go to the record of the key "أحمر"
Issuing the following seek command will fail to go to the desired record

SEEK "أحمر"

Instead it moves the record pointer to the " احمر" key record. But issuing the following locate statement will move the pointer correctly to the required key

LOCATE FOR arfield = "أحمر"


Using SELECT - SQL

The SELECT - SQL command uses the current sort order. For example, if you have an index tag based on the Arabic sort order and the current sort order (returned by SET ('COLLATE')) is Machine, the result of SELECT SQL is based on Machine.

To employ the current sort order, use the ORDER BY clause of SELECT-SQL.

Sorting Combo and List Controls

In addition, the combo and list controls are affected by the current sort order. For example if you have a list control with the following text items:

This.AddItem("خالــــد")
This.AddItem("أيمن")
This.AddItem("عليُ")
This.AddItem("علي")
This.AddItem("ايمن")
This.AddItem("خالد")
This.Sorted = .T.


MACHINE Collating output:


ARABIC Collating output:


Using Indexes

Sort orders determine the order of records in indexed tables. Consider the following guidelines for using indexes with sort orders:
  • Rebuild indexes created in earlier versions of FoxPro if you want the indexes to use a sort order other than machine.
  • Rebuild database indexes to take advantage of Visual FoxPro sort orders.
  • Use the REINDEX command to rebuild an index, because REINDEX leaves the sort order unchanged.


Preventing Translation of Data in Character or Memo Fields

In some cases you don't want automatic code page translation. For instance, if a character field contains an encrypted password, you don't want Visual FoxPro to automatically translate the password because doing so would change it.

To prevent translation of data in a character or memo field
  1. Open the project containing the table.
  2. Select the table.
  3. Choose the Modify button.
  4. Select the field whose data you want to protect.
  5. From the Type list select Character (Binary) for a Character field or Memo (Binary) for a memo field.
  6. Choose OK, and then choose Yes to make the changes permanent.


Digit substitution system

Visual FoxPro follows the same rules as the operating system regarding digit substitution. The digit substitution of the operating system depends on the user locale and how you set the digit substitution of the regional settings in the control panel.





For example, if you set the digit substitution to National Visual FoxPro will use the Arabic (Hindi) numbers instead of Latin numbers.



Formatting Date and Time

Visual FoxPro provides data time functionality via the following functions

Function
Description
CDOW()
Returns the day of the week from a given Date or DateTime expression.
CMONTH()
Returns the name of the month from a given date or DateTime expression.
CTOD()
Converts a character expression to a date expression.
CTOT()
Returns a DateTime value from a character expression.
DATE()
Returns the current system date, which is controlled by the operating system, or creates a year 2000-compliant Date value.
DATETIME()
Returns the current date and time as a DateTime value, or creates a year 2000-compliant DateTime value.
DAY()
Returns the numeric day of the month for a given Date or DateTime expression.
DMY()
Returns a character expression in day-month-year format (for example, 31 May 1998) from a Date or DateTime expression. The month name isn't abbreviated.
DOW()
Returns a numeric day-of-the-week value from a Date or DateTime expression.
DTOC()
Returns a Character-type date from a Date or DateTime expression.
DTOS()
Returns a character-string date in a yyyymmdd format from a specified Date or DateTime expression.
DTOT()
Returns a DateTime value from a Date expression.
GOMONTH()
Returns the date that is a specified number of months before or after a given Date or DateTime expression.
HOUR()
Returns the hour portion from a DateTime expression.
MINUTE()
Returns the minute portion from a DateTime expression.
MONTH()
Returns the number of the month for a given Date or DateTime expression.
QUARTER()
Returns the quarter of the year in which a date or datetime expression occurs.
SEC()
Returns the seconds portion from a DateTime expression.
TIME()
Returns the current system time in 24-hour, eight-character string (hh:mm:ss) format.
TTOC()
Converts a DateTime expression to a Character value of a specified format.
TTOD()
Returns a Date value from a DateTime expression.
WEEK()
Returns a number representing the week of the year from a Date or DateTime expression.
YEAR()
Returns the year from the specified date or datetime expression.
SET HOURS TO
Sets the system clock to a 12- or 24-hour time format.


In addition Visual FoxPro provides different date formats like (American mm/dd/yy, ANSI dd.mm.yy)
You can set the date format issuing the following command

SET DATE TO BRITISH     && Sets the date format to British (dd/mm/yy)


Sub-classing the DateTimePicker Control

Visual FoxPro doesn't support a specific date time control.

Instead it handles date time data types via the normal TextBox control, using TextBox requires an extra code to validate the entered date time, and also it is not combatable with the modern interface designs. So it's the time to know how to use an active X component (OCX) to enter date and time.

Sub-Class the DateTimePicker steps
  1. Create new class (File menu/New Class or issue the CREATE CLASS keyword in the command window)
  2. The create class dialog box appears as shown below

  3. In the "class name" text box write ar_DateTime, choose the class type to be based on Visual FoxPro OleControl from the "Based On" drop-down list, write the class library name in the "Store In" text box, and then press OK.
  4. The insert object dialog box appears as shown below.

  5. Select "Microsoft Date and Time Picker Control 6.0" then press OK.
  6. Save the class (Menu Save or the toolbar save button)


Note: You can also add extra functionality to the ar_DateTime class to satisfy your needs.


Samples

This section will help you to easily understand the topics discussed in this paper with a free real examples.

This sections contains two main samples
  1. Simple Arabic sample
    This sample demonstrates how to create Arabic application using Visual FoxPro. This includes a sample configuration file, form and report.
  2. User defined right to left Top-Level menu
    This sample demonstrates how to define your own Arabic right to left menu on a Top-Level form. (For advanced users)
  3. Bilingual English/Arabic class library
    This sample demonstrates how to create a bilingual class library. You can then reuse it in your application. (For advanced users)


How to download and use?

Please follow these simple steps to download the samples and to use it.
  • Simple Arabic sample
    1. To download this sample, click Here.
    2. After download process is completed successfully, unzip AddressBook.zip, and extract the sample files to the chosen folder.
    3. Open Visual FoxPro.
    4. Run the main program of this sample (MainCode.PRG)
  • User defined right to left Top-Level menu
    1. To download this sample, click Here.
    2. After download process is completed successfully, unzip UDMenu.zip, and extract the sample files to the chosen folder.
    3. Open Visual FoxPro.
    4. Run the main program of this sample (MAINAPP.PRG)
  • Bilingual English/Arabic class library
    1. To download this sample, click Here
    2. After download process is completed successfully, unzip Bi_en_ar.zip, and extract the sample files to the chosen folder.
    3. Open Visual FoxPro.
    4. Run the main program of this sample (Bi_En_Ar.prj)
    5. For more details read the associated README.DOC



Conclusion

In this paper you learned about Arabic language support for Visual Foxpro, including information about Arabic language code page setting up the code page and the sort order collating sequence either interactively or programmatically by using the configuration file. Most of Visual FoxPro controls provide an easy way to support Arabic language via the RightToLeft and Alignment properties. You also had access to useful samples.



©2015 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement
Microsoft