LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-18-2004, 10:09 AM   #1
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Rep: Reputation: 32
Help with Sed and regex


Some history...
I have a very large PicBasic file (12000 lines +/-). I am trying to parse out various code segments.

I am attempting to output every line that contains the words "draw" or "load" along with the line number and number of occurances. I can achieve that with:
Code:
 cat -n hrc_60.bas | grep -iP "(draw|load)" | cat -n
That produces 429 lines. A bunch of those lines are commented out. I would like to eliminate them from the output.
It seems like sed is the right tool for this job. I am having trouble getting my regex formed correctly.
Code:
 cat -n hrc_60.bas | sed "s/\d*\s*'.*//" | grep -iP "(draw|load)" | cat -n
The input to sed is the file listing with line numbers:
Code:
12832  getkeyu:
12833     ' Wait for all keys up
12834     PORTB = 0               ' All output pins low
12835     TRISB = $f0             ' Bottom 4 pins out, top 4 pins in
12836     Pause 1
12837     
12838     IF ((PORTB >> 4) != $f) Then getkeyu    ' If any keys down, loop
12839     
12840     Pause 50                ' Debounce
12841
12842  getkeyp:
12843     ' Wait for keypress
12844     For col = 0 TO 1        ' 2 columns in keypad
12845        PORTB = 0       ' All output pins low
12846        TRISB = (DCD col) ^ $f3 ' Set one column pin to output
12847        @ NOP
12848        row = PORTB >> 4        ' Read row
12849        
12850        IF row != $f Then gotkey        ' If any keydown, exit
12851        
12852        Spkr = 0
12853     Next col
12854     GoTo getkeyp            ' No keys down, go look again
12855
12856  gotkey: ' Change row and column to key number 0 - 15
12857     key = (col * 4) + (NCD (row ^ $f)) - 1
12858     
12859     ' Translate key to telephone keypad tone
12860     ' 10 = *
12861     ' 11 = #
12862     ' 12 = A
12863     ' 13 = B
12864     ' 14 = C
12865     ' 15 = D
12866     LookUp key,[1,2,3,12,4,5,6,13,7,8,9,14,10,0,11,15],tone
12867     
12868     Return                  ' Subroutine over
I want to eliminate lines that are commented like 12833, 12843, 12859-12865 but not lines that contain comments like lines12834 and 12835 etc...

This:
Code:
 cat -n hrc_60.bas | sed "s/\d*\s*'.*//" | grep -iP "(draw|load)" | cat -n
Eliminates lines that are commented. It also eliminates all trailing comments.

