Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
I am working on a validation routine for some GIS data tables that I have. The table that I am interested in appending text to is Table.tab (which can be edited in Notepad).
The format of the Table is:-!table
!version 650
!charset WindowsLatin1Definition Table
Type NATIVE Charset "WindowsLatin1"
Fields 5
a char (10);
b char (10);
c char (10);
d char (10);
e char (10);I would like to append the text Readonly
against d char (10); so that after running the line will readd char (10) readonly;
The position of the line is always line 11 of Table.tab. Can anyone help?
Thanks

@echo off > newfile
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in (table.tab) do (
echo %%a |find "d char" > nul
if not errorlevel 1 ( echo %%a readonly >> newfile
) else (
echo %%a >> newfile
)
)
=====================================
If at first you don't succeed, you're about average.M2

Thanks for this
I must be doing something wrong though as i keep getting %%a not expected at this time

Did you paste it in?
=====================================
If at first you don't succeed, you're about average.M2

Thanks for your help, I have got that bit working - just a couple of questions, I'm afraid. My file format has changed and the line I want to change has subsequently changed to -
Request5 Char (10) ;
when I change the code above to find "Request5 Char" the newfile that the code produces changes the line to:-
Request5 Char (10) ; Readonly
I need the readonly to appear between "(10)" and ";" i.e.:-
Request5 Char (10) Readonly ;
Another problem encountered is that I lose the exclamation marks at the top of the file - new file removes them so the top 3 lines in newfile are
table
version 650
charset WindowsLatin1my data needs them to be
!table
!version 650
!charset WindowsLatin1Any ideas on how I can achieve this?
Thanks Mark

We may be getting close. Post a copy of the current table.tab file.
::== T7.bat
@echo off > newfile
setLocalfor /f "tokens=* delims= " %%a in (table.tab) do (
echo %%a |find "d char" > nul
if not errorlevel 1 (
echo Request5 Char ^(10^) readonly; >> newfile
) else (
echo %%a >> newfile
)
)::
::== end T7.bat
=====================================
If at first you don't succeed, you're about average.M2

Sorry for the delay in getting back to you, I've been on bereavement leave.
The new code doesn't appear to do anything (What is Find "d char" looking for?)
As requested new table.tab format below-
!table
!version 650
!charset WindowsLatin1Definition Table
Type NATIVE Charset "WindowsLatin1"
Fields 56
District_Search_Ref Char (20) ;
District_Council_ID Char (8) ;
UPRN Char (20) ;
DCC_Search_No Char (6) ;
Year Char (4) ;
Date_of_Receipt Char (10) ;
Date_of_Return Char (10) ;
FTP_to_DCC Char (30) ;
FTP_from_DCC Char (30) ;
Status Char (3) ;
Version Char (2) ;
User_ID Char (6) ;
Property_No Char (25) ;
Street Char (50) ;
Location Char (50) ;
Town Char (25) ;
Postcode Char (8) ;
RASE Char (50) ;
Q2a Char (200) ;
Q2b Char (175) ;
Q2c Char (25) ;
Q2d Char (25) ;
Q2_Clarification Char (150) ;
Q3_2 Char (80) ;
Q3_4a Char (80) ;
Q3_4b Char (80) ;
Q3_4c Char (80) ;
Q3_4d Char (80) ;
Q3_4e Char (80) ;
Q3_4f Char (80) ;
Q3_5 Char (80) ;
Q3_6a Char (125) ;
Q3_6b Char (80) ;
Q3_6c Char (80) ;
Q3_6d Char (80) ;
Q3_6e Char (80) ;
Q3_6f Char (80) ;
Q3_6g Char (125) ;
Q3_6h Char (80) ;
Q3_6i Char (125) ;
Q3_6j Char (80) ;
Q3_6k Char (80) ;
Q3_6l Char (80) ;
Q3_7 Char (100) ;
Q3_11 Char (150) ;
Request5 Char (10) ;
Q5_1 Char (10) ;
Q5_2 Char (30) ;
Request18 Char (10) ;
Q18_1 Char (30) ;
Q18_2a Char (30) ;
Q18_2b Char (50) ;
Request22 Char (10) ;
Q22_1 Char (30) ;
Q22_2 Char (50) ;
Comments Char (254) ;

The reason it doesn't do anything is because it's looking for "d char", which is not in the new table.
There are, however, three lines contaiining "d Char". So it alters all 3.
Question is: which of these 3 lines should be changed? And to what?:
::====================
Q2d Char (25) ;
Q3_4d Char (80) ;
Q3_6d Char (80) ;
::====================
::======================
::==t8.batEnableDelayedExpansion
::== t8.bat
@echo off > newfile
setLocalfor /f "tokens=* delims= " %%a in (table.tab) do (
echo %%a |find "d Char" > nul
if not errorlevel 1 (
echo Request5 Char ^(10^) readonly; >> newfile
) else (
echo %%a >> newfile
)
)::== done
=====================================
If at first you don't succeed, you're about average.M2

None should be changed, we want to change
Request5 Char (10) ;
to
Request5 Char (10) readonly;Thanks again for your help

::== t9.bat
@echo off > newfile
setLocalfor /f "tokens=* delims= " %%a in (table.tab) do (
echo %%a |find "Request5 Char" > nul
if not errorlevel 1 (
echo Request5 Char ^(10^) readonly; >> newfile
) else (
echo %%a >> newfile
)
)::== done
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |