delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/11/10:00:19

From: Stan Moore <smoore AT exis DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: editor
Date: Sat, 11 Nov 2000 10:00:14 -0500
Message-ID: <r7nq0t4bn991luk26ltsg4062bkg9l32u9@4ax.com>
References: <8ui41b$2nn$1 AT lacerta DOT tiscalinet DOT it>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
NNTP-Posting-Host: digital-4-208.exis.net
X-Trace: 11 Nov 2000 09:57:22 -0500, digital-4-208.exis.net
Lines: 58
Organization: A Customer of Exis Net Inc
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sat, 11 Nov 2000 01:32:41 +0100, "abacuc" <f DOT onorati AT tiscalinet DOT it>
wrote:

>#include<stdio.h>
>#include<pc.h>
>#include<keys.h>
>#include<conio.h>
>int main()
>{
>  int car;
>  FILE *pf;
>
>  clrscr();
>  pf=fopen("prova.c","w");
>  while((car=getxkey())!=K_F1)
>  {
>     putch(car);
>     fputc(car,pf);
>  }
>  fclose(pf);
>  return 0;
>}

I was able to reproduce your problem here. I  think your problem is
that you are bypassing the normal sytem handling of "return". Normally
the system should handle the converting from the external or system
representation of return and the internal representation. in this case
teh getxkey isn't returning the typical dos system "return", it only
gives you the linefeed. So I added a test for K_Return and hacked in a
quick fix. 

#include <stdio.h>
#include <pc.h>
#include <keys.h>
#include <conio.h>
int main()
{
  int car;
  FILE *pf;

  clrscr();
  pf=fopen("prova.c","w");
  while((car=getxkey())!=K_F1)
  {
    if (car == K_Return) {
      car = '\n';
      putch('\r');
    }

     putch(car);
     fputc(car,pf);
  }
  fclose(pf);
  return 0;
}

Anyway, this version works here :) I added the putch('\r') to clean up
the screen display. 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019