This however (note the space between \s* and ' ):
Code:
 cat -n hrc_60.bas | sed "s/\d*\s* '.*//" | grep -iP "(draw|load)" | cat -n
Eliminates trailing comments leaving commented lines in place.

I think what my rex ex says is match:
- all lines that start with zero or more digits.
- and followed by zero or more whitespaces
- and followed by the character '
- and followed by any number of charcters
- and replace it with nothing

I don't understand why it is removing trailing comments.

Any thoughts/help?
 
Old 11-18-2004, 11:00 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,499

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Code:
sed "s/\d*\s* '.*//"
Quote:
I don't understand why it is removing trailing comments.
It does because both the number and the spaces are optional (*), so the pattern match too any line with a trailing comment prefixed by a space character, both of them being removed.
If you don't want that, insert the start of line token (^) at the beginning of your regexp.
 
Old 11-18-2004, 11:14 AM   #3
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
I think this does what I think your trying to do
Code:
sed "s/^[[:digit:]]*[[:space:]]*'.*//"
Hmm, it shouldn't look like that! It should look like this:-
sed "s/^[[:digit:]]*[[:space:]]*'.*//"

What the ...

That didn't work either.

OK, like this but replace the () with []

sed "s/^((:digit)*((:space)*'.*//"

Oh god, now I've got smiley faces!!! I hope you get the idea, anyway.

Last edited by ahh; 11-18-2004 at 11:22 AM.
 
Old 11-18-2004, 11:24 AM   #4
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Almost.
That regexp matches:
- first occasion in the line that start with zero or more digits.
(it doesn't have to be at the start of the line)
- and followed by zero or more whitespaces
- and followed by the character '
- and followed by any number of charcters
- and replace it with nothing

If you want it to match with the start of the line, add ^ to the regexp.
eg.
Code:
cat -n hrc_60.bas | sed "s/^\d*\s* '.*//" | grep -iP "(draw|load)" | cat -n
that will do what you said the previous regexp would do.

Last edited by ToniT; 11-18-2004 at 11:26 AM.
 
Old 11-18-2004, 11:44 AM   #5
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Original Poster
Rep: Reputation: 32
Everyone seemed to suggest the same thing:
Code:
cat -n hrc_60.bas | sed "s/^\d*\s* '.*//" | grep -iP "(draw|load)" | cat -n
That did not catch any of the comments. It yielded the same result as not having the sed statement in there at all.
I'll post the output put of:
Code:
cat -n hrc_60.bas | grep -iP "(draw|load)"
This is basically the input piped to sed (all 429 lines!). I think there are about 100 +/- lines that are commented out.
Any help you can provide is much appreciated:
Code:
    22  ' Define ONINT_USED to allow use of the boot loader.
    72  VPORT4         VAR   BYTE     'TRACKING REG. FOR UV,DRAWER,ECT
    92  RELEASE_TM     VAR   BYTE     'DRAWER RELEASE SOLENIOD ON TIME
    93  OPEN_DLY       VAR   BYTE     'USED FOR DRAWER RELEASE ERR MESS TIME
    94  DRAWER_FLAG    VAR   BIT      'SET WHEN DRAWER IS CLOSED
    96  LOAD_COMPLETE  VAR   BIT      'USED TO SEE IF LOAD CYCLE IS DONE
    97  LOAD_START     VAR   BIT      'USED TO SEE IF A LOAD CYCLE WAS STARTED
    98  LOADWAIT_FLAG  VAR   BIT      'SET TO TRY LOAD WAIT ONE TIME
    99  LOAD_AFTER     VAR   BYTE     'TEMP REG THAT HOLDS LOAD WAIT TIME
   113  DRAWER_WAS_LEFT_OPEN VAR BIT  'FLAG FOR CLEARING DRAWER MESS
   119  NEST_UP_TM     VAR   BYTE     'TIMER UNLOAD CYCLE
   120  NEST_DLY       VAR   BYTE     'TIMER FOR NEST DOWN TO DRAWER OPEN
   121  UNLOAD_CMPL    VAR   BIT      'FLAG UNLOAD CYCLE
   122  DRW_NOT_RDY    VAR   BIT      'FLAG UNLOAD CYCLE
   123  NEST_DN_FLAG   VAR   BIT      'FLAG UNLOAD CYCLE
   128  NO_LOAD_UNLOAD VAR   BIT      'SET SO WHEN DOING A REPEAT IT WON'T RE-LOAD 
   174  LOAD_WAIT      VAR   BYTE          '100 TIME TO WAIT AFTER CYCLE
   305        'IF TEMP1 = 0 THEN GOTO LOAD_INFOPAC      'HRC 180 REV 2.06
   317  LOAD_INFOPAC:
   465  CNT_LOAD:
   512     GoTo  LOAD_INFOPAC
   527     GoTo   LOAD_MAIN  
   542     IF tone = 1 Then  GoTo  LOAD_MAIN
   559     IF tone = 1 Then  GoTo  LOAD_MAIN 
   576     IF tone = 1 Then  GoTo  LOAD_MAIN 
   593     IF tone = 1 Then  GoTo  LOAD_MAIN 
   610     IF tone = 1 Then  GoTo  LOAD_MAIN 
   627     IF tone = 1 Then  GoTo  LOAD_MAIN 
   644     IF tone = 1 Then  GoTo  LOAD_MAIN
   661     IF tone = 1 Then  GoTo  LOAD_MAIN 
   678     IF tone = 1 Then  GoTo  LOAD_MAIN 
   695     IF tone = 1 Then  GoTo  LOAD_MAIN 
   712     IF tone = 1 Then  GoTo  LOAD_MAIN 
   716  LOAD_MAIN:
   928     IF POWER4 < 11 Then GoTo LOAD_SPEED
   934  LOAD_SPEED:
   935          GoSub MTR_SPEED         'LOAD VALUES IN D TO A
   938  '       GET SAVED VALUES FOR LOAD WAIT TIME
   943     LOAD_WAIT = EEVALUE 
   945     IF LOAD_WAIT > 50 Then
   946        LOAD_WAIT = 0
   948        EEVALUE = LOAD_WAIT
  1172     GoSub        DRAWER_RELEASE
  1176     GoSub        DRW_CLOSED_SW                   'WAIT FOR DRAWER TO CLOSE
  1444     NO_LOAD_UNLOAD = 1
  1454                                               'CLEAR "UNLOAD_CMPL"                                
  1455     UNLOAD_CMPL = 0                           'IF NO LENS SET "UNLOAD_CMPL"
  1456                                               'TO START A UNLOAD CYCLE  
  1460              UNLOAD_CMPL = 1
  1473     DRAWER_FLAG = 0
  1478     SPIN1 = C_SPIN_TIM                   'LOAD SPIN 1 TIME
  1480     CURE_TIME_T = CURE_TIME                      'LOAD CURRENT CURE TIME
  1482     NEST_DLY = 5                         '.5 SEC TIMER NEST DOWN TO DRAWER OPEN
  1484     RELEASE_TM = 5                               'SET DRAWER RELEASE TIME TO .5 SEC
  1485     OPEN_DLY = 5                         'FOR ERROR MESS (DRAWER NOT OPEN IN TIME .5 SEC
  1487     LOAD_START = 0                               'CLEAR LOAD START FLAG
  1501     if PORTC.3 = 0 Then GoTo PH1_NO_SC      'IF LENS AT HOME THEN UNLOAD IT
  1503     UNLOAD_CMPL = 1                              'IF NO LENS THEN DON'T TRY TO
  1504     LOAD_COMPLETE = 1                    'LOAD OR UNLOAD
  1509     IF LOAD_COMPLETE = 1 AND NO_LOAD_UNLOAD = 1 Then
  1510        UNLOAD_CMPL = 1
  1511        NO_LOAD_UNLOAD = 0
  1513        LOAD_COMPLETE = 0
  1514        NO_LOAD_UNLOAD = 0                        'CLEAR FLAG TO TRY LOAD CYCLE
  1540     if UNLOAD_CMPL = 1 Then GoTo PH1CHK_DRAWER
  1542     if NEST_DN_FLAG = 1 Then GoTo PH1_DR_OPEN    '1 = LENS ON 2 BUT DRAWER OPEN
  1546     if DRAWER_FLAG = 0 Then GoTo PH1A
  1579     IF NEST_DLY = 0 Then GoTo PH1_DRAWER_OP
  1583  PH1_DRAWER_OP:
  1586          GoSub   DRAWER_REL_ON
  1590          GoSub   DRAWER_REL_OFF
  1597     IF DRAWER_FLAG = 0 Then GoTo PH1_DR_CL_DONE
  1599     GoSub  DRAWER_NOT_MESS
  1612     UNLOAD_CMPL = 1
  1615  PH1CHK_DRAWER:
  1616     if COATFLUID_OUT = 1 OR WASHFLUID_OUT = 1 OR LOST_COM = 1 Then GoTo PH1A   'IF OUT OF FLUID THEN DON'T LOAD LENS
  1618     if LOAD_COMPLETE = 1 Then GoTo PH1A
  1620     if LOAD_START = 1 Then GoTo PH1A_CHK_VIB
  1624     if DRAWER_FLAG = 0 Then GoTo PH1A          ' 1 IN FLAG = DRAWER CLOSED
  1626     LOAD_START = 1
  1662     LOAD_COMPLETE = 1
  1919     if UNLOAD_CMPL = 0 AND DRAWER_FLAG = 0 Then GoTo PH1_DRAWER_OPEN
  1925  PH1_DRAWER_OPEN:
  1926     GoSub  DRAWER_NOTRDY
  1933     IF LOAD_START = 1 OR UNLOAD_CMPL= 0 Then GoTo CHK_LOAD_START1
  1941  CHK_LOAD_START1:
  1945     UV_COAT_STATUS.7 = 1 AND LOAD_COMPLETE = 1 AND UNLOAD_CMPL = 1 Then GoTo NEXT_PH1 
  1951     IF LOAD_AFTER > 0 Then
  1952        LOAD_AFTER = (LOAD_AFTER - 1)
  1966     if DRAWER_FLAG = 1 Then GoTo PH1_DRAWER_IN
  1968     LOAD_AFTER = LOAD_WAIT
  1971  '       LOAD WAIT ROUTINE
  1976     if DRAWER_FLAG = 0 Then GoTo DEC_WAIT_1
  1978     LOAD_START = 0
  1979     LOAD_COMPLETE = 0
  1981     GoTo  PH1CHK_DRAWER
  1984     if LOAD_AFTER = 0 Then GoTo PH1_DRAWER_IN
  1986     LOAD_AFTER = (LOAD_AFTER - 1)
  1992  PH1_DRAWER_IN: 
  2023     GoSub        DRW_CLOSED_DET                                  'IF REPEAT FLAG IS SET AND DRAWER
  2025     if FALT_REPEAT = 1 AND DRAWER_FLAG = 1 Then GoTo PHASE_1  'IS CLOSED THEN REPEAT WITH WASH
  2027     if FALT_REPEAT = 0 Then GoTo PH1_CNT_PHASE                'AND COAT ONLY OR WAIT FOR DRAWER
  2033     GoSub  DRAWER_NOTRDY
  2061     if DRAWER_FLAG = 1 Then GoTo DRW_CLOSED_FLT1
  2092     GoTo PH1_OPEN_DRAWER
  2094  PH1_OPEN_DRAWER:
  2095     IF DEACTIVATE.3 = 1 Then        'SPIN 3 TURNED ON THEN RELEASE DRAWER
  2096        GoSub     DRAWER_REL_ON           'IF NO LENS THEN DON'T TRY OPEN
  2098        Pause     500                             'DRAWER IF IN SINGLE CYCLE MODE
  2099        GoSub     DRAWER_REL_OFF
  2102        if DRAWER_FLAG = 0 Then GoTo PHASE_2
  2104        GoSub  DRAWER_NOT_MESS
  2221     NO_LOAD_UNLOAD = 1
  2230     UNLOAD_CMPL = 0                                   'CLEARED UNLOAD CYCLE NOT DONE     
  2234     UNLOAD_CMPL = 1
  2247     DRAWER_FLAG = 0
  2250     SPIN1 = C_SPIN_TIM            'LOAD SPIN 1 TIME
  2252     CURE_TIME_T = CURE_TIME       'LOAD CURRENT CURE TIME
  2254     NEST_DLY = 5                  '.5 SEC TIMER NEST DOWN TO DRAWER OPEN
  2256     RELEASE_TM = 5                'DRAWER RELEASE TIME .5 SEC
  2257     OPEN_DLY = 5                  'FOR ERROR MESS (DRAWER NOT OPEN IN TIME .5 SEC
  2259     LOAD_START = 0                'CLEAR LOAD START FLAG
  2273     if PORTC.2 = 0 Then GoTo PH2_NO_SC      'IF LENS AT HOME THEN UNLOAD IT
  2275     UNLOAD_CMPL = 1                              'IF NO LENS THEN DON'T TRY TO
  2276     LOAD_COMPLETE = 1                    'LOAD OR UNLOAD
  2280     IF LOAD_COMPLETE = 1 AND NO_LOAD_UNLOAD = 1 Then
  2281        UNLOAD_CMPL = 1
  2282        NO_LOAD_UNLOAD = 0
  2284        LOAD_COMPLETE = 0                 'CLEAR FLAG TO TRY LOAD CYCLE
  2285        NO_LOAD_UNLOAD = 0
  2312     if UNLOAD_CMPL = 1 Then GoTo PH2CHK_DRAWER
  2314     if NEST_DN_FLAG = 1 Then GoTo PH2_DR_OPEN    '1 = LENS ON 2 BUT DRAWER OPEN
  2318     if DRAWER_FLAG = 0 Then GoTo PH2A
  2351     if NEST_DLY = 0 Then GoTo PH2_DRAWER_OP
  2356  PH2_DRAWER_OP:
  2361     GoSub        DRAWER_REL_ON
  2366     GoSub        DRAWER_REL_OFF
  2376     if DRAWER_FLAG = 0 Then GoTo PH2_DR_CL_DONE
  2378     GoSub  DRAWER_NOT_MESS
  2393     UNLOAD_CMPL = 1
  2396  PH2CHK_DRAWER:
  2397     if COATFLUID_OUT = 1 OR WASHFLUID_OUT = 1 OR LOST_COM = 1 Then GoTo PH2A  'IF OUT OF FLUID THEN DON'T LOAD LENS
  2399     if LOAD_COMPLETE = 1 Then GoTo PH2A
  2401     if LOAD_START = 1 Then GoTo PH2A_CHK_VIB
  2405     if DRAWER_FLAG = 0 Then GoTo PH2A          ' 1 IN FLAG = DRAWER CLOSED
  2407     LOAD_START = 1
  2448     LOAD_COMPLETE = 1
  2706     if UNLOAD_CMPL = 0 AND DRAWER_FLAG = 0 Then GoTo PH2_DRAWER_OPEN
  2712  PH2_DRAWER_OPEN:
  2713     GoSub  DRAWER_NOTRDY
  2721     if LOAD_START = 1 OR UNLOAD_CMPL = 0 Then GoTo CHK_LOAD_START2
  2730  CHK_LOAD_START2:
  2734     UV_COAT_STATUS.7 = 1 AND LOAD_COMPLETE = 1 AND UNLOAD_CMPL = 1 Then GoTo NEXT_PH2
  2750     if DRAWER_FLAG = 1 Then GoTo PH2_DRAWER_IN
  2752     LOAD_AFTER = LOAD_WAIT
  2755  '       LOAD WAIT ROUTINE
  2760     if DRAWER_FLAG = 0 Then GoTo DEC_WAIT_2
  2762     LOAD_START = 0
  2763     LOAD_COMPLETE = 0
  2765     GoTo  PH2CHK_DRAWER
  2768     IF LOAD_AFTER = 0 Then GoTo PH2_DRAWER_IN
  2770     LOAD_AFTER = (LOAD_AFTER - 1)
  2777  PH2_DRAWER_IN:
  2809     GoSub        DRW_CLOSED_DET                                  'IF REPEAT FLAG IS SET AND DRAWER
  2811     if FALT_REPEAT = 1 AND DRAWER_FLAG = 1 Then GoTo PHASE_2  'IS CLOSED THEN REPEAT WITH WASH
  2813     if FALT_REPEAT = 0 Then GoTo PH2_CNT_PHASE                'AND COAT ONLY OR WAIT FOR DRAWER
  2819     GoSub  DRAWER_NOTRDY
  2847     if DRAWER_FLAG = 1 Then GoTo DRW_CLOSED_FLT2        
  2878     GoTo PH2_OPEN_DRAWER
  2880  PH2_OPEN_DRAWER:
  2881     IF DEACTIVATE.4 = 1 Then   'SPIN 4 TURNED ON THEN RELEASE DRAWER
  2882        GoSub     DRAWER_REL_ON     'IF NO LENS THEN DON'T TRY OPEN
  2883        Pause     500               'DRAWER IF IN SINGLE CYCLE MODE
  2885        GoSub     DRAWER_REL_OFF
  2888        if DRAWER_FLAG = 0 Then GoTo PHASE_3
  2890        GoSub  DRAWER_NOT_MESS
  3010     NO_LOAD_UNLOAD = 1                   'SET IF ON REPEAT CYCLE
  3020     UNLOAD_CMPL = 0                                   'CLEARED UNLOAD CYCLE NOT DONE 
  3024           UNLOAD_CMPL = 1
  3038     NO_LOAD_UNLOAD = 0
  3039     DRAWER_FLAG = 0
  3042     SPIN1 = C_SPIN_TIM            'LOAD SPIN 1 TIME
  3044     CURE_TIME_T = CURE_TIME                      'LOAD CURRENT CURE TIME
  3046     NEST_DLY = 5                  '.5 SEC TIMER NEST DOWN TO DRAWER OPEN
  3048     RELEASE_TM = 5                'DRAWER RELEASE TIME .5 SEC
  3049     OPEN_DLY = 5                  'FOR ERROR MESS (DRAWER NOT OPEN IN TIME .5 SEC
  3051     LOAD_START = 0                'CLEAR LOAD START FLAG
  3065     if PORTC.1 = 0 Then GoTo PH3_NO_SC      'IF LENS AT HOME THEN UNLOAD IT
  3067     UNLOAD_CMPL = 1                              'IF NO LENS THEN DON'T TRY TO
  3068     LOAD_COMPLETE = 1                    'LOAD OR UNLOAD
  3072     IF LOAD_COMPLETE = 1 AND NO_LOAD_UNLOAD = 1 Then
  3073        UNLOAD_CMPL = 1
  3074        NO_LOAD_UNLOAD = 0
  3076        LOAD_COMPLETE = 0                 'CLEAR FLAG TO TRY LOAD CYCLE
  3077        NO_LOAD_UNLOAD = 0
  3104     if UNLOAD_CMPL = 1 Then GoTo PH3CHK_DRAWER
  3106     if NEST_DN_FLAG = 1 Then GoTo PH3_DR_OPEN    '1 = LENS ON 2 BUT DRAWER OPEN
  3110     if DRAWER_FLAG = 0 Then GoTo PH3A
  3143     if NEST_DLY = 0 Then GoTo PH3_DRAWER_OP
  3148  PH3_DRAWER_OP:
  3153     GoSub        DRAWER_REL_ON
  3158     GoSub        DRAWER_REL_OFF
  3169     if DRAWER_FLAG = 0 Then GoTo PH3_DR_CL_DONE
  3171     GoSub  DRAWER_NOT_MESS
  3186     UNLOAD_CMPL = 1
  3189  PH3CHK_DRAWER:
  3190     if COATFLUID_OUT = 1 OR WASHFLUID_OUT = 1 OR LOST_COM = 1 Then GoTo PH3A  'IF OUT OF FLUID THEN DON'T LOAD LENS
  3192     if LOAD_COMPLETE = 1 Then GoTo PH3A
  3194     if LOAD_START = 1 Then GoTo PH3A_CHK_VIB
  3198     if DRAWER_FLAG = 0 Then GoTo PH3A          ' 1 IN FLAG = DRAWER CLOSED
  3200     LOAD_START = 1
  3243     LOAD_COMPLETE = 1
  3505     if UNLOAD_CMPL = 0 AND DRAWER_FLAG = 0 Then GoTo PH3_DRAWER_OPEN
  3511  PH3_DRAWER_OPEN:
  3512     GoSub  DRAWER_NOTRDY
  3520     if LOAD_START = 1 OR UNLOAD_CMPL = 0 Then GoTo CHK_LOAD_START3
  3529  CHK_LOAD_START3:
  3533     UV_COAT_STATUS.7 = 1 AND LOAD_COMPLETE = 1 AND UNLOAD_CMPL = 1 Then GoTo NEXT_PH3
  3548     IF DRAWER_FLAG = 1 Then GoTo PH3_DRAWER_IN
  3550     LOAD_AFTER = LOAD_WAIT
  3553  '       LOAD WAIT ROUTINE
  3558     if DRAWER_FLAG = 0 Then GoTo DEC_WAIT_3
  3560     LOAD_START = 0
  3561     LOAD_COMPLETE = 0
  3562     GoTo  PH3CHK_DRAWER
  3565     if LOAD_AFTER = 0 Then GoTo PH3_DRAWER_IN
  3567     LOAD_AFTER = (LOAD_AFTER - 1)
  3572  PH3_DRAWER_IN:
  3607     if FALT_REPEAT = 1 AND DRAWER_FLAG = 1 Then GoTo PHASE_3 'DRAWER IS CLOSED THEN REPEAT
  3615     GoSub DRAWER_NOTRDY
  3644     GoSub        DRW_CLOSED_DET                    'IF DRAWER TIME OUT
  3646     IF DRAWER_FLAG = 1 Then GoTo DRW_CLOSED_FLT3
  3678     GoTo PH3_OPEN_DRAWER
  3680  PH3_OPEN_DRAWER:
  3681     IF DEACTIVATE.1 = 1 Then        'SPIN 1 TURNED ON THEN RELEASE DRAWER
  3682        GoSub     DRAWER_REL_ON           'IF NO LENS THEN DON'T TRY OPEN
  3683        Pause     500                             'DRAWER IF IN SINGLE CYCLE MODE
  3685        GoSub     DRAWER_REL_OFF
  3689        IF DRAWER_FLAG = 0 Then GoTo PHASE_4
  3691        GoSub  DRAWER_NOT_MESS
  3813     NO_LOAD_UNLOAD = 1
  3823     UNLOAD_CMPL = 0                      'CLEARED UNLOAD CYCLE NOT DONE 
  3827     UNLOAD_CMPL = 1
  3841     DRAWER_FLAG = 0
  3844     SPIN1 = C_SPIN_TIM         'LOAD SPIN 1 TIME
  3846     CURE_TIME_T = CURE_TIME    'LOAD CURRENT CURE TIME
  3848     NEST_DLY = 5               '.5 SEC TIMER NEST DOWN TO DRAWER OPEN
  3850     RELEASE_TM = 5             'DRAWER RELEASE TIME .5 SEC
  3851     OPEN_DLY = 5               'FOR ERROR MESS (DRAWER NOT OPEN IN TIME .5 SEC
  3853     LOAD_START = 0             'CLEAR LOAD START FLAG
  3867     if PORTC.4 = 0 Then GoTo PH4_NO_SC      'IF LENS AT HOME THEN UNLOAD IT
  3869     UNLOAD_CMPL = 1                              'IF NO LENS THEN DON'T TRY TO
  3870     LOAD_COMPLETE = 1                    'LOAD OR UNLOAD
  3874     IF LOAD_COMPLETE = 1 AND NO_LOAD_UNLOAD = 1 Then
  3875        UNLOAD_CMPL = 1
  3876        NO_LOAD_UNLOAD = 0
  3878        LOAD_COMPLETE = 0                 'CLEAR FLAG TO TRY LOAD CYCLE
  3879        NO_LOAD_UNLOAD = 0
  3907     if UNLOAD_CMPL = 1 Then GoTo PH4CHK_DRAWER
  3909     if NEST_DN_FLAG = 1 Then GoTo PH4_DR_OPEN    '1 = LENS ON 1 BUT DRAWER OPEN
  3913     if DRAWER_FLAG = 0 Then GoTo PH4A
  3946     if NEST_DLY = 0 Then GoTo PH4_DRAWER_OP
  3951  PH4_DRAWER_OP:
  3956     GoSub        DRAWER_REL_ON
  3961     GoSub        DRAWER_REL_OFF
  3972     if DRAWER_FLAG = 0 Then GoTo PH4_DR_CL_DONE
  3974     GoSub  DRAWER_NOT_MESS
  3989     UNLOAD_CMPL = 1
  3992  PH4CHK_DRAWER:
  3993     if COATFLUID_OUT = 1 OR WASHFLUID_OUT = 1 OR LOST_COM = 1 Then GoTo PH4A  'IF OUT OF FLUID THEN DON'T LOAD LENS
  3995     if LOAD_COMPLETE = 1 Then GoTo PH4A
  3997     if LOAD_START = 1 Then GoTo PH4A_CHK_VIB
  4001     if DRAWER_FLAG = 0 Then GoTo PH4A          ' 1 IN FLAG = DRAWER CLOSED
  4003     LOAD_START = 1
  4044     LOAD_COMPLETE = 1
  4303     if UNLOAD_CMPL = 0 AND DRAWER_FLAG = 0 Then GoTo PH4_DRAWER_OPEN
  4309  PH4_DRAWER_OPEN:
  4310     GoSub  DRAWER_NOTRDY
  4317     IF  LOAD_START = 1 OR UNLOAD_CMPL = 0 Then GoTo CHK_LOAD_START4
  4325  CHK_LOAD_START4:
  4329     UV_COAT_STATUS.7 = 1 AND LOAD_COMPLETE = 1 AND UNLOAD_CMPL = 1 Then GoTo NEXT_PH4
  4346     IF DRAWER_FLAG = 1 Then GoTo PH4_DRAWER_IN
  4348     LOAD_AFTER = LOAD_WAIT
  4351  '       LOAD WAIT ROUTINE
  4356     IF DRAWER_FLAG = 0 Then GoTo DEC_WAIT_4
  4358     LOAD_START = 0
  4359     LOAD_COMPLETE = 0
  4360     GoTo  PH4CHK_DRAWER
  4363     IF LOAD_AFTER = 0 Then GoTo PH4_DRAWER_IN
  4365     LOAD_AFTER = (LOAD_AFTER - 1)
  4371  PH4_DRAWER_IN:
  4404     GoSub        DRW_CLOSED_DET                                'IF REPEAT FLAG IS SET AND DRAWER
  4406     if FALT_REPEAT = 1 AND DRAWER_FLAG = 1 Then GoTo PHASE_4 'IS CLOSED THEN REPEAT WITH WASH
  4408     if FALT_REPEAT = 0 Then GoTo PH4_CNT_PHASE                 'AND COAT ONLY OR WAIT FOR DRAWER
  4414     GoSub  DRAWER_NOTRDY
  4442     GoSub        DRW_CLOSED_DET                       'IF DRAWER TIME OUT
  4444     IF DRAWER_FLAG = 1 Then GoTo DRW_CLOSED_FLT4
  4458     GoTo CNT_PHASE4                           'IF DRAWER NOT CLOSED SET FLAG                          
  4475     GoTo PH4_OPEN_DRAWER
  4477  PH4_OPEN_DRAWER:
  4478     IF DEACTIVATE.2 = 1 Then        'SPIN 2 TURNED ON THEN RELEASE DRAWER
  4479        GoSub     DRAWER_REL_ON           'IF NO LENS THEN DON'T TRY OPEN
  4480        Pause     500                             'DRAWER IF IN SINGLE CYCLE MODE
  4482        GoSub     DRAWER_REL_OFF
  4485        IF DRAWER_FLAG = 0 Then GoTo PHASE_1
  4487        GoSub  DRAWER_NOT_MESS
  4535  DRAWER_NOTRDY:
  4537          LCDOut $fe, $94, "Push In Empty Drawer"      'move to line 3
  4538          LCDOut $fe, $D4, "  To Off-Load Lens  "      'move to line 4
  4554  DRAWER_NOT_MESS:
  4555          LCDOut $fe, $D4, "ERR: DRAWER NOT OPEN"      'move to line 4
  4648     'IF tone = 2 THEN  GOTO  DRAWER_M    'NEXT BUTTON 
  4691     LCDOut $fe, $94, "Load Scrap Lens Then"   'move to line 3
  4749     GoSub        DRAWER_RELEASE
  4753     GoSub        DRW_CLOSED_DET                'WAIT FOR DRAWER TO CLOSE
  4755     if DRAWER_FLAG = 0 Then GoTo CP_DRW_WAIT
  4881     GoSub        DRAWER_RELEASE
  4926  SET_POS: 'based on home/load position
  5036     LCDOut $fe, $94, "Load Dosimeter Then"   'move to line 3
  5122     GoSub        DRAWER_RELEASE
  5150     GoSub        DRAWER_RELEASE
  5154     GoSub        DRW_CLOSED_DET                'WAIT FOR DRAWER TO CLOSE
  5156     if DRAWER_FLAG = 0 Then GoTo UV_DRW_WAIT
  5365     LCDOut $fe, $94, "Load Scrap Lens Then"   'move to line 3
  5578     GoSub        DRAWER_RELEASE
  6276  SET_VALUES:                                     ' IF NOT LOAD DEFUALT
  6342     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  6373     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  6404     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  6457     IF tone = 6 Then  GoTo  DRAWER_M                'UP BUTTON
  6578     'IF tone = 2 THEN  GOTO  DRAWER_M        'NEXT BUTTON 
  6945     'IF tone = 2 THEN  GOTO  DRAWER_M             'NEXT BUTTON 
  7448     IF tone = 13 Then  GoTo DRAWER_M         'DWN BUTTON
  7493     'IF tone = 13 THEN  GOTO drawer_m        'DWN BUTTON
  7567  DRAWER_M:
  7570     LCDOut "Open Drawer   [Diag]"
  7581     GoSub IN_REED1           'WAIT FOR DRAWER TO OPEN
  7585     LCDOut $fe, $D4, "Drawer: OPEN   "        'move to line 4
  7589     LCDOut $fe, $D4, "Drawer: CLOSED "        'move to line 4
  7605     GoSub   DRAWER_RELEASE
  8075     IF tone = 13 Then  GoTo LOADWAIT_M               'DWN BUTTON    
  8097  '       LOAD WAIT MENU   JR 12/17-18
  8099  LOADWAIT_M:
  8102     LOAD_WAIT = EEVALUE 
  8104  LOADWAIT_M1B:
  8107     LCDOut "Load-Wait Set [Conf]"
  8110  LOADWAIT_LP:
  8111     LCDOut $Fe, $94, "      Time: ", DEC1 (LOAD_WAIT /10), ".", DEC1 LOAD_WAIT, " Sec "
  8120     'IF tone = 2 THEN  GOTO  LOADWAIT_2_LP            'NEXT BUTTON 
  8127     GoTo LOADWAIT_LP
  8130     IF LOAD_WAIT >= 50 Then RST_LWAIT
  8132     LOAD_WAIT = (LOAD_WAIT + 1)
  8134     EEVALUE = LOAD_WAIT
  8137     GoTo  LOADWAIT_LP
  8140     LOAD_WAIT = 0
  8142     EEVALUE = LOAD_WAIT
  8145     GoTo LOADWAIT_LP
  8169     IF tone = 6 Then  GoTo  LOADWAIT_M           'UP BUTTON
  8179  ''''''''''''''''''''''''''''' Defaults for Cure time, Coat Dwell, and Load Wait '''''''''''''
  8195  ''''''''''''''''''''''''''''' Load Wait default = 2.5 Seconds '''''''''''''''''''''''''''''''
  8216     IF C_CODE1 > 9 Then LOAD_DEFAULT
  8219  LOAD_DEFAULT:
  8265     'IF tone = 2 THEN  GOTO  DRAWER_M          'NEXT BUTTON 
  8285     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  8316     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  8347     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  8387     IF PCODE1 > 9 Then GoTo LOAD_C_CODES
  8390  LOAD_C_CODES:
  8444     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  8480     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  8516     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  8587     'IF tone = 2 THEN  GOTO  DRAWER_M            'NEXT BUTTON 
  9718  '       BIT 1  DRAWER OUT
  9719  '       BIT 2  DRAWER IN
  9856  DRAWER_RELEASE:
  9859     PORTD = VPORT4                     'DRAWER RELEASE SOLENOID
  9873     IF DRAWER_FLAG = 0 Then GoTo DRAWER_RTN
  9875     GoSub DRAWER_NOT_MESS
  9880  DRAWER_RTN:
  9885  DRAWER_REL_ON:
  9895     PORTD = VPORT4                     'DRAWER RELEASE SOLENOID
  9901  DRAWER_REL_OFF:
  9904     PORTD = VPORT4                          'DRAWER RELEASE SOLENOID
 10086     GoTo HALT_UNLOAD_LP
 10095  HALT_UNLOAD_LP:
 10106     LCDOut $fe, $D4, "    UNLOAD LENS     "        'move to line 4
 10111        GoSub CHECK_DRAWER_FOR_UNLOADING
 10112        GoTo UNLOAD_NEXT
 10115     GoTo  HALT_UNLOAD_LP
 10117  UNLOAD_NEXT:
 10131     IF PORTC.2 = 1 Then GoTo HALT_UNLOAD_LP  'SEE IF LENS ON 3RD STATION
 10143     GoSub        DRAWER_RELEASE
 10144     GoTo HALT_UNLOAD_LP
 10151     IF PORTC.1 = 1 Then GoTo HALT_UNLOAD_LP 'SEE IF LENS ON 4TH STATION
 10163     GoSub        DRAWER_RELEASE
 10164     GoTo HALT_UNLOAD_LP
 10171     IF PORTC.4 = 1 Then GoTo HALT_UNLOAD_LP  'SEE IF LENS ON 1ST STATION
 10183     GoSub        DRAWER_RELEASE
 10184     GoTo HALT_UNLOAD_LP
 10191     IF PORTC.3 = 1 Then GoTo HALT_UNLOAD_LP 'SEE IF LENS ON 2ND STATION
 10203     GoSub DRAWER_RELEASE
 10204     GoTo HALT_UNLOAD_LP
 10206  CHECK_DRAWER_FOR_UNLOADING:
 10207     DRAWER_WAS_LEFT_OPEN = 0
 10209  DRAWER_LOOP:
 10212     GoSub DRW_CLOSED_DET          'WAIT FOR DRAWER TO CLOSE
 10214     IF DRAWER_FLAG = 0 Then
 10215        DRAWER_WAS_LEFT_OPEN = 1 'set flag to clear mess after drawer is closed
 10218        LCDOut $fe, $94, "ERR:CLOSE DRAWER NOW"      'move to line 3
 10220        GoTo DRAWER_LOOP
 10223     IF DRAWER_WAS_LEFT_OPEN = 1 Then
 10371  '       110MS PULSE STARTS LOAD SEQUENCE
 10406     PORTD.7 = 0                  'SENDS 90MS PULSE LOAD COMMAND
 10416     Pause 2                              'START DATA LOAD PULSE 
 10418     PORTD.7 = 0                  'SENDS 2MS PULSE TO START LOAD SEQUENCE
 11053     PORTD.7 = 0                  'SENDS 90MS PULSE LOAD DATA COMMAN 
 11065     PORTD.7 = 0                  'SENDS 2MS PULSE TO START DATA LOAD
 11146        GoSub  CHN_BOTTLE_NOW         'DISPLAY ERROR "MUST LOAD COATING TO CONTINUE
 11195        GoSub  CHN_BOTTLE_NOW             'DISPLAY ERROR "MUST LOAD COATING TO CONTINUE"
 11283     LCDOut $fe, $94, "ERROR: Must Load    "                'move to line 3
 11598        IF POSITION = 1 Then 'handle door opened before index started so we unload at home
 12095     IF PORTC.2 = 1 Then GoTo DRAWER_OPEN
 12097     DRAWER_FLAG = 1                     '1 = CLOSED
 12100  DRAWER_OPEN:
 12101     DRAWER_FLAG = 0
 12116     IF PORTC.2 = 1 Then GoTo DRW_LOOP  'WAIT HERE UNTIL DRAWER IS CLOSED
 12616     GoSub LOAD_DAC
 12620     GoSub LOAD_DAC
 12659  LOAD_DAC:
 
Old 11-18-2004, 11:55 AM   #6
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
Replace "\d" with "[[ :digit: ]]" and "\s" with "[[ :space: ]]"

Except dont have any spaces between the "[]" and the ":", I had to put them there or - well, see my previous post

I dont believe it!!!

[ [ : digit : ] ] and [ [ : space : ] ], but with no spaces.

Last edited by ahh; 11-18-2004 at 11:58 AM.
 
Old 11-18-2004, 01:09 PM   #7
cmfarley19
Member
 
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Original Poster
Rep: Reputation: 32
Well, with bits and pieces of help from everyone I came up with:
[code}cat -n hrc_60.bas | sed "s/^[ [ :space: ] ] *[ [ :digit: ] ]*[ [ :space: ] ]*'.*//" | grep -iP "(draw|load)" |cat -n[/code]

That seemed to do the trick. Kind of ugly, but gets the job done.

Thank you all.

PS - ahh, same posting problem!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
regex Perl help igotlongestname Programming 2 09-14-2005 07:51 PM
sed / regex question whysyn Linux - General 3 06-28-2005 02:11 PM
regex problem with sed ta0kira Programming 7 06-20-2005 12:33 AM
Regex Help cmfarley19 Programming 5 03-31-2005 10:13 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM


All times are GMT -5. The time now is 06:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration