Code Quartering Feature for December 2010 Newsletter

Moderators: Phil Winkler, Graham Smith, Pete Tabord

Code Quartering Feature for December 2010 Newsletter

Postby Adrian Jones » Thu Dec 09, 2010 5:44 pm

Hi All,

in my next newsletter, I show you how to chop to a quarter its size procedure such as the 83 lines of DQL below. It's now a mere 21 lines.

Using a documented but undiscussed feature of DE-Ff that's been around since 6.5.

And it's a lot easier to iron out glitches.

If you're not already getting my newsletter, sign up now at http://www.n10net.com. I regularly explore the nooks and crannies of both DataEase (for Windows) and Ffenics.

The first. So far, the only!

I'll be sending this out mid next week.

---

How to prune this code down to almost a quarter:

Code: Select all
define "tForm1"   text 100 .
define "tForm2"   text 100 .
define "tFld11"   text 100 .
define "tFld12"   text 100 .
define "tFld21"   text 100 .
define "tFld22"   text 100 .
define "tFld13"   text 100 .
define "tFld23"   text 100 .
define "tRela1"   text 100 .
define "tRela2"   text 100 .

for System Relationships ;
  tForm1 := Form 1 .
  while textpos ( tForm1 , "." ) > 0 do
    tForm1 := concat ( firstc ( tForm1 , textpos ( tForm1 , "." ) -1 ) , " " , midc ( tForm1 , textpos ( tForm1 , "." ) + 1 , 255 ) ) .
  end
  tForm1 := proper ( lower ( tForm1 ) ) .
  tForm1 := stripchar ( tForm1 , " " ) .

  tForm1 := Form 2 .
  while textpos ( tForm2 , "." ) > 0 do
    tForm2 := concat ( firstc ( tForm2 , textpos ( tForm2 , "." ) -1 ) , " " , midc ( tForm2 , textpos ( tForm2 , "." ) + 1 , 255 ) ) .
  end
  tForm2 := proper ( lower ( tForm2 ) ) .
  tForm2 := stripchar ( tForm2 , " " ) .

  tFld11 := Field 1.1 .
  while textpos ( tFld11 , "." ) > 0 do
    tFld11 := concat ( firstc ( tFld11 , textpos ( tFld11 , "." ) -1 ) , " " , midc ( tFld11 , textpos ( tFld11 , "." ) + 1 , 255 ) ) .
  end
  tFld11 := proper ( lower ( tFld11 ) ) .
  tFld11 := stripchar ( tFld11 , " " ) .

  tFld12 := Field 1.2 .
  while textpos ( tFld12 , "." ) > 0 do
    tFld12 := concat ( firstc ( tFld12 , textpos ( tFld12 , "." ) -1 ) , " " , midc ( tFld12 , textpos ( tFld12 , "." ) + 1 , 255 ) ) .
  end
  tFld12 := proper ( lower ( tFld12 ) ) .
  tFld12 := stripchar ( tFld12 , " " ) .

  tFld21 := Field 2.1 .
  while textpos ( tFld21 , "." ) > 0 do
    tFld21 := concat ( firstc ( tFld21 , textpos ( tFld21 , "." ) -1 ) , " " , midc ( tFld21 , textpos ( tFld21 , "." ) + 1 , 255 ) ) .
  end
  tFld21 := proper ( lower ( tFld21 ) ) .
  tFld21 := stripchar ( tFld21 , " " ) .

  tFld22 := Field 2.2 .
  while textpos ( tFld22 , "." ) > 0 do
    tFld22 := concat ( firstc ( tFld22 , textpos ( tFld22 , "." ) -1 ) , " " , midc ( tFld22 , textpos ( tFld22 , "." ) + 1 , 255 ) ) .
  end
  tFld22 := proper ( lower ( tFld22 ) ) .
  tFld22 := stripchar ( tFld22 , " " ) .

  tFld13 := Field 1.3 .
  while textpos ( tFld13 , "." ) > 0 do
    tFld13 := concat ( firstc ( tFld13 , textpos ( tFld13 , "." ) -1 ) , " " , midc ( tFld13 , textpos ( tFld13 , "." ) + 1 , 255 ) ) .
  end
  tFld13 := proper ( lower ( tFld13 ) ) .
  tFld13 := stripchar ( tFld13 , " " ) .

  tFld23 := Field 2.3 .
  while textpos ( tFld23 , "." ) > 0 do
    tFld23 := concat ( firstc ( tFld23 , textpos ( tFld23 , "." ) -1 ) , " " , midc ( tFld23 , textpos ( tFld23 , "." ) + 1 , 255 ) ) .
  end
  tFld23 := proper ( lower ( tFld23 ) ) .
  tFld23 := stripchar ( tFld23 , " " ) .

  tForm1 := Form 1 .
  while textpos ( tRela1 , "." ) > 0 do
    tRela1 := concat ( firstc ( tRela1 , textpos ( tRela1 , "." ) -1 ) , " " , midc ( tRela1 , textpos ( tRela1 , "." ) + 1 , 255 ) ) .
  end
  tRela1 := proper ( lower ( tRela1 ) ) .
  tRela1 := stripchar ( tRela1 , " " ) .

  tForm1 := Form 1 .
  while textpos ( tRela2 , "." ) > 0 do
    tRela2 := concat ( firstc ( tRela2 , textpos ( tRela2 , "." ) -1 ) , " " , midc ( tRela2 , textpos ( tRela2 , "." ) + 1 , 255 ) ) .
  end
  tRela2 := proper ( lower ( tRela2 ) ) .
  tRela2 := stripchar ( tRela2 , " " ) .

  modify records
    Form 1 := tForm1 ;
    Form 2 := tForm2 ;
    Field 1.1 := tFld11 ;
    Field 2.1 := tFld21 ;
    Field 1.2 := tFld12 ;
    Field 2.2 := tFld22 ;
    Field 1.3 := tFld13 ;
    Field 2.3 := tFld23 ;
    relationship 1 := tRela1 ;
    relationship 2 := tRela2 .       
