We help IT Professionals succeed at work.

New podcast episode! Our very own Community Manager, Rob Jurd, gives his insight on the value of an online community. Listen Now!

x

CODE CORRECT

gfdas
gfdas asked
on
406 Views
Last Modified: 2010-04-05
CODE CORRECT

Hi, I need to set ARRAY1 FROM ARRAY2 for + 1 VALUE ! ! ! ! !
Without USING A LOOP OR CONST ! ! ! ! !

Thank You.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Math;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

const TESTARRAY1 : array [0..10] of integer = (0,1,2,3,4,5,6,7,8,9,10);

procedure TForm1.Button1Click(Sender: TObject);
var TESTARRAY: array [0..10] of integer;
begin
//So, I need to set TESTARRAY FROM TESTARRAY1 ! ! ! ! !
//(INC) ALL VALUES FOR (1)
//WITHOUT usig LOOP like FOR, WHILE, REPEAT..UNTIL ETC.
//OR CONST
//FOR TESTARRAY VARIABLE ! ! ! ! !
//(0+1,1+1,2+1,3+1,4+1,5+1,6+1,7+1,8+1,9+1,10+1)
end;

end.
Comment
Watch Question

MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
can you explain why you want this, that makes an answer probably a lot easier.

Commented:
Given the const array is exactly as You specified You could do

  Move(TESTARRAY1[1],TESTARRAY[0],10*SizeOf(integer));
  TESTARRAY[10] := TESTARRAY1[10]+1;

Or add one more element to const array to avoid second code line.

Author

Commented:
Hi, I want to be sure that it's possible today,
in computers and compilers, to do that.
So, not to use LOOP, like
FOR, WHILE, REPEAT..UNTIL ETC. OR CASE.
But to easy CALCULATE numbers LIKE +1 FOR ALL INTEGERS IN ARRAY.

Thank You.
Tomas Helgi JohannssonDatabase Administrator / Software Engineer
CERTIFIED EXPERT

Commented:
   Hi!

It is NOT possible to traverse and increment a value of in
particular position of an array WITHOUT using FOR, WHILE, REPEAT..UNTIL ETC. OR CASE.

Regards,
   Tomas Helgi
MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
only if you type it out completely:

TESTARRAY[0] := TESTARRAY1[0] + 1;
TESTARRAY[1] := TESTARRAY1[1] + 1;

etc
Tomas Helgi JohannssonDatabase Administrator / Software Engineer
CERTIFIED EXPERT

Commented:
That is not good programming
when it comes to code maintainance. :)

Regards,
   Tomas Helgi
MerijnBSr. Software Engineer
CERTIFIED EXPERT

Commented:
no, but what question asker wants is not good programming :)
Software Developer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.