Computer Hope
Software => Computer programming => Topic started by: scomp on June 17, 2008, 11:51:06 AM
-
hi everyone,
I want to know how to save content of a file into an array.
I want to save a full line into a particular position or address in an array.
e.g.
if a is an array
a(0) = save first line
a(1) = save second line
......
and it should be continue until all lines are saved.
Can anyone help me?
thank in advance
-
@echo off
set idx=0
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%x in (test.txt) do (
call set /a idx=%%idx%%+1
call set array.%%idx%%=%%x
)
for /l %%x in (1, 1, %idx%) do (
echo !array.%%x!
)
Batch code does not support true arrays although you can mimic one. The first for shows how to load the array from a file. The second for shows the notation needed to access the array elements.
Happy Coding 8)
-
thanks sidewinder
-
Yeah, what language are you programming in?