![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Using notEmpty
, you readily can weed out empty strings:
Food method definition class eatOnlyVegetables: aFile |inputStream string | inputStream := File pathName: aFile. [inputStream atEnd] whileFalse: [(string := inputStream nextLine) notEmpty ifTrue: [Transcript show: string printString; cr]]. inputStream close Workspace Food eatOnlyVegetables: 'c:\test\foods.dta' Transcript 'V Broccoli 3 16 9 0.5c ' 'D Butter 37 0 0 1.0tsp avoid' 'V Carrots 1 33 4 0.5c good for rabbits' 'V Corn 1 23 6 0.5c' 'V Cabbage 2 14 3 0.5c' 'D Milk 54 45 32 1.0c whole milk'