end
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Code Quartering Feature for December 2010 Newsletter

Postby Adrian Jones » Mon Dec 13, 2010 5:38 pm

PS: scheduled to go out on Thursday morning...
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 

Re: Code Quartering Feature for December 2010 Newsletter

Postby Graham Smith » Fri Dec 17, 2010 3:31 pm

I recall when this came out but promptly forgot about it because it was buggy (GPF'd a lot) and I couldn't think of a use for it. It seems you have found part of the problem, but it would seem that there's more to it than just invoking the DQL Scheduler. Look at the following three code examples:
Code: Select all
procedure text XXX ()
  if 1 then end .
  return "Hello World" .
end .

for FormName ;
list records
   XXX () .
end .
Code: Select all
if 1 then end .

procedure text XXX ()
  return "Hello World" .
end .

for FormName ;
list records
   XXX () .
end .
Code: Select all
procedure text XXX ()
  return "Hello World" .
end .

if 1 then end .

for FormName ;
list records
   XXX () .
end .

All three of these invoke the DQL Scheduler but only the first two work.

Now if I can just find something to do with this...

---------------------------
BTW, here's my solution to your Relationship problem. Since case does not matter in Relationships, export the data to a text file and use Notepad to search and replace . with nothing then re-import the data. But the DQL does make a good example of how to use Procedure () :wink:
Graham Smith
DataSmith, Delaware
"For every expert there is an equal and opposite expert.", Arthur C. Clarke (1917 - 2008)
"X-Clacks-Overhead: GNU Terry Pratchett"
User avatar
Graham Smith
 
Posts: 2501
Joined: Fri Sep 07, 2007 11:31 am
Location: Delaware, USA
Has thanked: 0 time
Been thanked: 1 time
 

Re: Code Quartering Feature for December 2010 Newsletter

Postby Adrian Jones » Wed Dec 22, 2010 5:15 pm

Hi Graham,

Good observations!

I'm really just trying this idea out, throwing out there to see if anything sticks.

We have all these weapons in our armoury. Might as well fire off a few rounds to see what damage they can do!
User avatar
Adrian Jones
 
Posts: 2000
Joined: Tue Sep 11, 2007 2:38 pm
Location: Cornwall, UK
Has thanked: 5 times
Been thanked: 4 times
 
 

Return to Blatant Advertising

Who is online

Users browsing this forum: No registered users and 2 guests