Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
SWIs and BASIC file reading/writing in C++ (reply to #86
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Jonathan Graham Harston  
View profile   Translate to Translated (View Original)
 More options 21 Oct, 22:32
Newsgroups: comp.sys.acorn.programmer
From: j...@arcade.demon.co.uk (Jonathan Graham Harston)
Date: 21 Oct 2009 22:32:32 +0100
Local: Wed 21 Oct 2009 22:32
Subject: SWIs and BASIC file reading/writing in C++ (reply to #86
Jonathan Graham Harston of fidonet#2:250/3 wrote:

> garethlock wrote:
> > I understand the command side of things, but I need to be able to
> > convert files written with BASICs PRINT# command. That is why I need
> > either customised routines to do it, or how BASIC does it, so I can

> Otherwise, I could through some C code together to add to the VB
> implementation.

Ok, will http://mdfs.net/Info/Comp/BBCBasic/ProgTips do?

--
J.G.Harston - j...@arcade.demon.co.uk - mdfs.net/User/JGH
Whitby Yards Gazetteer - http://mdfs.net/Docs/Books/YofWhitby/Gazetteer


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeff  
View profile   Translate to Translated (View Original)
 More options 22 Oct, 08:07
Newsgroups: comp.sys.acorn.programmer
From: jeff <jeffrey.a.dogg...@gmail.com>
Date: Thu, 22 Oct 2009 00:07:25 -0700 (PDT)
Local: Thurs 22 Oct 2009 08:07
Subject: Re: SWIs and BASIC file reading/writing in C++ (reply to #86

> Jonathan Graham Harston of fidonet#2:250/3 wrote:
> Ok, willhttp://mdfs.net/Info/Comp/BBCBasic/ProgTipsdo?

Difficult to say as the BBCFile and BBCFile.c links both 404

Jeff


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Graham Harston  
View profile   Translate to Translated (View Original)
 More options 23 Oct, 00:05
Newsgroups: comp.sys.acorn.programmer
From: j...@arcade.demon.co.uk (Jonathan Graham Harston)
Date: 23 Oct 2009 00:05:57 +0100
Local: Fri 23 Oct 2009 00:05
Subject: Re: SWIs and BASIC file reading/writing in C++ (reply to #86

jeffrey.a.dogg...@gmail.com wrote:
> > Ok, will http://mdfs.net/Info/Comp/BBCBasic/ProgTips do?

> Difficult to say as the BBCFile and BBCFile.c links both 404

Doh! I'd uploaded it as BBCFiile.c ! Blame 12-point Trinity ;)

--
J.G.Harston - j...@arcade.demon.co.uk - mdfs.net/User/JGH
A Review of Sheffield City Council's Members' Allowances Scheme
                                  See http://mdfs.net/payreform


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeff  
View profile   Translate to Translated (View Original)
 More options 23 Oct, 08:20
Newsgroups: comp.sys.acorn.programmer
From: jeff <jeffrey.a.dogg...@gmail.com>
Date: Fri, 23 Oct 2009 00:20:55 -0700 (PDT)
Local: Fri 23 Oct 2009 08:20
Subject: Re: SWIs and BASIC file reading/writing in C++ (reply to #86

> Jonathan Graham Harston of fidonet#2:250/3 wrote:
> Ok, willhttp://mdfs.net/Info/Comp/BBCBasic/ProgTipsdo?

In file BBCFile.c:

Function void bbc_WrStr(FILE * handle, char *str) won't work.

You've muddled up | and || in the function bbc_RdInt()
You've missed out the '*' in all of the handles.
In the function "int bbc_RdStr(FILE handle)" you've forgotten to put
the NULL terminator on the end of the string and to allow for it
in the malloc. A common error by C newbies. Plus the off-by-one error
as well.
You've also made the common error of declaring unsigned numbers as
signed (e.g. val in the same function - a string length can never be
negative so why use a signed number?)
And finally you've used malloc() without checking for the NULL return
code.

char * bbc_RdStr (FILE * handle)
{
  unsigned int val;
  char *str;
  char *p;

  val = fgetc (handle);
  if (val != 0)
    return (NULL);             /* Not a string in the data-stream */

  val = fgetc (handle);
  str = malloc (val + 1);    /* One extra for the string terminator */
  if (str == NULL)             /* NEVER use malloc without checking
for the out-of-memory condition */
    return (NULL);

  p = str + val;
  *p-- = 0;                 /* Terminate the string with a null */

  if (val)                    /* Anything to copy? */
  {
    do
    {
      *p-- = fgetc (handle);
    } while (--val);
  }

  return (str);

}

Jeff

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Graham Harston  
View profile   Translate to Translated (View Original)
 More options 24 Oct, 17:51
Newsgroups: comp.sys.acorn.programmer
From: j...@arcade.demon.co.uk (Jonathan Graham Harston)
Date: 24 Oct 2009 17:51:12 +0100
Local: Sat 24 Oct 2009 17:51
Subject: Re: SWIs and BASIC file reading/writing in C++ (reply to #86

jeffrey.a.dogg...@gmail.com wrote:
> > Jonathan Graham Harston of fidonet#2:250/3 wrote:
> > Ok, willhttp://mdfs.net/Info/Comp/BBCBasic/ProgTipsdo?

> In file BBCFile.c:

[Snip list of mistakes]

Ta. I threw the initial code togther from memory. I also have a
nagging feeling that WrReal and RdReal probably won't work as they
assume that the compiled C program is holding reals in memory
identically to BASIC. They probably need to explicitly calculate
the values.

--
J.G.Harston - j...@arcade.demon.co.uk - mdfs.net/User/JGH
The most perfect world is an imperfect world as the imperfections
give people a reason to strive to change it.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google