PDA

View Full Version : Question/Suggestion for Importer



robertjacobs
2013-03-11, 10:04
Barry

I know sometimes we ask for more than what is possible or even doable. I just recently discoverered you can view program code for SCX files through VFP using Tools - Class Browser and I have to admit it is much easier to read code when all controls (via ADD OBJECT) are contained in the FORM CLASS. However the code generated is not excutable through VFP since container nesting is not supported for ADD OBJECT and Event/Method Procedure names.

Is it possible for Lianja to handle container nesting for ADD OBJECT and Event/Method Procedure names? If not then is it possible for the IMPORTER to only generate DEFINE CLASS for containers? I have played around running VFP Class Browser code in Lianja and it appears to work fine after moving code into containers and properly ordering as per container nesting.

barrymavin
2013-03-11, 10:52
Robert, can you let provide me a small code snippet that demonstrates what you want the importer to achieve. Show me the code vfp is unable to execute exactly.

robertjacobs
2013-03-11, 11:14
Here is a Form containing a Pageframe with 2 controls in Page1. The form and both controls are subclassed. This is the code generated from the Class Browser. The commandsub1 procedure name does not show the nested container.

DEFINE CLASS formsub1 AS formsub

Top = 3
Left = 4
DoCreate = .T.
Caption = "Form2"
Name = "Formsub1"

ADD OBJECT pageframe1 AS pageframe WITH ;
ErasePage = .T., ;
PageCount = 2, ;
Top = 12, ;
Left = 12, ;
Width = 348, ;
Height = 228, ;
Name = "Pageframe1", ;
Page1.Caption = "Page1", ;
Page1.Name = "Page1", ;
Page2.Caption = "Page2", ;
Page2.Name = "Page2"

ADD OBJECT formsub1.pageframe1.page1.labelsub1 AS labelsub WITH ;
Left = 152, ;
Top = 56, ;
Name = "Labelsub1"

ADD OBJECT formsub1.pageframe1.page1.commandsub1 AS commandsub WITH ;
Top = 152, ;
Left = 130, ;
Height = 27, ;
Name = "Commandsub1"

PROCEDURE commandsub1.Click
THISFORM.RELEASE
ENDPROC

ENDDEFINE

robertjacobs
2013-03-11, 11:24
If I change the code to only show the container classes, this runs in Lianja.

define class page1_3qe0t5ay0 as page

** Properties
Caption = "Page1"
Name = "Page1"

ADD OBJECT labelsub1 AS labelsub WITH ;
Left = 72, ;
Top = 48, ;
Name = "Labelsub1"

ADD OBJECT commandsub1 AS commandsub WITH ;
Top = 144, ;
Left = 120, ;
Height = 27, ;
Name = "Commandsub1"

** Methods
PROCEDURE commandsub1.Click
THISFORM.RELEASE

ENDPROC

enddefine

define class page2_3qe0t5ay0 as page

** Properties
Caption = "Page2"
Name = "Page2"

enddefine

define class pageframe1_3qe0t5ay0 as pageframe

** Properties
ErasePage = .T.
PageCount = 0
Top = 12
Left = 12
Width = 348
Height = 228
Name = "Pageframe1"

ADD OBJECT page1 AS page1_3qe0t5ay0
ADD OBJECT page2 AS page2_3qe0t5ay0

enddefine

////////////////////////////////////////////////////////////////////////////////
define class formsub1 as formsub

** Children
add object pageframe1 as pageframe1_3qe0t5ay0

** Properties
DoCreate = .T.
Caption = "Form2"
Name = "Formsub1"

enddefine

barrymavin
2013-03-11, 11:49
Hmm the code generated by the class browser is not exactly readable. It's combining lots of classes together with no define class body for them.

So what you are saying is that vfp can't handle nested ADD OBJECT commands inside container classes as Lianja can. The class browser is treating them as anonymous classes. I'd be interested to see what it does with container methods in these anonymous classes.

i guess my question is, what are you wanting to achieve? Import the scx files into Lianja or run the code that Lianja generates under vfp?

barrymavin
2013-03-11, 11:58
Ah I see now. This is just the way the class browser is generating the code. Vfp in fact is creating the form by reading the scx file.

