Page Index Toggle Pages: [1] 2 3  Send Topic Send Topic Print Print
Very Hot Topic (More than 25 Replies) Using Pipes in Retrieve Specs (Read 3856 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Using Pipes in Retrieve Specs
Sep 19th, 2007 at 10:53am
Print Post Print Post  
In another thread, Erika wrote:
Quote:
use ">|@Date - 30|" .... It will also run faster than your programmed retrieve spec.


Hi Erika!

I remember you mentioning this at the conference, and I made a note that it was important to me, but I've forgotten just how and in what instances Piping should be used.  Can you explain its use in a bit more detail?

Is it just for date calculations?  Should I place pipes around all my date manipulations (and by all I mean form programming as well as report programming)?  Would it serve any purpose in a programming calculation such as:
Code
Select All
Invoice_Age = @ToNumber(@Date) - @ToNumber(Invoice_Date) 


or a report calculation such as:
Code
Select All
Var MonthTotal as Double
MonthTotal = @ToMoney(@XLookup("MonthTotals.db", @Year(@Date) - 1, "Year", @Month$(@Date)))
Last_Year = "Last year's total for " + @Month$(@Date) + " was:  $" + @STR(MonthTotal) 


Or is it just for retrieve specs?  Here's one I use to retrieve this month's invoices:
Code
Select All
{@Year(Invoice_Date) = @Year(@Date) AND @Month(Invoice_Date) = @Month(@Date)} 


How would piping be used on that?  Is it as simple as replacing the curly braces?

Thanks!
« Last Edit: Sep 19th, 2007 at 2:13pm by Hammer »  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Piping
Reply #1 - Sep 19th, 2007 at 11:18am
Print Post Print Post  
Scott,

This is only for retrieve specs.

You can use it on any programming statement that does not refer to a record value, such as @Date, @UserID, etc.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Piping
Reply #2 - Sep 19th, 2007 at 11:28am
Print Post Print Post  
Quote:
{@Year(Invoice_Date) = @Year(@Date) AND @Month(Invoice_Date) = @Month(@Date)}

You can't use the pipe for this because it refers to a record value - Invoice_Date. I believe there is a way to construct a retrieve that will work. I'm not where I can test though. I'll try to post it later.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Piping
Reply #3 - Sep 19th, 2007 at 12:59pm
Print Post Print Post  
Hello Scott,

If you put the following in the Invoice Date element it will do the same thing as your programmed retrieve, but faster.

Code
Select All
]|@Year(@Date)|/|@Right("00" + @Str(@Month(@Date)), 2)|/.. 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Piping
Reply #4 - Sep 19th, 2007 at 1:25pm
Print Post Print Post  
Holy guacamole, what the heck is that?  But hey, it works.  Can you explain it to me?  And where should I put the "-1" for 1) Last month's and 2) last year's.

Thanks Ray!
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Piping
Reply #5 - Sep 19th, 2007 at 1:27pm
Print Post Print Post  
I can make sense out of all of it except "@Right("00" + @Str(@Month(@Date)), 2)".

Note to interested onlookers:  Do not do this:
Code
Select All
]|@Year(@Date)|/|@Right("00" + @Str(@Month(@Date)), 2)-1|/.. 




  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Piping
Reply #6 - Sep 19th, 2007 at 1:38pm
Print Post Print Post  
@Right("00" + @Str(@Month(@Date)), 2) pads the month number out to two places. A date is stored as YYYY/MM/DD, where MM is the month. For September it is stored as 09 but @Month simply returns 9 so we need the other zero before it, so that the retrieve works.

Last month is tricky as last month may have been December and subtracting 1 from 1 does not give you 12 nor does it give you the right year. It's gonna be a tricky statement.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Piping
Reply #7 - Sep 19th, 2007 at 1:40pm
Print Post Print Post  
This got me August's:
Code
Select All
]|@Year(@Date)|/|@Right("00" + @Str(@Month(@Date)-1), 2)|/.. 


But I see what you mean about December.  Hmmm.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Piping
Reply #8 - Sep 19th, 2007 at 1:41pm
Print Post Print Post  
Explanation:

] <-This character makes it a string search instead of a date search

|@Year(@Date)| <- This gets the current year

/ <-This inserts a slash into the criteria

|@Right("00" + @Str(@Month(@Date)), 2)| <-This gets the month number padded to two numbers as described above

/.. <-This inserts a slash and then dot dot for any day in that month

So what you end up with(If you look at it after the compiler) is

]2007/09/..

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Piping
Reply #9 - Sep 19th, 2007 at 1:43pm
Print Post Print Post  
I think this will give you last months

Code
Select All
]|@Year(@Date-@DOM(@Date))|/|@Right("00" + @Str(@Month(@Date-@DOM(@Date))), 2)|/..  



-Ray
« Last Edit: Sep 19th, 2007 at 3:22pm by Ray the Reaper »  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Piping
Reply #10 - Sep 19th, 2007 at 1:44pm
Print Post Print Post  
For all of last year it would be

Code
Select All
]|@Year(@Date)-1|/.. 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Piping
Reply #11 - Sep 19th, 2007 at 1:58pm
Print Post Print Post  
Wow, you are amazing.  The one for last month nicely retrieves August.  I'll put it in play and see what happens in January.  Thanks Ray!
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Piping
Reply #12 - Sep 19th, 2007 at 2:09pm
Print Post Print Post  
I've been having fun with these; I've crashed Sesame 4 times because I've put the math in the wrong places.  But when the smoke cleared:

This month last year
Code
Select All
]|(@Year(@Date-@DOM(@Date))-1)|/|@Right("00" + @Str(@Month(@Date)), 2)|/..   



Last month last year
Code
Select All
]|(@Year(@Date-@DOM(@Date))-1)|/|@Right("00" + @Str(@Month(@Date-@DOM(@Date))), 2)|/..   



I now have a nice little library of programmed retrieves that make use of piping and are not tied to an element.  Thanks Ray and Erika!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Piping
Reply #13 - Sep 19th, 2007 at 2:12pm
Print Post Print Post  
Can you send us one that crashes? We'd like to intercept whatever evil is caused if you put the math in the wrong place. Please send it to Support as opposed to posting it here. I don't want to confuse someone who is skimming.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Using Pipes in Retrieve Specs
Reply #14 - Sep 19th, 2007 at 2:15pm
Print Post Print Post  
Well, one is already posted above as something not to do.  I'll mail the others.
  

**
Captain Infinity
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 3 
Send Topic Send Topic Print Print