Home | Careers | IT Counseling | IT Jobs | IT Resources

 

 

 
About Us | Advertise | Feedback | Contact Us | Bookmark this page now|
Have any doubts regarding how to Search IT Training Courses?...Click here for Quick Search Tips Search IT Courses
Have any doubts regarding Keyword Search?...Click here for Quick Search Tips keyword
Have any doubts regarding Institutes Search?...Click here for Quick Search Tips institutes
Have any doubts regarding Specialization Search?...Click here for Quick Search Tips specialization
Have any doubts regarding Fees Search?...Click here for Quick Search Tips fees
to
Have any doubts regarding Duration Search?...Click here for Quick Search Tips duration

IT dart Tips

Which IT course ?

Venture Capital

Online Education

Exams Required for US of A

Overview of Admission Process

Test Preparation

Financial Aid

TOEFEL Examination

Cool Interview Tips

Skill Check

Resume

GRE Examination

GMAT Examination


IT dart News Letter
Get ITdart.com weekly headlines before it's published on our site! Subscribe and receive the articles delivered to your inbox!

Creating an array of structures in VFP

The C languages provide for different datatypes to be defined as a part of a single structure, and then an array can be defined based upon that structure. Visual FoxPro allows you to implement this functionality using the

CUSTOM classes. To define a custom class in VFP you have to use the following syntax:

* Class definition
define class Myclass as custom
* Properties
color = "Blue"
status = "Active"
* Methods
function Myvalidation
* Some code...
endfunc
enddefine
Here you can define properties as well as methods for the class. Properties, when defined, behave like structure for an instance of the class. You can declare an array which contains instances of the class. This simulates the exact functionality of an array of structures.

The following code sample illustrates how to define an array of structures. The structure itself is defined in a custom class called sMyStruct. The code reads the values from the Products table and populates the array of structures.

open database C:\VFP\SAMPLES\DATA\TESTDATA.DBC
use C:\VFP\SAMPLES\DATA\PRODUCTS.DBF
go top && Start from the top
* Define the array of structures
public dimension oMyStruct(10)
for i=1 to 10
oMyStruct(i)=createobject("sMyStruct")
oMyStruct(i).Product_Name=PRODUCTS.Prod_name
oMyStruct(i).Engineer_Name=PRODUCTS.Eng_name
oMyStruct(i).Cost_Per_Unit=PRODUCTS.Unit_cost
?oMyStruct(i).Product_Name
?oMyStruct(i).Engineer_Name
?oMyStruct(i).Cost_Per_Unit
skip
endfor
define class sMyStruct as custom
Product_Name=''
Engineer_Name=''
Cost_Per_Unit=0
enddefine
This provides flexibility of the arrays and the structured data access of VFP classes. As each item in the array is a fully functional instance of the class, this is more than just an array of structures. It is an active array of structures, because each element in the array can also have methods invoked. In addition, the properties can have assign and access method code that can run automatically when an element is read or changed.

Thus an array of object instances is a very powerful data structure. Consider that VFP allows each element in the array to be of different datatype. This means each element in an array could be an instance of a different class. Imagine the flexibility!

One Click Courses

Advanced Certiflcate in Java Application Development

Advanced Cisco Router Conflguration

Advanced Course in Object Oriented Programming (Coop)

C#

C# with ASP.Net

CAD/ CAM

Certfication in Unix, C, C++ (CUCC)

Certificate in Advanced System Programming

Certificate in Java & E-commerce (CJEC)

EI -Strategiest

Object Oriented Developer and Designer

Specialization in 3D Graphics & Animation

Wap@Asset


Firewalls: What To Block

Windows System Architecture (WSA)

Operating System (OS)

Data Access Technologies

Functional menu-level blocking

Data Access Methodologies

ODBC Architecture

Learn Java from the ground up

Internet Security

The Day I Learnt JavaScript



ITdart Updates:
Computer Security | Computer Services | CRM | Database | E Commerce | Graphic & Design | Internet | Java | Knowledge Management | Linux | Online Marketing | Open Source | Operating System | Robotics | Semi Conductors | Software Downloads | Virus Info | WAP & 3G | Web Development | XML and Metadata
Home | Careers | IT Counseling | IT Jobs | IT Resources

© Copyright 1999-2000 ITdart.com. All rights reserved.
All brands are Trade Marks of Respective owners. Disclaimer    Legal    Privacy Policy