range of numbers

range of numbers

Post by Mikie » Mon, 07 Jul 1997 04:00:00



I need to test for a particular number within a range of numbers.  I have
entries that read "1-15, 18-21" for example, in which the numbers 16 and 17
are missing in a range from 1 to 21.

Right now I have a VERY inelegant bit of code which tests for a comma or a
space and a dash, gets a subStr of (in this example) "1", and another
subStr of "15", builds an array from 1 to 15 with a loop block, and then
goes back to get the "18-21" subStr and adds that to the array in the same
way.  Then I test the array to see if it contains the number I'm looking
for.  It works, but it seems very unnecessary.

I'm using this to test for volume numbers for journals and books in the
library, and return true if the library has a particular volume of a
particular journal.  An additional problem here is that many journals are
published in seperate series, in which the volume numbers begin again at 1
with every new series.  So I've formated my "Available Volumes" field to
designate a series by a number within brackets.  This means that some
entries read "[1]1-10, [2]1-5, 8-15 [3]6-9, 12" which makes things
difficult.

Is there an ObjectPal method which can handle a range entry like the above
without all the extra coding?  I just need the database to understand that
"1-15" means 1 through 15, and not 1 minus fif*.  I've scoured the
ObjectPal manuals and the help files in the system and I can't find
anything that makes this easier.  setRange() almost seems the thing, except
that it operates on seperate table entries, and I'd really prefer not to
have a seperate record for every volume in every journal.

I don't mind having to reformat the entries in the database if I can find a
way to make the database understand that it's looking at a range of numbers
in a string without having to go through this much code every time it's
looks up a particular volume.

I'm running Paradox 5 on a Win95 system.

Any advice greatly appreciated!
--
-Mikiel
Tempe, Arizona

 
 
 

range of numbers

Post by Mikie » Mon, 07 Jul 1997 04:00:00


I need to test for a particular number within a range of numbers.  I have
entries that read "1-15, 18-21" for example, in which the numbers 16 and 17
are missing in a range from 1 to 21.

Right now I have a VERY inelegant bit of code which tests for a comma or a
space and a dash, gets a subStr of (in this example) "1", and another
subStr of "15", builds an array from 1 to 15 with a loop block, and then
goes back to get the "18-21" subStr and adds that to the array in the same
way.  Then I test the array to see if it contains the number I'm looking
for.  It works, but it seems very unnecessary.

I'm using this to test for volume numbers for journals and books in the
library, and return true if the library has a particular volume of a
particular journal.  An additional problem here is that many journals are
published in seperate series, in which the volume numbers begin again at 1
with every new series.  So I've formated my "Available Volumes" field to
designate a series by a number within brackets.  This means that some
entries read "[1]1-10, [2]1-5, 8-15 [3]6-9, 12" which makes things
difficult.

Is there an ObjectPal method which can handle a range entry like the above
without all the extra coding?  I just need the database to understand that
"1-15" means 1 through 15, and not 1 minus fif*.  I've scoured the
ObjectPal manuals and the help files in the system and I can't find
anything that makes this easier.  setRange() almost seems the thing, except
that it operates on seperate table entries, and I'd really prefer not to
have a seperate record for every volume in every journal.

I don't mind having to reformat the entries in the database if I can find a
way to make the database understand that it's looking at a range of numbers
in a string without having to go through this much code every time it's
looks up a particular volume.

I'm running Paradox 5 on a Win95 system.

Any advice greatly appreciated!
--
-Mikiel
Tempe, Arizona

 
 
 

range of numbers

Post by dmorga » Tue, 08 Jul 1997 04:00:00


Quote:> I need to test for a particular number within a range of numbers.  I
> have entries that read "1-15, 18-21" for example, in which the numbers
> 16 and 17 are missing in a range from 1 to 21.

> Is there an ObjectPal method which can handle a range entry like the
> above without all the extra coding?  I just need the database to
> understand that "1-15" means 1 through 15, and not 1 minus fif*.  

The problem is that you have an incorrectly set up database. You should
have two tables. One for publication name and one for issue like this:

PARENT
pub_number   N*
pub_name     A20

CHILD
pub_number   N*
issue_number N*

Then a simple query solves the problem. I know it requires more initial
data entry but it does work.

Daniel A. Morgan

 
 
 

range of numbers

Post by Kasey Chang (fix address before replying to m » Tue, 08 Jul 1997 04:00:00




Quote:>> I need to test for a particular number within a range of numbers.  I
>> have entries that read "1-15, 18-21" for example, in which the numbers
>> 16 and 17 are missing in a range from 1 to 21.

>> Is there an ObjectPal method which can handle a range entry like the
>> above without all the extra coding?  I just need the database to
>> understand that "1-15" means 1 through 15, and not 1 minus fif*.  

>The problem is that you have an incorrectly set up database. You should
>have two tables. One for publication name and one for issue like this:

>PARENT
>pub_number   N*
>pub_name     A20

>CHILD
>pub_number   N*
>issue_number N*

>Then a simple query solves the problem. I know it requires more initial
>data entry but it does work.

Daniel is right, your data is NOT normalized. You can write OPAL
routines pretty easily that will convert your existing data into the
"right" normalized format. If you really need reports to show up as
that old format, you can write OPAL to generate fields like that, but
PDOX is NOT designed to read "shorthand".
 
 
 

1. return ranges of numbers?

This may be an easy question, but this problem is out of my scope of
experience.  What I'm trying to do is read a table with web page session
data.  Listed are users logged in an the bandwidth of their connection.
In the table are all sorts of numbers, most of which are not the same.
What kind of query would I use to group them into speed ranges, for
example, have return values like:

Bandwidth Range                            Count
-----------------------------------------
0k-28k                                              40
28k-56k                                            283
56k-128k                                          103
128k-256k                                        95
256k-512k                                        87
512k-up                                            56

TIA
-Gern

2. Pick Opportunities in D.C. Area

3. creating the range of numbers

4. "Could not redo log record ..." during restore

5. Range of Numbers

6. Performance Issue

7. Validating a range of numbers?

8. PUBLIC DOMAIN E-R Modeling..

9. figuring between range of numbers

10. finding a range of numbers in a calc

11. Ranges of numbers within calculations?

12. Range of Numbers

13. Query to detect "gaps" in a range of numbers