Showing posts with label VFP. Show all posts
Showing posts with label VFP. Show all posts

Networking Visual FoxPro Database by Brute Force

There are variety of ways in networking databases in Visual FoxPro and today we will learn how to do it by brute force...Hopefully...

Preliminaries...

1. Ensure that you have a functional Local Area Network. For instance, if you want your PHONE DIRECTORY SYSTEM in StationA to be accessed in StationB, the first thing that you need to do is to start command prompt and ping StationB. Once you receive four packets response then both computers have working network connections. Additionally, make sure that both computers have file and printer sharing enabled.

2. Once network connection testing is complete and successful,you should now prepare your PHONE DIRECTORY SYSTEM for networked environment. Alter your source code and make sure that you have included the SHARED alias in your USE TABLE_NAME command. For instance, if your primary table is TFOXPHONEDIR, modify USE TFOXPHONEDIR to USE TFOXPHONEDIR SHARED. This will enable your table to be manipulated in a networked-based environment. Don't forget to save changes.

Almost there...

3. Next, create a program superlauncher for the first form of your PHONE DIRECTORY SYSTEM. To do this, press CTRL + F2 then type MODI COMM SUPERLAUNCHER in the command window. This command performs two things. It creates a Visual FoxPro program named superlauncher.prg and it displays the Visual FoxPro editor. Type the following in the FoxPro editor textarea:

DO FORM FIRSTFORMNAME

Don't forget to replace FIRSTFORMNAME with the actual firstname of your first form. For example if the filename of your first form is LOGINFORM.SCX, replace DO FORM FIRSTFORM with DO FORM LOGINFORM. CLick close to save changes.

4. Now, share the Microsoft Visual Studio Folder. This will enable your system to be available to all clients in the network, assuming that all your forms and databases are located inside the Visual Studio directory.

The finale...

5. To access your PHONE DIRECTORY SYSTEM in StationB or in any workstations in the network, browse your network places and locate your shared Microsoft Visual Studio folder. Look for your superlauncher.prg then double-click it.

6. In similar manner, double-click superlauncher.prg in StationA.You should now have phone directory systems activated in separate computers at the same time.

7. Though you are using the same form, it can perform independent actions in each workstations. To test your system, perform a record search in StationA, while one of your pals edits a record in StationB. Notice how it worked perfectly as mentioned. And that's all, a simple database networking  by brute force in VFP just for you.

ISAPLHA and ISDIGIT functions in Visual FoxPro 9

ISALPHA function is one of the powerful functions in Visual FoxPro 9 that can be used to test if the inputted data is a string or character. By default, ISALPHA has a false value and returns a true value when the Expression is a string data. It is very helpful in filtering illegal inputs:

Syntax:
ISALPHA(Expression)

Where;
1. Expression can be a variable, a text, or a control. ISAPLHA can be entered in any capitalization.

Examples:
ISALPHA(“John”)
ISALPHA(strname)
ISALPHA(Thisform.NameTextbox.Value)

To see ISALPHA in action, follow these steps:

1. Click Start>All Programs>Microsoft Visual FoxPro 9.0.
2. Click File>New>Form>New File.
3. Design your interface as follows:



4. Double-click the control named OkButton then enter the following codes:



5.Press F5 to test our sample application.

Another useful input validation function in Visual FoxPro 9.0 is the ISDIGIT function. It works like ISNUMERIC function in PHP wherein it allows you to test whether the input is a numeric data. Just like the ISALPHA function, the default value of is numeric function is false and it returns true whenever the contents of the expression is a numeric value.

Syntax:
IDIGIT (Expression)

Where;
1. Expression can be a variable, a number, or a control. ISDIGIT can be entered in any capitalization.

Examples:
ISDIGIT (“John”)
ISDIGIT (intage)
ISDIGIT (Thisform.AgeTextbox.Value)

The following example demonstrates the capability of ISDIGIT function:

1. Click Start>All Programs>Microsoft Visual FoxPro 9.0.
2. Click File>New>Form>New File.
3. Design your interface as follows:



4. Double-click the OkButton then enter the following:



5. Press F5 to test our sample application.

Those are the two powerful input validation functions in Visual FoxPro 9. Hope you learn something from it. Till next time.

Microsoft Visual FoxPro 6.0 Printing (The FoxPro For DOS way)

One of the most important features that a good database system should have is its ability to generate printed reports. In this tutorial we will learn how to print the contents of a Visual FoxPro from…the good old FoxPro for DOS way. Actually there is another way, the one that involves using Advanced Programmers Interface or API but since I hate to complicate simple things, we will be using the easiest way, the DOS way.For the sake of example, we will use the form below, actually it’s not a form…it’s a sketch. But in this tutorial, I would like you to think of it as a real form. Just for now, okay?


OUR FORM



What we have here, ladies, is a form with two labels (Name and Last name) and two textboxes beside each labels. Of course don’t forget those tiny buttons named Print and Exit. Let us make up a name for the print button because that’s the object where we will place our codes later on, let’s call it Print… what do you think?So our aim here is…if the user runs the form and types a text on those textboxes, and clicks the Print button, whatever ever text that was entered by the user will be sent onto the printer. Of course it is only possible if we attach a code onto the Print button. To do that, double click the Print button in the design time then type the following codes in the click procedure event.


SET CONSOLE OFF
//The text that is being printed will appear on the screen if
//you turn this ON, you don’t want that, wont you?
SET PRINTER ON
//Send the text onto the printer.
? ThisForm.Text1.Text''
//The question mark symbol displays our text on a new line while
//ThisForm.Text1.value indicates the source of the text that will be sent onto the
//printer, in this case, it’s text1 or the textbox beside the name label.
? ThisForm.Text2.Text
//Prints the contents of text2 or the textbox beside the Last name label.
Wait Window ‘Please wait…Printing’
//Some Hollywood special effects
SET PRINTER OFF
//If you turn it ON, you should also know how to turn it off…Good Boy.
And that’s it. No Sweat. We are done. If you have 10 textboxes in your form then just add ? Thisform.text3.text, ?Thisform.text4.text, and so on. It is just that simple and you don’t have to be good –looking and rich to do that. Let us have a quick glance at those codes again…



SET CONSOLE OFF
SET PRINTER ON
? ThisForm.Text1.Text
? ThisForm.Text2.Text
Wait Window ‘Please wait…Printing’
SET PRINTER OFF
You can copy, paste and edit these codes Just don’t forget to thank me. You can send me some love letters too.