answersLogoWhite

0

REM initialise arrays

count%=1

DIM first$(10)

DIM last$(10)

DIM address1$(10)

DIM address2$(10)

DIM postcode$(10)

DIM phone$(10)

DIM dob$(10)

DIM email$(10)

REM read file

infile%= OPENIN ("U: "

WHILE NOT EOF# (infile%)

LF=10

INPUT# infile%, text$

IF ASC(text$) = LF THEN text$ = MID$(text$,2)

REM ignore blank lines

REM add 8 field values to arrays

FOR field%=1TO8

compos%=INSTR(text$,",")

value$= LEFT$(text$,compos%-1)

IF field%=1 THEN last$(count%) = value$

IF field%=2 THEN first$(count%) = value$

IF field%=3 THEN address1$(count%) = value$

IF field%=4 THEN address2$(count%) = value$

IF field%=5 THEN postcode$(count%) = value$

IF field%=6 THEN phone$(count%) = value$

IF field%=7 THEN dob$(count%) = value$

IF field%=8 THEN email$(count%) = value$

text$=MID$(text$,compos%+1)

REM remove value and comma from existing string

NEXT field%

count%=count%+1

ENDWHILE

PRINT last$(count%)

REM DO Search

REPEAT

surnamesearch$=""

monthsearch%=0

INPUT "Search for (S)urname or (M)onth or (Q)uit?" choice$

REM Search surnames

IF choice$="S" OR choice$="s" THEN

REM Get search term

WHILE surnamesearch$=""

INPUT "Enter surname:" surnamesearch$

ENDWHILE

REM loop through array

FOR i%=1 TO 6

IF INSTR(last$(i%),surnamesearch$)THEN

COLOUR 3

PRINT first$(i%)

PRINT last$(i%)

PRINT address1$(i%)

PRINT address2$(i%)

PRINT postcode$(i%)

PRINT phone$(i%)

PRINT dob$(i%)

PRINT email$(i%)

PRINT "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _"

COLOUR 0

ENDIF

NEXT i%

ENDIF

REM search months

IF choice$="M" OR choice$="m" THEN

REM Get search term

WHILE monthsearch%>12 OR monthsearch%<1

INPUT "Enter Month (MM) : " monthsearch%

ENDWHILE

REM format month to 2 character string with slashes for searching

search$=STR$(monthsearch%)

IF LEN(search$)=1 THEN

search$="0" +search$

ENDIF

search$="/"+search$+"/"

REM loop through array

FOR i%=1 TO 6

IF INSTR(dob$(i%),search$) THEN

COLOUR 3

PRINT first$(i%)

PRINT last$(i%)

PRINT address1$(i%)

PRINT address2$(i%)

PRINT postcode$(i%)

PRINT phone$(i%)

PRINT dob$(i%)

PRINT email$(i%)

PRINT "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ "

COLOUR 0

ENDIF

NEXT i%

ENDIF

UNTIL choice$="Q" OR choice$="q"

CLS

PRINT "goodbye"

User Avatar

Wiki User

13y ago

What else can I help you with?