• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

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.
0
gfdas
Asked:
gfdas
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now