Saved Bookmarks
| 1. |
Solve : New Line In File? |
|
Answer» Quote from: Sidewinder on January 18, 2009, 06:57:14 PM Did you set FNAME variable to the label of a file on your system? I'll try the code again...But no, it is not compressing then decompressing files. But, like I said, the complete reason why I need this must remain between my friend and I, although to help you I will say this: I need to be able to remove a certain line at will (or automatically if its the first line and there are 31 lines) without directly modifying the text file. Dias, I was asking for help, not for wasting comments. EDIT: Code works...almost. It will echo each and every line, and if there is more than 30, doesn't show the first lines...but how can I GET each visible line as a variable???Quote EDIT: Code works...almost. It will echo each and every line, and if there is more than 30, doesn't show the first lines...but how can I get each visible line as a variable??? It could be me, but isn't this what you asked for? Quote 1. I'm trying to get the contents, and set each line as a variable. If you want all the lines in variables remove some of the logic from the posted code: Code: [Select]@echo off setlocal set fname=drive:\path\file.ext for /f "tokens=* delims=" %%x in (%fname%) do ( call set /a idx=%%idx%%+1 call set array.%%idx%%=%%x ) for /L %%x in (1,1,%idx%) do call echo %%array.%%x%% Be aware the environment space (where your variables are stored) is limited to 8K bytes on a XP machine. Quote I need to be able to remove a certain line at will (or automatically if its the first line and there are 31 lines) without directly modifying the text file. Determine which line to delete and write out a new file. You don't need a variable for each line, you need a counter. By the way who is Will? Perhaps you should get together with the other guy on this board with the 142 labels. You could share the cost of a KISS 101 course Quote Hamlet? 0x2B | ~ 0x2BYes. Hamlet was not a programmer. In the original context it was an XOR that had to have a YES or NO. But the C construct would become -1 if converted directly to a number. What would Hamlet think if we told him the answer is always minus one?Quote You don't need a variable for each line, you need a counter. I told him this days ago.Quote from: Dias de verano on January 20, 2009, 12:46:54 AM QuoteAnd I said that I DO need a variable for each line. (But atleast my problem is partially done)You don't need a variable for each line, you need a counter. |
|