A BASIC Challenge!!! (A call for help!)-email replies please 
Author Message
 A BASIC Challenge!!! (A call for help!)-email replies please

I'm sorry, I forgot to mention to please send your replies by email to

Thanks,
Scott Sternfeld

Hi all-

Maybe you can help me direct my message to the appropriate place, but
hopefully I found the right people to help.

I have a program written in BASIC running on Qbasic.  It is a program
that
interfaces with an oscilliscope to obtain wafeform data.

The problem is, on a random number of cycles through the program, it
will
just freeze.  My guess is some kind of buffer error.  But I can't figure

out the loops and the context.

If anyone wants the challenge of figuring this out, it can be re-written

in Visual Basic, C, or any language you want where I can run this on a
pc
somehow.

A monetary reimbur{*filter*}t may also be available.

Thank you for your time.

**Scott Sternfeld**

This is for a LeCroy 9360 Oscilliscope, and I have the Remote Control
manual as well.
-----start program----

  OPEN "COM1:9600,n,8,1" FOR RANDOM AS #1 LEN = 256
1 CLS : PRINT , "PROGRAM TO RETURN WAVEFORM FROM 9360 OSCILLOSCOPE"
PRINT , "Output file name";
INPUT f$
cr$ = CHR$(13)
PRINT #1, CHR$(27) + "C"
PRINT #1, CHR$(27) + "["
OPEN f$ FOR OUTPUT AS #2
PRINT , "Enter number of shots to avg";
INPUT nshts
XOFF$ = CHR$(19)
XON$ = CHR$(17)
B$ = "ZZZ"
wfn = 0
8  PRINT #1, "CLSW" + cr$
s = TIMER
WHILE TIMER < (s + .1 * nshts)
WEND
FOR YY = 1 TO 1500: NEXT YY
555  PRINT #1, "PAST? CUST,AVG"
tzt = TIMER
WHILE TIMER < tzt + .5: WEND
IF LOC(1) = 0 THEN
  GOTO 555
ELSE
  bo$ = INPUT$(LOC(1), #1)
  PRINT #2, bo$
END IF
COMD$ = "TC:INSP? 'SIMPLE'"
GOSUB 80
9  wfn = wfn + 1
 LOCATE 4, 1: PRINT , "Downloaded waveform #", wfn
 LOCATE 5, 1: PRINT , "Hit any key to continue, x to exit";
 v$ = INPUT$(1)
 IF v$ <> "x" THEN
    LOCATE 5, 1: PRINT , "                                    "
    GOSUB 1000
    GOTO 8
 END IF
10  END

REM Subroutine to gather data from the oscilloscope

80  PRINT #1, "WFSU SP,0,NP,0"
PRINT #1, "COmm_RS232 LL,80, EO,'ZZZZZZZZZZZ'"
90 PRINT #1, COMD$ + cr$
400 FOR DELAY = 1 TO 2000: NEXT DELAY
402 FOR DELY = 1 TO 2000: NEXT DELY
  IF LOC(1) = 0 THEN
      nl1 = nl1 + 1
      IF nl1 = 20 GOTO 80
      GOTO 400
  END IF
504 IF LOC(1) < 250 THEN
        LOCATE 7, 1: PRINT , LOC(1)
        A$ = INPUT$(LOC(1), #1)
        PRINT #2, A$;
        IF INSTR(A$, B$) > 0 THEN
          PRINT #2, " ";
          GOTO 9
        END IF
  END IF

506 IF LOC(1) > 250 THEN PAUSE = TRUE: PRINT #1, XOFF$;
REM          LOCATE 7, 1: PRINT , LOC(1)
507    C$ = INPUT$(LOC(1), #1)
     PRINT #2, C$; : IF LOC(1) > 0 THEN 504

     IF INSTR(C$, B$) > 0 THEN
        PRINT #2, " ";
        GOTO 9
     END IF

511 IF PAUSE THEN PAUSE = FALSE: PRINT #1, XON$;
  GOTO 402

900 RETURN

REM Subroutine to clear input and output buffers

1000 dp$ = INPUT$(LOC(1), #1): PRINT #2, dp$
1005 PRINT #1, CHR$(27) + "C"
1006 PRINT #1, CHR$(27) + "["
1010 FOR zztop = 1 TO 2000: NEXT zztop
   IF LOC(1) > 0 THEN
      GOTO 1000
   END IF
1020 RETURN



Wed, 06 Aug 2003 07:08:42 GMT  
 A BASIC Challenge!!! (A call for help!)-email replies please

Quote:
> I'm sorry, I forgot to mention to please send your replies by email to

> Thanks,
> Scott Sternfeld
> Hi all-

Hello Scott,

Quote:
> The problem is, on a random number of cycles through the program, it
> will just freeze.  My guess is some kind of buffer error.  But I can't figure
> out the loops and the context.

[Snip]

Line 504 and 507 are the culprit's in more way's than one.  

1) You're jumping to line 9 (the main program) from both of these lines.  That's not allowed, a Subroutine should be terminated by
a RETURN command.  
A simple solution for this program is to replace both GOTO 9 's with a RETURN command.  It's stil ugly (RETURN commands within a IF
construction are not considered "nice programming" :-)

2) Your'e checking if the number of chars/bytes in your input-buffer is lower than 250 at line 504, and if there are more
chars/bytes than 250 in line 507. What happens if there are *exacly* 250 chars/bytes present ....?  You've guessed it, none of the
two lines will be executed !
Solution of it would be to add a Equal-sign ("=") in front of either the "<" in line 504 or the ">" in line 507 (but *not* both.)

Regards,
  Rudy Wieser

P.s.
Let me know if it worked.



Fri, 08 Aug 2003 18:40:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. A BASIC Challenge!!! (A call for help!)-email replies please

2. xxx please reply per email

3. tkinspect 5.1.6 (email replies please)

4. Please help Visual Basic Programer with simple read/write text file routine---Real Basic 2.1

5. Calling Python interpreter via Visual Basic -Reply

6. (PLEASE REPLY) Calling all Conversion Generator Experts - [Cross-Posted]

7. Help Needed with Oberon, please reply

8. Help: Newbie FORTRAN I/O question (ELF90) - e-mail reply please

9. !!!Please,please reply

10. Email Experiment - Please help

11. Report email to big - PLEASE HELP?

12. Email help required please

 

 
Powered by phpBB® Forum Software