How vfp creates the form is not how the class browser sees it as they are two different things entirely.

robertjacobs
2013-03-11, 12:02
I not sure what you mean when you say not exactly readable. This first output above creates the smallest code file and you can read it top to bottom. The DEFINE CLASS body for each control is handled in the ADD OBJECT.

*** Are you saying Lianja can handle ADD OBJECT container2.container3.controlname inside container1?

I only want to import SCX into Lianja and move forward from there - I have no interest to run anything through VFP.

robertjacobs
2013-03-11, 12:06
Sorry - I replied just after you did. The Class Browser code is not executable through VFP - It is more intended for source code control.

barrymavin
2013-03-11, 12:20
What I am saying is the class browser is not generating proper class definitions. It is implictly creating objects on the add object command. Anyway, no. That strange syntax of implicitly reference unknown classes is not supported.

ADD OBJECT formsub1.pageframe1.page1.labelsub1 AS labelsub WITH ;
Left = 152, ;
Top = 56, ;
Name = "Labelsub1"

Page1 is not a class it's an implicit object in the pageframe class so it cannot be treated as a class in ADD OBJECT.


So, forget the code the class browser is generating that was an addon written in vfp itself not actually part of the vfp engine.

ok. Can we get back to the original issue you reported and fix the importer so it reads te scx file and generates code that will run under Lianja.

Your original issue is to do with the beautifier is that correct?

barrymavin
2013-03-11, 12:24
Well that's not surprising looking at what it generated.

What we need to do is solve the forward referencing of classes is that correct?

(sorry about the typos I'm on my iPad)

robertjacobs
2013-03-11, 12:47
The problem right now with the IMPORTER using the above example is it does not ADD OBJECT for the container controls (i.e. the 2 controls in page1).

How about the second code example which at the minimum generates a DEFINE CLASS for each container for which all control's PEM are coded within. This works in Lianja.

robertjacobs
2013-03-11, 12:52
Barry

I should point out that I am only looking for the easiest way to read code. IMO but I like it when control PEMs are coded inside the parent container. Of course all this means nothing if someday someone can provide a visual form designer.

barrymavin
2013-03-11, 12:53
Robert, zip up the scx file so we can take a look at it. If the classes are defined in it then it should generate the code for them. If they are just implicit it will not.

Zip it up and submit as a ticket and we will take a look. It wi t be fixed for RC4 as I am expecting to release that within a day or so.

robertjacobs
2013-03-11, 12:57
I will zip them to the ticket already open for this issue.

barrymavin
2013-03-11, 21:21
Robert, after we release RC4 I will take a further look at the importers and put the source code on LianjaX so that anyone can work on them with me as these are all written in the Lianja/VFP scripting language. I will merge the changes if they make sense to me otherwise it can be forked by anyone interested.

My intention is to enhance the importers so that:

1. They handle forward class references properly without you having to move the class definitions around manually
2. They (optionally) can import an scx and create a page which has the VFP scx embedded into a "Custom" section on the page. This page can (optionally) be added to the "UI Page library" which will make all imported forms available using Lianja.showDialog() so they can be properly integrated in with your Lianja App. You may not have seen UI page libraries yet as they are in RC4.

The process for importing would be:

1. Create a new app called "MyFormLibrary"
2. Import the scx files
3. They will be added to the app and (optionally) added to the UI page library. This allows you to edit the custom section, tweak it, theme it with CSS etc, and then resave it in the UI page library.

You would then create a simple "startup" app with one page that is displayed when your app is run. From there you can show the required pages based on whatever UI you dream up. RC4 has support for "inline" delegates so to show a UI page (containing your VFP .scx) it is simply a matter of specifying an inline delegate (on a CommandButton for example) for the "click" delegate as $("showdialog:form1") which will popup a window with your form1.scx file embedded in it. Note that you could design this "startup" page using a canvas section and use CSS to apply a style to the buttons e.g. gradients, rounded corners etc.

I'm still looking into the issue you ticketed regarding the windows taskbar showing an icon for each window; I did get this working but it was behaving differently on Linux and the Mac so I will revisit this. I expect to be able to get around this issue, bear with me.