1. Separating Code

I'd like to organize my code differently for a current project, and I'm wondering how to go about doing it.

Ultimately, what I'd like to do is something like this:

include wxeud.e 
 
include myFrame.ew        -- defines the primary frame as well as multiple dialogs 
include frame_controls.ew -- uses the frame defined in myFrame.ew 
include dlg_controls_1.ew -- uses dlg_1 defined in myFrame.ew 
include dlg_controls_2.ew -- uses dlg_1 defined in myFrame.ew 
-- etc... 
 

In each of the "dlg_controls_X.ew" files, it contains the definition for the dialog's controls and the associated event handlers.

Is there even a way to do this with Euphoria? If not, I'm imagining an "import" directive that plops the imported code straight into the code as though it were there to start with.

Matt, how do you wrangle a large wxEuphoria project?

Thanks!

new topic     » topic index » view message » categorize

2. Re: Separating Code

euphoric said...

I'd like to organize my code differently for a current project, and I'm wondering how to go about doing it.

Ultimately, what I'd like to do is something like this:

include wxeud.e 
 
include myFrame.ew        -- defines the primary frame as well as multiple dialogs 
include frame_controls.ew -- uses the frame defined in myFrame.ew 
include dlg_controls_1.ew -- uses dlg_1 defined in myFrame.ew 
include dlg_controls_2.ew -- uses dlg_1 defined in myFrame.ew 
-- etc... 
 

In each of the "dlg_controls_X.ew" files, it contains the definition for the dialog's controls and the associated event handlers.

Is there even a way to do this with Euphoria? If not, I'm imagining an "import" directive that plops the imported code straight into the code as though it were there to start with.

Matt, how do you wrangle a large wxEuphoria project?

What you have looks fine. I'm assuming that you'll have some code that several of those files will want to use. Put that in its own file, and include it wherever you need it.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: Separating Code

We did use predefined code for common tasks in an include file.
Here is a function created for setting up labels (text,size, colour, font, etc.) in multiple grids within one window.
As you can see, it becomes fairly large and complex to allow for many variables in a major work, but it does work well enough to ease the life of the next person to use it. We never measured the speed deterioration, if any.
This work was done by a student before we changed to shortened version of wxEuphoria.

global function StartLbl (atom qGrid,atom qWhichGrid) 
--  
-- Submitted by: __________________________________ 
--  
-- Assignment: 
-- Create a common module for setting labels to multiple grids in a Window. 
-- Assume that the Window and Grids are already defined.  
-- Extract the appropriate Label parameters from the related sequences 
-- Allow for adding own label or not adding a label 
-- Use the defined two dimentional sequences for Label size, colour and text 
-- Optionally redefine them, if you want to. 
-- Label size, colour, default row and column size, colour and font should be set. 
-- Also initialize the defualt cell colors and initialise the cell sizes, and label and cell fonts 
-- 
-- Use AllLabSz, AllLabClr, AllLabFont, AllCellDefSz, AllCellDefClr 
-- DO NOT USE AllCellSz, AllCellClr, AllCellFont, AllCell Txt here 
-- THOSE WILL BE USED IN  FUNCTION StartCell LATER. 
-- 
-- Row and column count 
  atom qRowCt,qColCt,qMaxRow,qMaxCol,qFill,qCellDefFont 
  qRowCt = get_number_rows( qGrid )  
  qColCt = get_number_cols( qGrid ) 
  sequence qLabTxt = AllLabTxt[qWhichGrid]    
  sequence qLabSz=AllLabSz[qWhichGrid] 
  sequence qLabClr=AllLabClr[qWhichGrid] 
  sequence qLabTxtR=qLabTxt[1] 
  sequence qLabTxtC=qLabTxt[2] 
  atom qLabFont=AllLabFont[qWhichGrid] 
  sequence qCellDefSz=AllCellDefSz[qWhichGrid] 
  sequence qCellDefClr=AllCellDefClr[qWhichGrid] 
-- Row and colunm Default Lable and Cell sizes 
  set_row_label_size( qGrid, qLabSz[1] )  
  set_col_label_size( qGrid, qLabSz[2] )  
  set_default_row_size( qGrid, qCellDefSz[1], 1 ) 
  set_default_col_size( qGrid, qCellDefSz[2], 1 )  
-- Row and colunm Default Label and Cell colours and fonts 
  set_grid_label_text_color(qGrid,qLabClr[1] ) 
  set_grid_label_background_color(qGrid, qLabClr[2] ) 
  set_default_cell_text_color( qGrid, qCellDefClr[1] ) 
  set_default_cell_background_color( qGrid, qCellDefClr[2] ) 
  set_grid_label_font( qGrid, qLabFont) 
  set_default_cell_font(qGrid,qLabFont) 
