70 likes | 365 Views
Files in Pseudocode. Prepared by: Careene McCallum-Rodney. Append to file example. OPEN FILE "loginInfo.txt" in APPEND mode IF "loginInfo.txt" NOT OPEN THEN PRINT "File cannot open“ ELSE FILE WRITE user[c].username, user[c].password ENDIF
E N D
Files in Pseudocode Prepared by: Careene McCallum-Rodney
Append to file example OPEN FILE "loginInfo.txt" in APPEND mode IF "loginInfo.txt" NOT OPEN THEN PRINT "File cannot open“ ELSE FILE WRITE user[c].username, user[c].password ENDIF CLOSE FILE "loginInfo.txt“
Write to file example OPEN FILE "loginInfo.txt" in WRITE mode IF "loginInfo.txt" NOT OPEN THEN PRINT "File cannot open“ ELSE FOR c = 0 TO numUsers-1 DO FILE WRITE user[c].username, user[c].password ENDFOR ENDIF CLOSE FILE "loginInfo.txt“
Read from file example • OPEN FILE "loginInfo.txt" in READ mode • IF "loginInfo.txt" NOT OPENED THEN • PRINT "File cannot open" • ELSE • FOR c = 0 TO numUsers-1 DO • FILE READ user[c].username, user[c].password • ENDFOR • ENDIF • CLOSE FILE "loginInfo.txt"