Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14007

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How can one protect the piracy of his software? Posted by networm32 on 5 Oct 2001 at 1:12 PM
Hi. what i am trying to do is indenting the fields of a record while printing, so that they are printed under their heading, even though the record lengths vary.
Dont know what I am doing wrong, perhaps the function? :

FUNCTION PADSPACES(VALUE : STRING, MAXLENGTH : INTEGER) :STRING;

VAR
L, COUNTER : INTEGER;

BEGIN
L := length (Value);
MaxLength := (Maxlength - L);
FOR COUNTER := L TO MAXLENGTH DO
BEGIN
INSERT (' ', vALUE, COUNTER);
END;
END;

{**********************]
{PART OF THE MAIN PROGRAM}
{READING FROM A FILE AND PRINTING UNDER HEADERS}

WITH RECORD DO

BEGIN
ASSIGN (PRINTER, 'PRN');
REWRITE PRINTER;
PADSPACES (DATE,12);
PADSPACES (YEAR,10);
PRINTLINE := CONCAT(PADSPACES(VALUE,12),PADSPACES(VALUE,10));
WRITELN (PRINTER, PRINTLINE);

...I am not sure about the ending part of function, a function must end with an assignment statement, no?
Also not sure about the printline thing, AM I PUTTING 'VALUE' correctly??

10x

Report
Re: Help Posted by Manning on 5 Oct 2001 at 3:39 PM
: Hi. what i am trying to do is indenting the fields of a record while printing, so that they are printed under their heading, even though the record lengths vary.
: Dont know what I am doing wrong, perhaps the function? :
:
: FUNCTION PADSPACES(VALUE : STRING, MAXLENGTH : INTEGER) :STRING;
:
: VAR
: L, COUNTER : INTEGER;
:
: BEGIN
: L := length (Value);
: MaxLength := (Maxlength - L);
: FOR COUNTER := L TO MAXLENGTH DO
: BEGIN
: INSERT (' ', vALUE, COUNTER);
: END;
: END;
:
: {**********************]
: {PART OF THE MAIN PROGRAM}
: {READING FROM A FILE AND PRINTING UNDER HEADERS}
:
: WITH RECORD DO
:
: BEGIN
: ASSIGN (PRINTER, 'PRN');
: REWRITE PRINTER;
: PADSPACES (DATE,12);
: PADSPACES (YEAR,10);
: PRINTLINE := CONCAT(PADSPACES(VALUE,12),PADSPACES(VALUE,10));
: WRITELN (PRINTER, PRINTLINE);
:
: ...I am not sure about the ending part of function, a function must end with an assignment statement, no?
: Also not sure about the printline thing, AM I PUTTING 'VALUE' correctly??
:
: 10x
:

The way you are calling PADSPACES I would say it is not a function. What you should do is declare it like so:

procedure PadSpaces(var Value: String; MaxLength: Integer);


If you really wanted it to be a function just add this to the last line (before the end;)

PadSpaces := Value;


But you would have to change the way you are calling it.

Report
Re: Help Posted by networm32 on 6 Oct 2001 at 12:12 AM
: : Hi. what i am trying to do is indenting the fields of a record while printing, so that they are printed under their heading, even though the record lengths vary.
: : Dont know what I am doing wrong, perhaps the function? :
: :
: : FUNCTION PADSPACES(VALUE : STRING, MAXLENGTH : INTEGER) :STRING;
: :
: : VAR
: : L, COUNTER : INTEGER;
: :
: : BEGIN
: : L := length (Value);
: : MaxLength := (Maxlength - L);
: : FOR COUNTER := L TO MAXLENGTH DO
: : BEGIN
: : INSERT (' ', vALUE, COUNTER);
: : END;
: : END;
: :
: : {**********************]
: : {PART OF THE MAIN PROGRAM}
: : {READING FROM A FILE AND PRINTING UNDER HEADERS}
: :
: : WITH RECORD DO
: :
: : BEGIN
: : ASSIGN (PRINTER, 'PRN');
: : REWRITE PRINTER;
: : PADSPACES (DATE,12);
: : PADSPACES (YEAR,10);
: : PRINTLINE := CONCAT(PADSPACES(VALUE,12),PADSPACES(VALUE,10));
: : WRITELN (PRINTER, PRINTLINE);
: :
: : ...I am not sure about the ending part of function, a function must end with an assignment statement, no?
: : Also not sure about the printline thing, AM I PUTTING 'VALUE' correctly??
: :
: : 10x
: :
:
: The way you are calling PADSPACES I would say it is not a function. What you should do is declare it like so:
:
:
: procedure PadSpaces(var Value: String; MaxLength: Integer);
: 

:
: If you really wanted it to be a function just add this to the last line (before the end;)
:
:
: PadSpaces := Value;
: 

:
: But you would have to change the way you are calling it.
:

Yes I want it as a function, in order that it will return the string, with a number of spaces at the end, so that I can concat all the fields, and print the file line by line.
I arranged it like this, but still not working, how can I change the way I am calling it, as you said?


: FUNCTION PADSPACES(VALUE : STRING, MAXLENGTH : INTEGER) :STRING;
: :
: : VAR
: : L, COUNTER : INTEGER;
: :
: : BEGIN
: : L := length (Value);
: : MaxLength := (Maxlength - L);
: : FOR COUNTER := L TO MAXLENGTH DO
: : BEGIN
: : INSERT (' ', vALUE, COUNTER);
: : END;
: : PadSpaces := Value;
END;
: :
: : {**********************]
: : {PART OF THE MAIN PROGRAM}
: : {READING FROM A FILE AND PRINTING UNDER HEADERS}
: :
: : WITH RECORD DO
: :
: : BEGIN
: : ASSIGN (PRINTER, 'PRN');
: : REWRITE PRINTER;
: : Value := Date;
PADSPACES (Value,12);
Value := Year;
: : PADSPACES (Value,10);
Printline := '';
: : PRINTLINE := CONCAT(PADSPACES(VALUE,12),PADSPACES(VALUE,10));
: : WRITELN (PRINTER, PRINTLINE);

10x for help

Report
Re: Help Posted by Manning on 6 Oct 2001 at 10:00 AM
: Yes I want it as a function, in order that it will return the string, with a number of spaces at the end, so that I can concat all the fields, and print the file line by line.
: I arranged it like this, but still not working, how can I change the way I am calling it, as you said?

If you want to use it as a function, you have to call it as one. For example:

ReturnValue := FunctionName(Paramater1, Paramter2, etc..);

So try:

WriteLn(Printer, PadSpaces(Date) + PadSpaces(Year));


Report
Re: Help Posted by networm32 on 7 Oct 2001 at 11:22 AM
ok.

10x very much. With a little more modification it worked.

10x fory your help.

NET^WORM






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.