Autor Beitrag
ebber
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: So 05.10.08 00:57 
Hallo,

ich stehe gerade irgendwie ein bisschen auf dem Schlauch. Ich komm einfach nicht mehr dahinter was es damit auf sich hatte.

Ich habe eine Variable z.B. Port1 ein Boolean. Kann ich auf true... setzten. Ich möchte jetzt aber sowas eingeben wie LED1 := true, aber dass dann eben Port1 auf true gesetzt wird. LED1 soll nur so ein Platzhalter sein so irgendwie. Ich bin irgendwie gerade verwirrt. Kann mir jemand helfen?

MfG
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 05.10.08 01:58 
Gleicher Speicher:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
    Port: Boolean;
    LED1: Boolean absolute Port;
    LED2: Boolean absolute Port;


Ansonsten als Bitset:

ausblenden Delphi-Quelltext
1:
2:
type TLED = (led0, led1, led2, led3, led4, led5, led6, led7);
var Port: set of TLED;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: So 05.10.08 11:25 
Danke erstmal. Also im normalen Delphi funktionierts. Für dieses Projekt muss ich aber einen anderen Compiler benutzen. Der nimmt beides nicht. Ich würde jetzt ja noch nach einer anderen Möglichkeit fragen, aber ich glaube kaum, dass er das dann nimmt. Muss ich eben einen umständlicheren Weg gehen.

MfG
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19321
Erhaltene Danke: 1748

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 05.10.08 11:29 
Dann sag doch mal welchen Compiler du benutzt :roll: .
Grundsätzlich hört sich das für mich so an als könntest du auch einen Pointer auf deine erste Variable benutzen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  Port: Boolean;
  PointerToPort: ^Boolean;
begin
  PointerToPort := @Port; // auf die Adresse von Port setzen
  PointerToPort^ := True; // den Booleanwert an der Adresse auf True setzen
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: So 05.10.08 18:26 
Das funktioniert auch nicht.
Der Compiler ist vom Programm mikroPascal. Damit kann man Mikrocontroller programmieren. Deshalb ist das auch eine stark vereinfachte Sache das ganze. Ich schätze mal so Spielereien funktionieren damit einfach nicht. Trotzdem Danke.

MfG
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 05.10.08 18:38 
Hi,

Eventuell so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
private
  FPort: Boolean;
public
  property LED1: Boolean read FPort write Port;
  property Port1: Boolean read FPort write FPort;


mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 05.10.08 18:42 
Wozu soll denn das gut sein? Warum kannst du nicht einfach Port1 schreiben? Wozu braucht man so etwas? :gruebel:
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: So 05.10.08 20:05 
Hallo,


@Hidden Danke, hat aber überhaupt nicht funktioniert. Er kennt kein private, public, property, read, write. :( Ich habe so das Gefühl das einzige was das überhaupt mit Delphi zu tun hat ist begin und end;

@Yogu Ja theoretisch kann ich das, ist aber ein bisschen umständlich weil sich nicht so direkt Led1 hinter Port1 befindet sondern mehr so Port1 Led8, Port2 Led4.... Das verwirrt dann ein wenig und vorallem kann sich das mal ändern und dann muss ich im ganzen Code alle nochmal ändern.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 05.10.08 20:14 
user profile iconebber hat folgendes geschrieben Zum zitierten Posting springen:
@Yogu Ja theoretisch kann ich das, ist aber ein bisschen umständlich weil sich nicht so direkt Led1 hinter Port1 befindet sondern mehr so Port1 Led8, Port2 Led4.... Das verwirrt dann ein wenig und vorallem kann sich das mal ändern und dann muss ich im ganzen Code alle nochmal ändern.

Und warum verwendest du dann nicht nur LEDx, und änderst eben beim Einlesen in die Variable entsprechend den Port?
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: So 05.10.08 20:18 
Okay, dann ein letzter, verzweifelter Versuch :)

probier' mal, ob er #define kennt. dürfte er zwar nicht, aber..

Kenne leider das Pascal-Äquivalent nicht(das es, fällt mir gerade ein, imho nicht geben dürfte, da so etwas aus Pascal-Sicht grob unsauber wäre: Pascal will klar definierte Typen und keine Präprozessor-Code-Schnipsel).

Ansonsten: Schreib' dir ein Programm, das du vor dem letztendlcihen compillieren einmal drüberlaufen lässt - kleine Tabelle mit Begriffen und dann einfach StringReplace :(

E: Mist, zu spät :) Yogu's Vorschlag hat 'was^^

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: Mo 06.10.08 10:25 
Wenn der Vorschlag was hat finde ich es toll. Ich verstehe ihn bloß leider nicht. Könntest du ihn vielleicht bitte nochmal in 2 Sätzen schreiben statt in einem :)
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 06.10.08 10:27 
Ich hab' ihn auch drei Mal lesen müssen^^

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 06.10.08 18:58 
user profile iconYogu hat folgendes geschrieben Zum zitierten Posting springen:
Und warum verwendest du dann nicht nur LEDx, und änderst eben beim Einlesen in die Variable entsprechend den Port?

  • Definiere eine Variable LED1.
  • Definiere eine Variable LED2.
  • Definiere weitere, falls du weitere brauchst.
  • Anstatt in deine ursprüngliche Variable Port1 zu schreiben, machst du folgendes:
    • Schreibe in Variable LED1.
    • Schreibe in Variable LED2 das, was du vorher in Port2 geschrieben hast..
    • Schreibe in weitere Variablen, falls du weitere brauchst.
    • Falls sich die Verknüpfung (Port1 - LED1) ändert, machst du folgendes:
      • Du schreibst statt in LED1 (noch früher hieß es Port1) in LED2
      • Du kannst auch in LED3 schreiben, falls sich die Verknüpfung so ändert.


Read - Compile - Execute :mrgreen:
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: Mo 06.10.08 19:05 
Also entweder ich bin heute schwer von Begriff und versteh dich immer noch nicht oder ich habe dir eine wichtige Information vorenthalten. Port1... ist vordefiniert, daran kann ich nichts ändern, das muss so heißen.

MfG
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 06.10.08 19:09 
user profile iconebber hat folgendes geschrieben Zum zitierten Posting springen:
Also entweder ich bin heute schwer von Begriff und versteh dich immer noch nicht oder ich habe dir eine wichtige Information vorenthalten. Port1... ist vordefiniert, daran kann ich nichts ändern, das muss so heißen.

Da hast du mir tatsächlich eine wichtige Information vorenthalten. Dass Port1 konstant ist, wusste ich nicht. :)

Tut mir leid - wenn dein Compiler keine Pointer kennt, kann ich dir auch nicht weiterhelfen. :nixweiss:
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 06.10.08 19:13 
bleibt nur: Quelltext kopieren, Schlüsselwörter ersetzen, compillieren, kopierte Version wegschmeißen :(

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
ebber Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 239
Erhaltene Danke: 1

Win XP, Win 7
C# (VS 2010), Delphi (2007), Expression 4
BeitragVerfasst: Mo 06.10.08 20:18 
Ja das scheint mir auch so.
Trotzdem Danke.

MfG