Autor Beitrag
Stefan-W
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 21.02.05 20:16 
Hi Leut's

Also ich hab ein Prob mit ner Variable... und zwar will ich in einer Schleife folgendes Problem losen...

ich hab den Code...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
Ico01.Handle:=ExtractIcon(Application.Handle,Pchar(Programm11.Icon),Programm11.IconNr);
Ico01.Handle:=ExtractIcon(Application.Handle,Pchar(Programm12.Icon),Programm12.IconNr);
Ico01.Handle:=ExtractIcon(Application.Handle,Pchar(Programm13.Icon),Programm13.IconNr);
Ico01.Handle:=ExtractIcon(Application.Handle,Pchar(Programm14.Icon),Programm14.IconNr);
Ico01.Handle:=ExtractIcon(Application.Handle,Pchar(Programm15.Icon),Programm15.IconNr);
Ico01.Handle:=ExtractIcon(Application.Handle,Pchar(Programm16.Icon),Programm16.IconNr);

und der soll in ne Schleife um die Sache mit möglichst einer zeile zu machen...

D.h. es müsste sich die Zahl am Ende von Programm (die ich so wunderhüpsch markiert hab) von alleine ändern.

Nun sagt nicht gleich, dass ich doff bin und ich mich wegen den 6 Zeilen nicht aufregen soll! Bei dem Code oben handelt es sich nur um ein Auszug aus meinem Programm... (sind insgesammt 30 Zeilen und ich hab das Problem nicht nur an diser Stelle)

Gut, dann bedanke ich mich schon jetzt mal...
Tschau

// Edit: Auf freundlichen Hinweis hin Korrigiert


Zuletzt bearbeitet von Stefan-W am Mo 21.02.05 20:24, insgesamt 2-mal bearbeitet
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 21.02.05 20:19 
1.) Ändere deinen Titel bitte (Sterne raus, das sch weg und lässt vielleicht mit seinem zweiten s ;))

2.) Etwas nmehr Info wäre nett: was ist Programm15 etc. Ich tipp mal spontan auf ein Image... versuchs einfach mal mit Suche in: Delphi-Forum, Delphi-Library FINDCOMPONENT

AXMD
Stefan-W Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 21.02.05 20:23 
Sorry hatte ich vergessen

Programm** ist eine Variable von dem Type
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Type
    TProgramm = Packed Record
        Name: String;
        Programm: String;
        Parameter: String;
        Icon: String;
        IconNr: Integer;
    End;
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Mo 21.02.05 20:25 
Hallo,

da musst du wohl einen Array bzw. eine Liste nehmen, sonst klappt das nicht.

Gruß Hape!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mo 21.02.05 20:28 
warum nimmst kein array ne andere lösung fällt mir gerade net ein oO
Stefan-W Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 21.02.05 20:30 
gut ich hab mal gesucht und diesen Link gefunden :D
Danke AXMD für den Hinweis

cu
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mo 21.02.05 20:41 
das funktioniert aber NICHT mit einem record (oder doch oO)

es gibt eine möglichkeit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
type a = packed record
           a, b: integer;
         end;
     pa = ^a;

var x1, x2, x3: a;

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
  for i := 1 to 3 do
  begin
    pa(pointer(integer(@x1)+(i-1)*sizeof(a)))^.a := 1234;
  end;
end;


die ist aber NICHT zu empfehlen mach lieber

x: array[1..100] of a;

(in meinem fall)
Stefan-W Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 21.02.05 20:42 
gut mar ich mal wieder zu schnell... Das was ich gefunden hab geht mal wieder nur mit was was ich nicht selbst erstellt hab. oder ich mach was falsch...

könnt ihr mir nochmal helfen
Stefan-W Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 21.02.05 20:46 
@uall@ogc: das hatte ich schon mal versucht wollte aber nicht also hab ich 30 Programm**: TProgramm; Variablen erstellt und dachte ich spar mir dann schon die ander 30 Var von jeder sorte

P.S haast du vielleicht ein bsp. vielleicht hatte ich nur was falsch gemacht

(Wenn das gehen würde währe das mir sogar lieber)
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mo 21.02.05 22:25 
nimm bester

ausblenden Delphi-Quelltext
1:
var programarray[1..30of TProgram;					


das andere von mir ist wirklich nicht geeignet, wolte nur zeiges das es theoretisch möglich ist

Moderiert von user profile iconAXMD: Delphi-Tags hinzugefügt.
Stefan-W Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Mo 21.02.05 22:29 
gut ich teste das dann mal... muss aber dazu noch was umschreiben (viel Arbeit) aber danke... :-)
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Di 22.02.05 00:58 
uall@ogc hat folgendes geschrieben:
pa(pointer(integer(@x1)+(i-1)*sizeof(a)))^.a := 1234;

Für solche Fälle gibt es das "absolute":

ausblenden Delphi-Quelltext
1:
2:
3:
var
 x1, x2, x3 : AnyType;
 x : array[1..3of AnyType absolute x1;


dann ist
x[1] identisch mit x1,
x[2] identisch mit x2,
usw.

Mach das aber nur, wenn die x1 usw. global deklariert sind.

Gruss

A propos, wusstest du, dass die Delphi-Suche Regular Expressions unterstützt (Checkbox bei Optionen)?
Der Suchstring "Programm([0-9]+)" matcht all deine ProgrammXX-Variablen...
Stefan-W Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 475

Win 7 SP1
D2005 PE
BeitragVerfasst: Di 22.02.05 11:14 
gut ich habs mit der Array gemacht geht wunderbar... :D
ist ne feine Sache hab dadurch noch an paar anderen Stellen Code gespart

Nochmal vielen Dank an alle

Tschau