CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Search 'Between' issues

 



compbugs
New User

Oct 27, 2011, 9:49 AM

Post #1 of 6 (2762 views)
Search 'Between' issues Can't Post

I am trying to create a 'Housing Report' that searches only A-pod through E-pod, but cannot include B-pod for billing purposes.


So what I am trying to do is get results from a 'between' search and another 'between' search of the same table. I would be open to a 'between' search less a 'between' search also.

My issue revolves around @p1 (I think)
$var_name[1] = "jmmain.locatn";
$var_name[2] = "jmmain.active";
$var_name[3] = "jmmain.here";

@p1 = ('String', 24, 'B', 'BCCF-ZON1-APOD-DORM-01L', 'BCCF-ZON1-APOD-DORM-COT4') . ('String', 24, 'B', 'BCCF-ZON1-CPOD-DORM-01L', 'BCCF-ZON1-EPOD-14 -COT1');
@p2 = ('Short', 4, 'E', 1);
@p3 = ('Short, 4, 'E', 1);

Running this code results in: Invalid search type (BCCF-ZON1-APOD-DORM-COT4BCCF-ZON1-EPOD-14 -COT1,,,)

Anyone have any ideas? Crazy


rovf
Veteran

Oct 28, 2011, 5:01 AM

Post #2 of 6 (2675 views)
Re: [compbugs] Search 'Between' issues [In reply to] Can't Post

In the code which you are posted, I see only assignments to some variables (including one - @p1 - which doesn't make any sense), but I don't see any code doing a "search". I'm pretty sure that executing the 6 lines you posted does NOT give the error message "Invalid search type".

Having said this, may I ask you what you intended by placing the dot (".") in the assignment statement for @p1?


compbugs
New User

Nov 1, 2011, 8:46 AM

Post #3 of 6 (2585 views)
Re: [rovf] Search 'Between' issues [In reply to] Can't Post

The dot was there basically because I ran out of ideas, but it is supposed to combine the two. (Thanks for the reply, btw)



eval "exec ctperl -S $0 $*"
if $running_via_sh;
require 'ctree.pl';

$var_name[1] = "jmmain.locatn";
$var_name[2] = "jmmain.active";
$var_name[3] = "jmmain.here";

@p1 = ('String', 24, 'B', 'BCCF-ZON1-APOD-DORM-01L', 'BCCF-ZON1-APOD-DORM-COT4') . ('String', 24, 'B', 'BCCF-ZON1-CPOD-DORM-01L', 'BCCF-ZON1-EPOD-14 -COT1');
@p2 = ('Short', 4, 'E', 1);
@p3 = ('Short', 4, 'E', 1);

$rpt_head = "Testing BRT";

format top =
@<<<<<<<<<< @|||||||||||||||||||||||||||||||||||||||||||||||| @>>>>
$rpt_date, $agency_head, $<
@<<<< @||||||||||||||||||||||||||||||||||||||||| Page: @>>>>
$rpt_time, $rpt_head, $%
.

format heading =
@<<<<<<<<<< @|||||||||||||||||||||||||||||||||||||||||||||||| @>>>>
$rpt_date, $agency_head, $<
@<<<< @||||||||||||||||||||||||||||||||||||||||| Page: @>>>>
$rpt_time, $rpt_head, $%
.

format DETAIL =
@<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>
$locatn, $number
.

format RPTFTR =
------------------------------------------------------------
Total Housed: @<<<<<
$total
------------------------------------------------------------
Report Includes:
.

&pick_index ("file_index", "search_data");

$query = "jmmain, locatn, number;
nmmain.number = jmmain.namenum, last, first, middle;
jmoffens.booknum => jmmain.number;
jmintrel.booknum => jmmain.number, arrivcr;
-| locatn, jmmain.number";

$DB_HANDLE = &db_open ($file_index, *search_data, $query);

$~ = 'DETAIL';
$total = 0;

while (((($locatn, $number, $last, $first, $middle) =
&db_read ($DB_HANDLE)) || 1) && $isam_err == 0) {
write;
$total++;
}
&db_close ($DB_HANDLE);
$^ = heading;
&GENCONTROL("RPTFTR");
&rptinc ("ALL Locations", "All with active field matching", "All with here field matching");
&cleanup;



rovf
Veteran

Nov 2, 2011, 5:14 AM

Post #4 of 6 (2512 views)
Re: [compbugs] Search 'Between' issues [In reply to] Can't Post


Quote
The dot was there basically because I ran out of ideas, but it is supposed to combine the two.


Putting a dot into arbritrary places, without knowing exactly what it is doing, is not a practice I personally would recommend.... However:

I don't know what you mean by "combining", but the dot operator has the following function: It tries to convert both operands into a string, and delivers the catenation of these strings.

Now you posted a longer excerpt of your code, and I wonder: Is this the complete program you have posted? Because there is no

use strict; use warnings;

in your program, and it doesn't make sense to discuss bugs in the logic of your program, before you haven't got rid all of the strictness- and warning messages. In your case, I would expect a "Useless use of a constant in void context" message, because the operands of your dot-operator use the "comma" operator, which throws away the left argument.

Note that comma behaves differently, when used in list context or in scalar context. While the comma in

@x=(3,5);

is the "list construction" comma, the comma in

(3,5).6

is the scalar comma operator (i.e. discarding the left argument and delivering the right argument).

This is not a feature of Perl I'm particularily fond of, but one we have to live with...


compbugs
New User

Nov 2, 2011, 6:15 AM

Post #5 of 6 (2506 views)
Re: [rovf] Search 'Between' issues [In reply to] Can't Post

The dot-operator is only there, because I tried all the other operators that I thought would work. And for that matter, I may be completely off the mark on how I'm trying to accomplish this and going about it in the wrong way. So, to explain a bit more clearly, I need the report to give me the following:

ex. @p1 = (A1 through B5) + (D1 through E5)

result should be: A1 A2 A3 A4 A5 B1 B2 B3 B4 B5 D1 D2 D3 D4 D5 E1 E2 E3 E4 E5

I hope that makes more sense.



As to the report itself (and that is all of it), if I take

@p1 = ('String', 24, 'B', 'BCCF-ZON1-APOD-DORM-01L', 'BCCF-ZON1-APOD-DORM-COT4') . ('String', 24, 'B', 'BCCF-ZON1-CPOD-DORM-01L', 'BCCF-ZON1-EPOD-14 -COT1');

and remove the second half of it, so it looks like

@p1 = ('String', 24, 'B', 'BCCF-ZON1-APOD-DORM-01L', 'BCCF-ZON1-APOD-DORM-COT4');

the report runs fine without any issues. But that only gives me part of what I need. Once again, thanks for your help and your patience.


BTW, I added the use strict; use warnings; to the code that I posted and the attachment shows the results.
Attachments: ScreenHunter_01 Nov. 02 07.11.gif (39.5 KB)


rovf
Veteran

Nov 2, 2011, 2:53 PM

Post #6 of 6 (2452 views)
Re: [compbugs] Search 'Between' issues [In reply to] Can't Post


Quote
I added the use strict; use warnings; to the code that I posted and the attachment shows the results.


So, please fix first the messages you get from this, and then let's get back to your original problem.

In most cases, it helps you (and us) to get the code "strict/warnings"-clean, and on the long run, you are doing yourself a favour.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives