3
  440 DEFPROCsave
  450 phonenos=OPENUP("Phonenos")
  470 PRINT
  480 FOR j= 1 TO counter
  490       PRINT#phonenos,contact{(j)}.name$,contact{(j)}.phone$,contact{(j)}.email$
  500   FOR f = 1 TO 10
  510     PRINT#phonenos,contact{(j)}.response%(1,f)
  520   NEXT f
  530   
  540 NEXT j
  550 CLOSE#phonenos
  560 PRINT "Data saved."
  570 ENDPROC

Code to save details from database I'm trying to save what i have entered to a file but the error INVALID CHANNEL AT LINE 490 APPEARS/

gordon
  • 31
  • 4
  • Whoa; a blast from the past. Define "not working". #390 has an issue, #490 has an issue, there may be others. – Dave Newton Mar 25 '15 at 18:33
  • Thanks yea 490 not working – gordon Mar 25 '15 at 18:35
  • Have you verified that `phonenos` opens and is a readable db file? –  Mar 25 '15 at 18:37
  • no sorry how do u do that? – gordon Mar 25 '15 at 18:38
  • Any body know how to get this working where it can create and save contacts to a file? – gordon Mar 25 '15 at 18:42
  • 370 DEFPROCcreate 380 counter = counter + 1 390 INPUT"Name " contact{(counter)}.name$ 400 INPUT"Phone number ",contact{(counter)}.phone$ 410 INPUT"Email address ", contact{(counter)}.email$ 420 ENDPROC 430 440 DEFPROCsave 450 phonenos=OPENOUT("Phonenos") 470 PRINT 480 FOR j= 1 TO counter 490 PRINT#phonenos,contact{(j)}.name$,contact{(j)}.phone$,contact{(j)}.email$ 500 FOR f = 1 TO 10 510 PRINT#phonenos,contact{(j)}.response%(1,f) 520 NEXT f 530 540 NEXT j 550 CLOSE#phonenos 560 PRINT "Data saved." 570 ENDPROC – gordon Mar 25 '15 at 18:43
  • The **Alpha BASIC (AB)** we sometimes have to use would differs from your **BBC Micro**. In **AB**, the call would be `OPEN #1,"Phonenos",INPUT`. It is hard to find documentation on these, but testing your File Handle might be what you need to search for. –  Mar 25 '15 at 18:44
  • @DaveNewton Could you please tell me the issues? – gordon Mar 25 '15 at 18:45
  • #490 had those two tick marks in the text. #390 is no longer listed. –  Mar 25 '15 at 18:46
  • 390 INPUT"Name " contact{(counter)}.name$ – gordon Mar 25 '15 at 18:48
  • what do u mean by tick marks? – gordon Mar 25 '15 at 18:49
  • There were two backticks before the `PRINT`. Don't you need a comma after the string on 390? – Dave Newton Mar 25 '15 at 18:50
  • Yes thanks, but can't see any backticks – gordon Mar 25 '15 at 18:53
  • PRINT#phonenos,contact{(j)}.name$,contact{(j)}.phone$,contact{(j)}.email$ – gordon Mar 25 '15 at 18:54

1 Answers1

1

If your error is on line 490, one of two things is likely happening.

  1. Your FILEHANDLE for phonenos did not open.

    You could be attempting to access the file from a bad location, it may not exist, or it could be write protected.

  2. Your contact array is referencing an invalid index item.

    Is counter going outside the range of the array? Is this a zero (0) or one (1) based array?

  • I do not know if `contact{(j)}` is a valid indexer. Here, you are the expert and not me. –  Mar 25 '15 at 18:58
  • We have an **AlphaBASIC** manual here, but I haven't found any online sources of information. Luckily, I have not had to edit much of that old code (knock on wood). –  Mar 25 '15 at 19:09