Autor Beitrag
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 29.11.08 19:44 
Hi!

Aaalso. Ich schreibe eine Batch - bzw. CMD-Datei.
Man kann bei set den Namen der Variablen aus einer anderen zusammenbasteln. Beispiel:
ausblenden Quelltext
1:
set "line%y%=abc"					

Wenn man jetzt y aus einer Schleife holt, krieg ich line1,line2,line3 usw.

Die Frage ist: wie greift man darauf zu?
ausblenden Quelltext
1:
echo %line%y%%					

Sieht nicht nur komisch aus, sondern es funktioniert auch nicht.

Gleiches Problem stellt sich bei %a:~4,5%-Syntax. Wers nicht kennt: das ist im Grunde Copy. Aber wenn die Position nicht konstant ist, dann muss ich die irgendwie aus der Variable rauskriegen. Auch hier geht einfach %index% natürlich nicht.

EDIT: eine Idee hatte ich grade, aber die geht auch nicht:
ausblenden Quelltext
1:
  for /F "tokens=" %%i in ("echo %%line%y%%%") do %%i					

Keine Ausgabe...


Kreative Ideen?
Immer her damit :P

Danke schonmal,
Martok

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19276
Erhaltene Danke: 1741

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 29.11.08 20:13 
Viel einfacher, habs grad so nochmal ausprobiert, geht ;-):
ausblenden Quelltext
1:
2:
3:
4:
5:
setlocal EnableDelayedExpansion
set line1=abc
set y=1
echo !line%y%!
pause
Martok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 29.11.08 20:19 
Cool. !!-Syntax ist mir neu. Wieder was gelernt ;)

Credits.Add(user profile iconjaenicke)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."