-- Label Text if available, other wise it will be 1-100 and A-Z defaults of Grid 
  if length(qLabTxtR[1]) < 2 then  -- Do not change the row labels if Row labels do not exist 
    qMaxRow = qRowCt 
  else 
    qMaxRow=length(qLabTxtR)  
    if qMaxRow>qRowCt then -- Can't allow more rows than maximum grid size 
      qMaxRow=qRowCt  
    end if 
-- Fill defined Row labels with supplied text 
    for i = 0 to qMaxRow-1 do 
      set_row_label( qGrid, i, qLabTxtR[i+1] )   
    end for 
    qFill=qRowCt-qMaxRow 
-- Fill undefined Row labels with Blanks 
    for i = qMaxRow to qFill-1 do 
      set_row_label( qGrid, i, " ")   
    end for 
  end if 
  if length(qLabTxtC[1]) < 2 then  -- Do not change the row labels if Row labels do not exist 
    qMaxCol=qColCt  
  else 
    qMaxCol=length(qLabTxtC)  
    if qMaxCol>qColCt then -- Can't allow more columns than maximum grid size 
      qMaxCol=qColCt  
    end if 
-- Fill defined Column labels with supplied text 
    for i = 0 to qMaxCol-1 do 
      set_col_label( qGrid, i, qLabTxtC[i+1] )   
    end for 
    qFill=qColCt-qMaxCol 
-- Fill undefined Column labels with Blanks 
    for i = qMaxCol to qFill-1 do 
      set_col_label( qGrid, i, " ")   
    end for 
  end if 
-- Retrun pairs of derived information. 
  sequnece qReturn ={ {qGrid,qWhichGrid }, {qRowCt,qColCt},{qMaxRow,qMaxCol}, {qLabFont,qLabFont} } 
  return qReturn 
end function 
 
 
new topic     » goto parent     » topic index » view message » categorize

4. Re: Separating Code

Vinoba said...

Here is a function created for setting up labels (text,size, colour, font, etc.) in multiple grids within one window.

Relevance?

new topic     » goto parent     » topic index » view message » categorize

5. Re: Separating Code

jimcbrown said...
Vinoba said...

Here is a function created for setting up labels (text,size, colour, font, etc.) in multiple grids within one window.

Relevance?

This was a teaching assignment in a computing class teach/learn about programming in a low level language using a modern sophisticated Windows interface. The details of the relevance are there in the initial part of the assignment for anybody to read. It and other modules were used by the students to create something that they all used during the sessions in the class class.

It was my decision as their teacher to give them this exercise for learning, and showing me their ability to program and create and understand Windows. And yes, it was part of the "separating code", the topic of this thread.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Separating Code

Vinoba said...

The details of the relevance are there in the initial part of the assignment for anybody to read...it was part of the "separating code", the topic of this thread.

So, this was intended as an example to demonstrate another method that euphoric (or another reader of the forum) could try out?

new topic     » goto parent     » topic index » view message » categorize

7. Re: Separating Code

jimcbrown said...
Vinoba said...

The details of the relevance are there in the initial part of the assignment for anybody to read...it was part of the "separating code", the topic of this thread.

So, this was intended as an example to demonstrate another method that euphoric (or another reader of the forum) could try out?

I am not postulating anything new here. The question before us in this thread was whether or not somebody could set up some predefined Windows, Controls, Events, and Functions and use them repeatedly.
I just showed what we did in a class. Buddies (two together) were given a specific separate assignment each in a project of about 20 sections, and this was one of the submissions from one of the twenty buddies. In teaching programming I find the buddy system best. We create a substantial project, execute it and then discuss everything with each section describing their approach and their achievement and are subjected to some intensive (sometimes ridiculous) questioning by the others. It gives me a chance to assess the students in a very comprehensive manner.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Separating Code

Vinoba said...

I am not postulating anything new here. The question before us in this thread was whether or not somebody could set up some predefined Windows, Controls, Events, and Functions and use them repeatedly.

Not quite. The question involved an element of scoping and include file organization, which your answer did not seem to address.

But, I admit, your answer was relevant to part of the question asked.

Vinoba said...

I just showed what we did in a class. Buddies (two together) were given a specific separate assignment each in a project of about 20 sections, and this was one of the submissions from one of the twenty buddies. In teaching programming I find the buddy system best. We create a substantial project, execute it and then discuss everything with each section describing their approach and their achievement and are subjected to some intensive (sometimes ridiculous) questioning by the others. It gives me a chance to assess the students in a very comprehensive manner.

Sounds plausible.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu