Hi Bill,

You've entered the twilight zone (oooouuuuiiiii) - of undefined default behaviours, I 
fear. :-)

No, it's really a question of what the cursor is set to when you haven't set it. If 
you add a "Fetch First ..." before each column
reference (Print statements), or at least before the last one, you get the right 
results.

It's not really a bug, since one should always state what one wants before asking for 
it, even if it looks as trivial as here.

But the example proves that selection tables doesn't have their own cursor, it's using 
the cursor of the base table. Which makes
sense, since a selection table isn't really a table technically, it only works that 
way in a logically sense.

Supporting example:
If I issue a "Fetch Rec 4 From BEERS" before each Print statement, the app replies 
with "Red Hook" all three times, even though the
column references goes to BEER2 and BEER3, not BEER.

Best regards/Med venlig hilsen
Lars V. Nielsen
GisPro, Denmark
http://www.gispro.dk/
----- Original Message ----- 
From: "Bill Thoen" <[EMAIL PROTECTED]>
To: "MapInfo-L" <[EMAIL PROTECTED]>
Sent: Sunday, August 01, 2004 6:00 PM
Subject: MI-L A Problem with Cursors of Beers


> This is a problem for MapBasic programmers and it involves MapInfo
> swicthing one selection cursor with another. In this case it switched a
> pint of Bass for a LoveInnaCanoe brand. Horrors!
>
> But what's going on here? If you create one temporary table with a
> selection, you don't want a subsequent selection overwriting the first
> when you specify a different result table. But that's exaclty what's
> happening in the short application below. Does anyone know why this is,
> and if there's a workaround?
>
> ' Beer.mb
> ' Demonstrates a bug in selection cursors. They are not persistent!
>
> Dim i As Integer
>
>   Close All
>   Print Chr$(12)
>
>   ' Set 'em up and display them...
>   Create Table BEERS (
>     name Char(40)
>     )
>   File ApplicationDirectory$() & "Beers.tab"
>   Insert Into BEERS (name) Values ("Guinness")
>   Insert Into BEERS (name) Values ("Bass")
>   Insert Into BEERS (name) Values ("Molson BarleyPop")
>   Insert Into BEERS (name) Values ("Red Hook")
>   Browse * From BEERS
>
>   ' Create a selection into a cursor
>   Select * From BEERS Where rowid = 2 Into BEER2 NoSelect
>   Print "Beer 2 is " & BEER2.name
>
>   ' Create another one
>   Select * From BEERS Where rowid = 3 Into BEER3 NoSelect
>   Print "Beer 3 is " & BEER3.name
>
>   ' So what's happened to BEER2 ???
>   Print "Ha! Beer 2 is now " & BEER2.name
>
> ' --- end
>
>
>
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 12814
>
>


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12816

Reply via email to