Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Include Header Files Problem
Message
From
08/06/2001 06:21:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/06/2001 05:21:58
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00516780
Message ID:
00516794
Views:
8
This message has been marked as a message which has helped to the initial question of the thread.
>Hi all,
>
>I tried to define some class in a header file and use them in another program, however, I've some problem..
>
>FormDefine.h
>
>define class oForm as form
>  autocenter=.T.
>  caption="Testing"
>
>  procedure queryunload
>    clear event
>  endproc
>enddefine
>
>
>and in CallForm.prg
>
>#include FormDefine.h
>
>TestForm=createobject("oForm")
>TestForm.show
>read events
>
>
>Then I have error message: "Class definition oForm is not found."
>
>What did I do wrong? I'd really hate to have 2-3k lines in my program.. <g>
>Thank a lot!

Jimi,
Include puts content as is to the place it called (as if you pasted contents there). BUT only directives are recognized in a header file and commands are ignored. Thus it can't see the definition there.

If you use VFP6 then :
Put your class definitions in a separate file (it might be 'FormDefine.h' but better have the extension .prg). And call like this :
TestForm=NewObject("oForm","FormDefine.prg")
TestForm.show
read events
If VFP5 or 3 then :
if !'FORMDEFINE.PRG'$set('PROCEDURE')
 set procedure to FormDefine additive
endif
TestForm=NewObject("oForm","FormDefine.prg")
TestForm.show
read events
If you keep group of classes in the same file then having extra 2-3 lines at startup places wouldn't harm you :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform