Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic General > Re: sorting lis...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 640 of 702
Post > Topic >>

Re: sorting list problem

by Derek <derekrss@[EMAIL PROTECTED] > Dec 28, 2007 at 09:06 PM

On Dec 28, 6:23=A0pm, richard <s...@[EMAIL PROTECTED]
> wrote:
> I have a list of a few thousand records that I need to resolve into
> one short list.
>
> I have compiled and sorted, a major list of items.
> Each item is currently listed multiple times due to the last field
> entry.
> I'm trying to make a short list where the duplicates are not entered,
> but counted.
> So each new item begins a new record in the short list.
>
> e.g.
>
> John Smith,123 adams,some where, 1234
> John Smith,123 adams,some where, 1245
> John Smith,123 adams,some where, 1266
>
> Bill Smith, Baker, else where, 3452
> Bill Smith, Baker, else where, 3588
> Bill Smith, Baker, else where, 3762
>
> Would become:
>
> John Smith, 3
> Bill Smith, 3
>
> Are you guys still messin around with ancient qbasic?
> Upgrade!www.libertybasic.com
> This puppy is everything that basic was with a lot of new twists.
> It also works within windows so you don't need to go into dos.
> Newer versions will include html.
>
> Can basic connect you to the internet and beyond?
> Liberty Basic can.

Since the list is already sorted the QBASIC program you need is
something like

-- Begin code ----
DIM J AS INTEGER
DIM dRecord AS STRING
DIM dNewItem AS STRING
DIM dCurrentItem AS STRING
DIM dTotal AS INTEGER

OPEN "count.txt" FOR OUTPUT AS #1
OPEN "records.txt" FOR INPUT AS #2
LET dCurrentItem =3D ""
LET dTotal =3D 0
DO WHILE NOT EOF(2)
   LINE INPUT #2, dRecord
   LET dNewItem =3D LEFT$(dRecord, INSTR(dRecord + ",", ",") - 1) + ","
   IF dCurrentItem =3D dNewItem THEN
      LET dTotal =3D dTotal + 1
   ELSE
      IF dTotal <> 0 THEN
         PRINT #1, dCurrentItem; dTotal
      END IF
      LET dCurrentItem =3D dNewItem
      LET dTotal =3D 1
   END IF
LOOP
IF dTotal <> 0 THEN
   PRINT #1, dCurrentItem; dTotal
END IF
CLOSE #2
CLOSE #1
SYSTEM
-- End code ----

As a matter of interest, it's quite easy to handle the internet with
QBASIC using the SHELL command. This allows QBASIC to transfer data
(either ftp or http data) via DOS programs such as ftp.exe or curl.exe
and then process it via QBASIC commands.

Cheers

Derek
 




 2 Posts in Topic:
sorting list problem
richard <spam@[EMAIL P  2007-12-28 20:23:28 
Re: sorting list problem
Derek <derekrss@[EMAIL  2007-12-28 21:06:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Nov 20 21:35:57 CST 2008.