LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-24-2005, 11:00 PM   #1
zhyjanet
LQ Newbie
 
Registered: Mar 2005
Posts: 10

Rep: Reputation: 0
help me out here on DOS to Linux transition with C


Can anybody tell me what this script below do and how to convert it to Linux system? This script was used under MS-DOS. I am new to C programming so bear with me.


#include <time.h>
#include <graph.h>

wait(tsec) /* wait tsec seconds */
float tsec;
{
time_t start, finish;
double difftime(),delta,delta1;
struct videoconfig config;
struct rccoord rcoord1,rcoord2;
char buff[40];

if (tsec>10 ){
_getvideoconfig(&config);
rcoord1=_gettextposition();
}
time(&start); /* get start time */
time(&finish); /* get stop time */
while ((delta=difftime(finish,start))<tsec) { /* set up timer countdown */
if(tsec>10&&((delta-delta1)>=1)) {
sprintf(buff,"Timer ---[%g] \0",tsec-delta);
_settextposition(-100,60);
_outtext(buff);
delta1=delta;
}
time(&finish);

}
if (tsec>10)
_settextposition(rcoord1.row,rcoord1.col);
}
 
Old 03-25-2005, 12:01 AM   #2
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Shure, I am not gunna write the script for you, but just look into the "curses" library for that text output. The program looks really simple. Although I could understand it allot better if you would put it between [ code ] [ /code ] tags (with out the spaces).
 
Old 03-25-2005, 12:37 AM   #3
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Yes The_Nerd is right ncurses you need to use see http://www.gnu.org/software/ncurses/ncurses.html and
http://cyberciti.biz/nixcraft/forum/viewtopic.php?t=53
 
Old 03-25-2005, 08:16 AM   #4
TheLinuxDuck
Member
 
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
Uhm.. no you don't need ncurses (the typical replacement for the MSDOS conio lib).

In fact, unless you're going to be doing alot of fancy text-based graphical work in this program, I'd argue against it. ncurses is great when you need serious functionality. But when you don't, or only need cursor movement, and text colors, you don't need the bloat of curses.

Use ansi escape characters instead.

Here's a thread where they are discussed. I'd opt for this any day over curses -- why add that extra program overhead for a few simple functions?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ok, I decided to make Linux my main system... now please help me in the transition! RobertoBech Mandriva 11 03-09-2004 08:18 PM
My Transition to Linux Plan. rvijay Linux - Newbie 7 08-24-2003 10:12 PM
Want to make full transition to linux but... jpc82 Linux - Software 7 06-05-2003 06:27 AM
Newbie with some Windows > Linux transition questions. KiLLaWaBBiT Linux - General 7 03-28-2003 05:40 AM
Transition from Windows to Linux (IBM) mcleodnine General 3 08-12-2001 03:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration