summaryrefslogtreecommitdiff
path: root/1088/CH5/EX5.7
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /1088/CH5/EX5.7
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '1088/CH5/EX5.7')
-rwxr-xr-x1088/CH5/EX5.7/Example7.sce104
-rwxr-xr-x1088/CH5/EX5.7/Result7.pdf91
-rwxr-xr-x1088/CH5/EX5.7/Result7.txt91
3 files changed, 286 insertions, 0 deletions
diff --git a/1088/CH5/EX5.7/Example7.sce b/1088/CH5/EX5.7/Example7.sce
new file mode 100755
index 000000000..cce0b8443
--- /dev/null
+++ b/1088/CH5/EX5.7/Example7.sce
@@ -0,0 +1,104 @@
+clear
+flag=1
+clc
+mode(-1)
+
+printf("Example 7 : Show the method of file handling using the od command \n")
+disp("****************************************************************")
+disp("Answer : ")
+disp("INSTRUCTIONS : ")
+printf("\nHere all instructions are preloaded in the form of a demo\nPRESS ENTER AFTER EACH COMMAND to see its RESULT\nPRESS ENTER AFTER EACH RESULT TO GO TO THE NEXT COMMAND\n")
+halt('.............Press [ENTER] to continue.....')
+halt("")
+clc
+printf("\tUNIX SHELL SIMULATOR(DEMO VERSION WITH PRELOADED COMMANDS)\n\n\n")
+
+
+printf("\n# Enter the name of the file which you want to access \n\n")
+nam=input('$ od ','s')
+printf("# This searches for a file named %s \n\n",nam)
+
+
+if ~isfile(nam) then
+ flag=0
+ printf("\n%s : file not found \n",nam)
+ printf("# Create a new file named %s?\n # y : Yes \n # n : No \n",nam)
+ resp=input('','s')
+ if resp=='y' then
+ flag=1
+ printf("\n#***Enter the contents of the file %s*****\n# [Enter ^ in a newline to end and close the file]\n",nam)
+ printf('\n\n$ cat > %s #to create a file named %s and fill its contents\n',nam,nam)
+ fhdr=mopen(nam,'wt')
+ i=1
+ while %t
+ cont=input(string(i)+'. ','s')
+ if (cont=='^') then
+ break
+ end
+ mfprintf(fhdr,"%s\n",cont)
+ i=i+1
+ end
+ mclose(fhdr)
+ end
+end
+
+if flag==1 then
+ i=1
+ clc
+ printf("\n $ od %s #to display %s in octal characters\n\n",nam,nam)
+ printf("\n ===========> %s <============\n\n\n",nam)
+ fhdr=mopen(nam,'rt')
+ while %t
+ [n,a]=mfscanf(fhdr,"%c")
+ if meof(fhdr) then
+ break
+ end
+ printf(" %o",ascii(a))
+ if ascii(a)==10 then
+ printf("\n")
+ end
+ i=i+1
+ end
+ mclose(fhdr)
+ printf("\n\n%d characters present in the file.\n[hit ENTER to continue]\n",i)
+ halt('')
+else
+ printf("\n\n# file %s is not found and not created also\n",nam)
+end
+
+flag=flag+1
+
+octs=blanks(0)
+if flag==2 then
+ i=1
+ clc
+ printf("\n $ od -bc %s #to display %s in octal characters\n\n",nam,nam)
+ printf("\n ===========> %s <============\n\n\n",nam)
+ fhdr=mopen(nam,'rt')
+ while %t
+ [n,a]=mfscanf(fhdr,"%c")
+ if meof(fhdr) then
+ break
+ end
+ printf(" %c ",a)
+ octs=octs+string(dec2oct(ascii(a)))+' '
+ if ascii(a)==10 then
+ printf("%s\n\n",octs)
+ clear('octs')
+ octs=blanks(0)
+ end
+ i=i+1
+ end
+ mclose(fhdr)
+ printf("\n\n%d characters present in the file.\n[hit ENTER to continue]\n",i)
+ halt('')
+else
+ printf("\n\n# file %s is not found and not created also\n",nam)
+end
+
+printf("\n\n\n$ exit #To exit the current simulation terminal and return to Scilab console\n\n")
+halt("........# (hit [ENTER] for result)")
+//clc()
+
+printf("\n\n\t\t\tBACK TO SCILAB CONSOLE...\nLoading initial environment')
+sleep(1000)
diff --git a/1088/CH5/EX5.7/Result7.pdf b/1088/CH5/EX5.7/Result7.pdf
new file mode 100755
index 000000000..65157c1ca
--- /dev/null
+++ b/1088/CH5/EX5.7/Result7.pdf
@@ -0,0 +1,91 @@
+ ans =
+
+ 1.
+
+-->exec("Example7.sci",-1)
+Current date is 05-Jun-2013
+
+Welcome to the Textbook Companionship Project 2013
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Book Title : UNIX CONCEPTS AND APPLICATIONS
+
+ Book Edition : 4
+
+ Book Author : Sumitabha Das
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Code Author : Pranav Bhat T
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Chapter Number : 5
+
+ Chapter Title : HANDLING ORDINARY FILES
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+Example 7 : Show the method of file handling using the od command
+
+ ****************************************************************
+
+ Answer :
+
+ INSTRUCTIONS :
+
+Here all instructions are preloaded in the form of a demo
+PRESS ENTER AFTER EACH COMMAND to see its RESULT
+PRESS ENTER AFTER EACH RESULT TO GO TO THE NEXT COMMAND
+.............Press [ENTER] to continue..... UNIX SHELL SIMULATOR(DEMO VERSION WITH PRELOADED COMMANDS)
+
+
+
+# Enter the name of the file which you want to access
+
+# This searches for a file named hithern
+
+
+ $ od hithern #to display hithern in octal characters
+
+
+ ===========> hithern <============
+
+
+ 110 151 40 111 40 141 155 40 120 162 141 156 141 166 12
+ 111 40 141 155 40 141 156 40 151 156 164 145 162 156 40 141 164 40 106 117 123 123 105 40 160 162 157 152 145 143 164 12
+ 111 40 150 157 160 145 40 164 150 151 163 40 160 162 157 152 145 143 164 40 150 145 154 160 163 40 163 164 165 144 145 156 164 163 40 167 145 154 154 12
+ 124 150 141 156 153 40 131 157 165 12
+
+
+98 characters present in the file.
+[hit ENTER to continue]
+
+ $ od -bc hithern #to display hithern in octal characters
+
+
+ ===========> hithern <============
+
+
+ H i I a m P r a n a v
+ 110 151 40 111 40 141 155 40 120 162 141 156 141 166 12
+
+ I a m a n i n t e r n a t F O S S E p r o j e c t
+ 111 40 141 155 40 141 156 40 151 156 164 145 162 156 40 141 164 40 106 117 123 123 105 40 160 162 157 152 145 143 164 12
+
+ I h o p e t h i s p r o j e c t h e l p s s t u d e n t s w e l l
+ 111 40 150 157 160 145 40 164 150 151 163 40 160 162 157 152 145 143 164 40 150 145 154 160 163 40 163 164 165 144 145 156 164 163 40 167 145 154 154 12
+
+ T h a n k Y o u
+ 124 150 141 156 153 40 131 157 165 12
+
+
+
+98 characters present in the file.
+[hit ENTER to continue]
+
+
+
+$ exit #To exit the current simulation terminal and return to Scilab console
+
+........# (hit [ENTER] for result)
+
+ BACK TO SCILAB CONSOLE...
+Loading initial environment
+-->diary(0)
diff --git a/1088/CH5/EX5.7/Result7.txt b/1088/CH5/EX5.7/Result7.txt
new file mode 100755
index 000000000..65157c1ca
--- /dev/null
+++ b/1088/CH5/EX5.7/Result7.txt
@@ -0,0 +1,91 @@
+ ans =
+
+ 1.
+
+-->exec("Example7.sci",-1)
+Current date is 05-Jun-2013
+
+Welcome to the Textbook Companionship Project 2013
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Book Title : UNIX CONCEPTS AND APPLICATIONS
+
+ Book Edition : 4
+
+ Book Author : Sumitabha Das
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Code Author : Pranav Bhat T
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Chapter Number : 5
+
+ Chapter Title : HANDLING ORDINARY FILES
++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+Example 7 : Show the method of file handling using the od command
+
+ ****************************************************************
+
+ Answer :
+
+ INSTRUCTIONS :
+
+Here all instructions are preloaded in the form of a demo
+PRESS ENTER AFTER EACH COMMAND to see its RESULT
+PRESS ENTER AFTER EACH RESULT TO GO TO THE NEXT COMMAND
+.............Press [ENTER] to continue..... UNIX SHELL SIMULATOR(DEMO VERSION WITH PRELOADED COMMANDS)
+
+
+
+# Enter the name of the file which you want to access
+
+# This searches for a file named hithern
+
+
+ $ od hithern #to display hithern in octal characters
+
+
+ ===========> hithern <============
+
+
+ 110 151 40 111 40 141 155 40 120 162 141 156 141 166 12
+ 111 40 141 155 40 141 156 40 151 156 164 145 162 156 40 141 164 40 106 117 123 123 105 40 160 162 157 152 145 143 164 12
+ 111 40 150 157 160 145 40 164 150 151 163 40 160 162 157 152 145 143 164 40 150 145 154 160 163 40 163 164 165 144 145 156 164 163 40 167 145 154 154 12
+ 124 150 141 156 153 40 131 157 165 12
+
+
+98 characters present in the file.
+[hit ENTER to continue]
+
+ $ od -bc hithern #to display hithern in octal characters
+
+
+ ===========> hithern <============
+
+
+ H i I a m P r a n a v
+ 110 151 40 111 40 141 155 40 120 162 141 156 141 166 12
+
+ I a m a n i n t e r n a t F O S S E p r o j e c t
+ 111 40 141 155 40 141 156 40 151 156 164 145 162 156 40 141 164 40 106 117 123 123 105 40 160 162 157 152 145 143 164 12
+
+ I h o p e t h i s p r o j e c t h e l p s s t u d e n t s w e l l
+ 111 40 150 157 160 145 40 164 150 151 163 40 160 162 157 152 145 143 164 40 150 145 154 160 163 40 163 164 165 144 145 156 164 163 40 167 145 154 154 12
+
+ T h a n k Y o u
+ 124 150 141 156 153 40 131 157 165 12
+
+
+
+98 characters present in the file.
+[hit ENTER to continue]
+
+
+
+$ exit #To exit the current simulation terminal and return to Scilab console
+
+........# (hit [ENTER] for result)
+
+ BACK TO SCILAB CONSOLE...
+Loading initial environment
+-->diary(0)