21
edits
Changes
→Blog Posts
*: And then:
*: Connection > Data > Terminal-type string = linux (This step must be done when first connecting through putty!)
*:: Or if you have already connected, type in (export TERM="linux") without brackets
* [https://cs.senecac.on.ca/~chris.szalwinski/resources/borland.html Guide for Using Borland 5.5]
*: Note that to change the cmd.exe window size, right click on the top bar -> Properties -> Layout Tab
=Due Dates=
*Fri Mon Oct 12th15th, 23:59
=Help=
==Help Needed==
<!-- Thanks Omkar, that was all I needed to understand how past this test.
* Omkar Parmar
Re : Amir, after previous test, without pressing any key it will display like this
+--------------------------------------------------------------------+
|Test 4.17: console.edit() initial corrections, Offset: The offset is|
|set to 10 that is invalid and it should be corrected to 5. The |
|function should terminate returning 0. |
+--------------------------------------------------------------------+
+--------------------+
| |
+--------------------+
PASSED, hit any key to continue
* Re: Jessica, My question is what is the instruction for test 4.17, but thank you for replying.
* Re: Amir.
Amir, Try to re-download the cio_test.cpp from git and re-compile it again. I had some problem with you. It works fine after I re-upload the text.cpp file. I do not know what happened. - Jessica Park
* Re: Omkar.
Return value of edit is correct. How we should act in test 4.17? pressing arrow keys?
* Student: '''Omkar Parmar'''
'''Amir''' Check return value of edit function
* My program fails at the following test. Anyone knowswhy should it returns Unkown keycode? How it should be handled then! - Amir
+--------------------------------------------------------------------+
|Test 4.17: console.edit() initial corrections, Offset: The offset is|
|set to 10 that is invalid and it should be corrected to 5. The |
|function should terminate returning 0. |
+--------------------------------------------------------------------+
+--------------------+
| |
+--------------------+
- console.edit() was supposed to return Unknown Keycode, Dec: 0 Hex: 0
but instead it returned: ENTER, Dec: 10 Hex: A
FAILED, hit any key to continue
*"My program is working completely fine in window but when I am trying to testing it on matrix it gives same error as below."- Tejas Patel
To Omkar Parmar: "Write [export TERM="linux"] then try it again"-Tejas Patel
* Student :Omkar Parmar
'''HOME,END F1, F2, F3, F4, F5''' keys are not working while testing linux.
HOME,END are return Unknown key and
F1 A
F2 B
F3 C
F4 D
F5 E.
* After copying cio_test.o, it has changed MY NAME and R.01 to "CIO TESTER PROGRAM" and "R0.93". I can assume what happened it, but I just wonder it is ok? - Rody Choi <==I think that's it. cio_test.o cannot be edited. I guess cio_test.cpp is submitted as well. - Linpei Fan ===> I guess so. Thanks, Lily - Rody Choi
*I keep getting messages " '''The row and column of the terminal must be maximum of 30 by 100.''' press any key to quit
" when I tried to test it on matrix account. is there anyone who has same problem? - Jessica Park
:: You need to resize the terminal window because the test program restricts it to 24x80 to 30x100 (rows x cols). You can also edit the size thru preferences/settings if you don't like trial and error - Michael Wang <=== Hey,you have to use the "PUTTY" - Rody Choi
<==Just using the "PUTTY" anything will be fined - Jay Feng =>
*When running on matrix, whenever I press Home, End, or Insert, the program exits rather than run the code I wrote. It works fine on Visual Studio however. I complied with -lncurses. - Ronny Wan <-- Check Notes section on this page and follow "Using Linux..." instruction even for Windows version of Putty - Hiroshi Takemoto
<===Try to compile it in a Linux OS, such as Fedora, using VM. It will be fine. - Linpei Fan ===> -->
==Blog Posts==
<!-- *Ok, I did something with the display function. It's not 1 line but it's different from the code that's online and it has less loops. I sincerely hope it's not what was shown in class today, though, lol. I could be just writing remembered code which would be funny. Sad. But funny. Blog: [http://ashtramwasser.blogspot.ca/ ashtramwasser1] * Questions about terminating the process of editing by pressing '''ENTER''', '''TAB''', '''ESCAPE''', '''UP''', '''DOWN'''.... and what your program doing after pressing '''ESCAPE''' were not clear for me, so I decided to ask Fardad, here the answers.Blog: [http://stanislavatseneca.blogspot.ca/ stanislavatseneca] * Here's a post of my troubleshooting issues with compiling the code on OSX. It covers both the terminal c++ compiler and Xcode. [http://gambitkun.blogspot.ca/2012/10/working-with-console-part-2-mac.html mgauer]** hi guys i would like to know ho you solved these two questions?in the first one the test ask:PrnTextBox(1, 5, 70, 8, "Test 4.2: console.edit() initial corrections, Offset: The offset is set to 10 that is invalid and it should be corrected to 5. "////////// "HIT ENTER ONLY to test!");in the second test the same question is asked:PrnTextBox(1, 5, 70, 8, "Test 4.17: console.edit() initial corrections, Offset: The offset is set to 10 that is invalid and it should be corrected to 5. " ////////// "The function should terminate returning 0."); but how am i going to return 0 and at the same time set the offset to 10. I do not understand those two questions. -->
=Learning Outcome=
void display(const char* str, int row, int col, int fieldLen=0);
This method outputs the C-style, null-terminated string pointed to by str starting at row row and column col of the screen in a field of fieldLen characters. Row value 0 refers to the top row, and column value 0 refers to the left-most column. If the string is longer than fieldLen, your function displays the first fieldLen characters. If the string is shorter than fieldLen, your function displays the portion of the entire string that fits on the screen, followed by enough trailing spaces to fill out the field completely. <s>If fieldLen is 0, your function displays the portion of the entire string with no trailing spaces. </s> EDIT: In the video lecture, Fardad explains that if fieldLen is 0, the entire string is displayed. Your function positions the cursor after the last character displayed. Your function does not flush the output buffer. The results are undefined if the starting position of the string is not within the dimensions of the screen. '''Bonus: display() in One Line'''* [http://sobrisk.tumblr.com/post/33006756229/display-part-2 Matt's Blog : Display (Part 2)]* [http://chgw.wordpress.com/2012/10/07/display/ Guiwen's Blog : Update Matt's display()]
===edit() method===
<big><pre>
int edit(char *str, int row, int col, int fieldLength, int maxStrLength,
This method is to be written in two steps.
====Step one====
''Ignore the last two arguments of the the edit method '''(IsTextEditor and ReadOnly)''' and write the method as follows:''
This method edits the C-style, null-terminated string pointed by str. The parameter row holds the row (0 is the top row) of the string on the screen. The parameter col holds the starting column (0 is the left-most column) on the screen. The parameter fieldLength holds the length of the editable field. The string may be larger than the field itself, in which case part of the string is hidden from view. The parameter maxStrLength holds the maximum length of the string, excluding the null byte. The parameter insertMode points to a bool variable that holds the current insert mode of the string. The parameter insertMode receives the address of a variable that stores the current editing mode - insert or overwrite. The parameter strOffset points to an int variable that holds the initial offset of the string within the field; that is, the index of the character in the string that initially occupies the first character position in the field. The parameter curPosition points to an int variable that holds the initial cursor position within the field; that is, the index of the character in the field at which the cursor is initially placed.
* '''''Initial Corrections'''''*:If the initial offset is beyond the end of the string, your function resets the offset to the length of the string; that is, to the index of the character immediately beyond the end of the string. If no offset variable is pointed to; that is, if the address of the variable is NULL, your function sets the offset to the index of the first character in the string; that is, to 0.(to do this have a local variable for the offset that holds zero to be pointed instead of an external variable) *:If the initial cursor position is beyond the end of the field, your function resets the position to the last character in the field. If the position is beyond the end of the string, your function resets the position to that immediately beyond the end of the string. If no cursor position variable is pointed to; that is, if the address of the variable is NULL, your function sets the cursor position to the first position in the field; that is, to position 0.(like the offset, to do this have a local variable for the cursor position that holds zero to be pointed instead of an external variable)
Your function does not allow the cursor to move before the start of the field or past the end of the field. If the field ends at the right edge of the screen, your function does not allow the cursor to the right of that edge.
You may assume that it is the calling program's responsibility to ensure that the string array is large enough to handle maxStrLength characters and that the starting screen position provides enough room (on the screen) for the field, etc.
{| class="wikitable" border="0"
|+
! Edit Method!! Interface
|-
| [[File:editString.png|500px|thumb|center|Edit Method Function Diagram]] ||
[[File:interface.png|400px|thumb|center|Interface Diagram]]
|}
====Step two====
Local Mac: (use -lcurses to link curses library)
c++ bconsole.cpp console.cpp cio_test.cpp -lcurses-Wno-write-strings
matrix: GNU (use -lncurses to link ncurses library)
g++ bconsole.cpp console.cpp cio_test.cpp -lncurses-Wno-write-strings
For submission purposes, your solution must compile, link, and run without errors in each environment.
==Tester Demo==
To see how tester runs, you can run on Matrix (only use putty with the setting stated at [[#Notes|Notes]]) run:
<big><pre>
$ ~fardad.soleimanloo/cio_test
</pre></big>
==Submission details==
The due date for submission is: Mon Oct 15th 23:59
When your program passed all the tests, on matrix, create a directory and copy all the source files (console.cpp, console.h, bconsole.cpp, bconsole.h) into it. Then copy cio_test.o from "~fardad.soleimanloo" and then compile your code with your professors version of cio_test (i.e cio_test.o) and run it. If all the tests are passed successfully, an email will be sent to your professor automatically with your source code (console.h and console.cpp) attached to it.