Lookup issue

Jeremy Leach

Senior Member
Hi

I've encountered a strange issue. I've got a very long lookup command that wraps onto two lines of code. This seems to be causing unexpected problems in execution, although the syntax checker thinks it's ok.

How do I get round this? Is there some sort of continuation symbol in the program editor - e.g VBA uses "_" to mean that the command continues on the next line ?

The command I'm using is :
Lookup RecordIndex,(0,5,10,16,22,27,34,42,50,55,60,65,69,74,82,84,92,95,100,105,108,111,117,124,126,129,135,143,147,152,159,162,167,171,178,182,187,189,191,193,195,197,199,201,203,205,206,209,213,18,222,222,228),Address

 

ylp88

Senior Member
Very odd... I was able to reproduce the two-line-spanning scenario but then now I can't!

ylp88
 

Jeremy Leach

Senior Member
I should have searched first. Here's an existing answer ..
http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=1147&forum_id=9&Topic_Title=Continuation%2Blines&forum_title=No+new+posts+please%21+4

However the example I've given seems to give execution issues - it makes my program loop continuosly where there isn't a loop !
 

Jeremy Leach

Senior Member
I guess the issue must be in the way the program editor translates the text into tokens for the interpreter, and somehows gets it wrong.

I've noticed that adding spaces shuffles the text onto different lines, but this doesn't seem to cure the issue. If I understood why it's being translated wrong then I could understand the fix - hopefully.

The full subroutine that causes the problem is below. If it's called then my program loops unexpectedly. If it isn't called it doesn't.


Lookup_String_Index_Table:
Lookup RecordIndex,(5,5,6,6,5,7,8,8,5,5,5,4,5,8,2,8,3,5,5,3,3,6,7,2,3,6,8,4,5,7,3,5,4,7,4,5,2,2,2,2,2,2,2,2,2,1,3,4,5,4,6,7,3),Bytes
Poke SV_Bytes,Bytes
Lookup RecordIndex,(0,5,10,16,22,27,34,42,50,55,60,65,69,74,82, 84,92,95,100,105,108,111,117,124,126,129,135,143,147,152,159, 162,167,171,178,182,187,189,191,193,195,197,199,201,203,205,206,209,213,218,222,222,228),Address
Poke SV_Address,Address
Return
 

Jeremy Leach

Senior Member
I'm talking to myself here , but it may not even be anything to do with the wrapping of the command. The manual doesn't make it clear how many data parameters you can have in an offset command. I've assumed 255 because the offset parameter is one byte ??
 

wardbob

Member
Both of your lookups have 53 items in the argument. But is it true that only the second one is causing problems? That seems odd.
You could split it into two and send values <100 to one lookup otherwise to another. Of course this wouldn't work so well for your first lookup.
 

wardbob

Member
129 might be a better split in case there is a limit of 32, this would give about half of 53. But again there's the problem of the first on.
 

Jeremy Leach

Senior Member
Thanks for the suggestions. I'm now not even sure my issue is related to the Lookup command. I thought it was because when I removed the call to the routine the program flowed as it should. But if I remove all the commands within the sub (ie an empty sub except for the sub label name and a return statement) and call it the program doesn't flow. It's very bizarre.
 
Very strange.

The things i can think of is the standard "Are you using the latest version software" or isn't "address" a reserved keyword (althoug the manual doens't mention the address word)

Does the gosub count exceed the maximum of 16 or does the count of the nested gosubs the maximum of (i believe) 4 ?

Edited by - dave_h on 4/11/2005 11:21:58 AM

Edited by - dave_h on 4/11/2005 11:25:22 AM
 

Jeremy Leach

Senior Member
Dave-h, you must have read my mind. Yes, the gosubs exceed nesting of 4. I'm trying to nest to 5 levels, so that must be it ! Pity the Editor doesn't pick up on this. Back to the drawing board !!!


I apologise for trying to blame the Lookup command ;-)

Actually I think this is an extremely useful command in certain circumstances. In my case I am using it to retrieve 'records' of data from 'tables' and apart from this hiccup it's working really well.
 

Jeremy Leach

Senior Member
Actually, it's made me think that it might not be too hard to write a VBA program to scan PicAxe code to detect if maxnesting is exceeded. Although might be harder than I think !
 
Top