How to read from the window and compare in Ncurses?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to read from the window and compare in Ncurses?
# 1  
Old 03-17-2015
How to read from the window and compare in Ncurses?

How would I go about having ncurses look at a coordinate, read what character is there, and see if it is the same as an other character? I've been trying to use inch(), but I don't think I'm doing it right. Here's the portion of the code I'm struggling with.

Code:
//Code to scroll left
chtype inch(void);
chtype winch(WINDOW *win);
chtype mvinch(int y, int x);
chtype mvwinch(WINDOW *win, int y, int x);
int scrollX = 0;
int scrollY = 0;
int tempscrollX = 0;
int checkfarend = 1; //Checks to see if there is already an X on the right when looping
else if(CX == -1 ||CY == -1)
{
    while (scrollY < height)
    {
        while (scrollX < width)
        {
            if (inch(scrollX,ScrollY) == 'X')
            {
                tempscrollX = scrollX - 1;
                if(tempscrollX < 0)
                {
                    tempscrollX = width - 1;
                    while(checkfarend == 1)
                    {

                        if(inch(tempscrollX,scrollY) == 'X')
                        {
                            tempscrollX--;
                        }
                        else
                        {
                            checkfarend = 0;
                        }
                    }
                }
                mvaddch(scrollY,tempscrollX,'X');
                mvaddch(scrollY,scrollX,' ');
                checkfarend = 1;
            }
            else
            {
                scrollX++;
            }
            scrollX = 0;
            scrollY++;
        }
    }
    scrollX = 0;
    scrollY = 0;
}

I'm on 32-bit ubuntu, version 14.10.
Thanks for the help!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Read two file and compare the line

Hello Guys I need to read and compare two file, one file contains hostname, and others contain hostname and IP@, and the objective is to read each file and compare if line in file1 equal to first word in the second file2 file1 file2 this is my first code fqdn_hosts=list.txt... (2 Replies)
Discussion started by: Abdellah
2 Replies

2. Shell Programming and Scripting

Re: Read lines and compare in a loop

I have a file which has following content: NAME=ora.DG1.dg TYPE=ora.diskgroup.type TARGET=ONLINE STATE=ONLINE NAME=ora.DG2.dg TYPE=ora.diskgroup.type TARGET=ONLINE STATE=ONLINE NAME=ora.DG3.dg TYPE=ora.diskgroup.type TARGET=ONLINE STATE=ONLINE NAME=ora.DG4.dg... (7 Replies)
Discussion started by: rcc50886
7 Replies

3. Shell Programming and Scripting

How to Read & Compare Two Files

Hi forumers, How is it going. Ok i need some advice on the following problem. I have 2 files to read and compare data.FileA and FileB. FileA will return either status 1 or 0. FileB on the other hand is trickier and has the following details:- Count DeviceID CurrentStatus ... (7 Replies)
Discussion started by: prakash1111
7 Replies

4. Shell Programming and Scripting

need to read lines in file and compare value in if not working

Hello, I have this file that sometime contains 0 lines and sometimes 1 or more. It's supposed to then put the result (could be 0 or 1 or 2 or more) into a variable. Then it's supposed to echo using an if else statement depending on the value of the variable. flagvar='wc -l $tempfile |... (1 Reply)
Discussion started by: script_op2a
1 Replies

5. Shell Programming and Scripting

Read Two lines in a CSV File and Compare

Hi , I have a CSV file ( file.csv) with some data as below: A,1,abc,x,y,z,,xyz,20100101,99991231 A,1,abc,x,y,z,234,xyz,20100101,99991231 I have to delete the duplicate line based on unique identifiers which are values in the fields- 2,3,4,8.These coulmns in both the rows have same... (6 Replies)
Discussion started by: Sheel
6 Replies

6. Shell Programming and Scripting

Read from a file and compare

i want a shell script to read the a list of numbers from a file and compare with a unique number with the list. FOR EXAMPLE : abc.lst file contains d following 2343 3214 45654 563456 5436 Unique number is 2342 (6 Replies)
Discussion started by: pgmfourms
6 Replies

7. Shell Programming and Scripting

Read window Excel sheet to unix

I would like to read data from excel sheet as a input to a shell script. Myproblem is the excel sheet is in windows. How can I write a shell script to read data from that excel sheet? How can I do that?. (4 Replies)
Discussion started by: vj8436
4 Replies

8. Shell Programming and Scripting

How to read and compare multiple fields in a column at the same time

Hi, Currently I am coding up a nasty way of reading file input using *cat* rather than *read*. My text input looks like TextA 100 TextB 110 TextC 120 Currently I am using cat |while read line to read the first column and second column fields. cat foo.txt|while read line do ... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

9. UNIX for Dummies Questions & Answers

Compare 2 files and output result in pop up window

Need help ! how do i compare 2 files and if there is a difference, output a massage in a pop up window? the script meant to run using crontab. (2 Replies)
Discussion started by: hongsh
2 Replies

10. Shell Programming and Scripting

read a file and compare

hi how can i read a file using the unix script and check for one or more field value for a predefined status/value for example : the file contains the following text Name IP Address/Mask Type Connection Status mgmt-eth0(1) ... (2 Replies)
Discussion started by: aemunathan
2 Replies
Login or Register to Ask a Question