Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : label in library
Author | Message | ||||
drkl Senior Member Joined: 18/10/2015 Location: HungaryPosts: 102 |
Hi, where is my mistake? The code fragmnent in the library: FOR I=1 TO CPMX C1$=CP$(I)+":" UJBEV: C2$="AKT: "+PP$(I) KIIR INPUT " ",SEGS$ IF SEGS$<>"" THEN PP$(I)=SEGS$ GOTO UJBEV ENDIF NEXT I The error massage: GYUJT.AZ.(MX10): AKT: 12345ABCDEF s [LIBRARY] GoTo UJBEV Error: Cannot find label Can anybody help me? Thanks drk |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Hi drkl, I have just successfully tried a 'shorter' version of your code as follows: FOR i = 1 to 10
ujbev: INPUT "hit a key ",s$ IF s$<>"" THEN d$=d$+s$ GOTO ujbev ENDIF NEXT i Even though it is meaningless code in this form, it hopefully copies the main elements of your library code. By the way, this was saved as a library and worked as expected. The main difference (apart from variable names) is the lack of a call to your 'KIIR' sub. What happens your end if you comment out the line 'KIIR from your LIBRARY code?? WW Tried on a 28pinner running v5.0 For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
drkl Senior Member Joined: 18/10/2015 Location: HungaryPosts: 102 |
Hi WW, Before writing, I also tried with a short code: SUB PROBA LOCAL LABL,I=1 LABL: PRINT I I=I+1 PAUSE 1000 GOTO LABL END SUB put it into library, writing proba to the command line, works fine. otherwise without KIIR subroutine, the problem remains. Thank you so much to deal with the problem, but I'm completely clueless. drkl |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9063 |
Isn't it illegal to use the same name for a variable AND a label? LOCAL LABL,I=1 LABL: ...i thought so... By that I mean you should not have a local variable called LABL AND also a label with the same name. Members will correct me if I am wrong, but I would have thought that to be a no-no, as even if the interpreter is happy with that, it would be confusing to debug later on. Smoke makes things work. When the smoke gets out, it stops! |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
@drkl If you want to send me your code then feel free and I will gladly look into this for you (100% confidential). Just let me know what platform, and which firmware you are using and I should be able to sort out the issue. Assuming you don't want to 'publically release' your code then just PM or email me with it (plus any other basic instructions!!). WW For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8584 |
drkl To make your life easier and the code more readable can I suggest you stop using capital letters for anything except reserved words. Also, if you use OPTION EXPLICIT and OPTION DEFAULT NONE this will force you to declare and type all variables. This makes debugging much easier for you (and for us ) |
||||
drkl Senior Member Joined: 18/10/2015 Location: HungaryPosts: 102 |
Hi, Of course, I tried without LOCAL, the problem persisted. Otherwise I would have been if the labels were local. It is very interesting: put the library code into the program it works without error! Dear Matherp, I love the great-letter codes, the MMEDIT supports and thus do not have to use lower-upper switch . Dear WW, e-mail I was send e-mail the ZIP code It contains LB-LOGGER.BAS library and event logger program in half-finished state. Unfortunately, the Hungarian commenting, but after that I will be comment in English. I recommend attention, numbers, time and texts in 64-bit storage. Otherwise I use MM44/V5.0. Thanks to employ my problem. Regards drkl |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
You could change this piece of code to [code]SUB PROBA LOCAL LABL,I=1 Do PRINT I I=I+1 PAUSE 1000 Loop END SUB [/code] It's a much better way to code and the idea may solve your original problem. |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
POSSIBLE FIRMWARE BUG? Please can some of you try the following test if you have a spare 10minutes In trying to solve drkl's issue I have narrowed something down (and this is a very intermittent issue which makes it very difficult). With any v4.7 B37 (or later Beta) OR v5.0 MicroMite (28pin, 44pin, 64pin, or 100pin) please load the following code WITHOUT running it: SUB ww(x)
LOCAL k$,i FOR i=1 TO x wwL1: a$=b$(i) '***************************** INPUT "Press a key!",k$ IF k$<>"" THEN GOTO wwL1 NEXT i END SUB Then at command prompt type: LIBRARY SAVE Now at the command prompt, type: ww(1) You should get an error message stating effectively that b$ is not declared. So now type DIM b$(10) Now type ww(1) again and now you should be able to press keys without issues. Pressing ENTER will 'exit' the WW sub. Next type WATCHDOG 1 to reset the MM. Typing ww(1) at the Command Prompt should show the 'undeclared b$' message again. This time, enter a one line program INTO THE EDITOR. Hence type EDIT, and then enter: DIM b$(10) and press F2 Now type WW(1), press any key (apart from ENTER) and see if you get a message identical to drkl's original post. Appreciate any feedback with this one as have spent the last 14hours trying to pinpoint what is going on Thanks for any replies . . . . WW For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3659 |
Having used EDIT wouldn't you also have to RUN it for the DIM to take effect? John |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Hi John, Thanks for your response. I agree with you, but I can consistently get the error of 'cannot find label' even from a running program which is an 'issue' IMHO. It has taken many hours to track down this simple 'summary' and in a way I hope it is something silly I am doing. However, I have written thousands (seems like it) of test libraries and can get this error message to 'randomly' appear. The method outlined is a consistent way of making it appear/disappear so will hopefully give Geoff something to home in on. I think I need a break from this for a bit - time for some responses to see what others observe. Thanks again John. Sorry, forget to respond specifically to your question. I mentioned to press F2 which is 'run' For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3659 |
D'oh! Silly me. Sorry. John |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3165 |
OK, I have spent some time going through WW's post above, ie: A lot of the problems seems to arise from testing library functions at the command prompt. The important thing to note is that the library code is only run immediately before the program in main memory is run. It is not run when the command prompt is displayed. The way that the interpreter runs startup code can be best illustrated with a flow diagram. The actual process is more complicated but this is the high level summary: I have gone through WW's step by step process and MMBasic does what it should. So the issue might be a misunderstanding or perhaps I have fixed the issue while fixing other bugs in 5.0. I believe that the best way forward is to wait for ver 5.1 (due out in a few days) and see if the issue persists. Geoff Geoff Graham - http://geoffg.net |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
Please note that there is an issue with Labels in Library code; confirmed and already fixed by Geoff. The original issue in this thread (drkl's code) is confirmed working ok by drkl when using a test Beta from Geoff. If anyone is using LIBRARY code and experiencing strange program behaviour, then it may be due to having Labels in your library code. I mention this to try and save you time de-bugging Thanks to Geoff once again for fixing the issue immediately For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
Print this page |