CODE CORRECT

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.
gfdasAsked:
Who is Participating?
 
ZhaawZSoftware DeveloperCommented:
>> Hi, I want to be sure that it's possible today,
>> in computers and compilers, to do that.

It should NOT be possible in "computers" (you can, for example, say CPU to move 1 32bit value to CPU register, to increment it and then move it back to memory, then to do it with another 32bit value etc, but it's a loop technically; but I don't think you can say "RAM" to "increment all values in memory range between $xxxxxxxx and $xxxxxxxx and to treat values in this range as 32bit [un]signed integers").

It *could* be possible in some compilers and interpreters (actually - in languages, not in compilers or interpreters) which do a lot of things for programmer (and therefore make programmers dumber than they used to be).

Is it really a big and, well, impassable problem for you to write your own function that does this?
0
 
MerijnBSr. Software EngineerCommented:
can you explain why you want this, that makes an answer probably a lot easier.
0
 
mokuleCommented:
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.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
gfdasAuthor 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.
0
 
Tomas Helgi JohannssonCommented:
   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
0
 
MerijnBSr. Software EngineerCommented:
only if you type it out completely:

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

etc
0
 
Tomas Helgi JohannssonCommented:
That is not good programming
when it comes to code maintainance. :)

Regards,
   Tomas Helgi
0
 
MerijnBSr. Software EngineerCommented:
no, but what question asker wants is not good programming :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.