Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove extra spaces, tab in a text file?
#1
Solved: 11 Years, 4 Months ago
Hi there,
Can one answer my below question please?

I wrote one action and one function as follows. I have clicked associate this function to Action under File Menu
Action:
-----------
Code:
If browser("SPLAT! A Terrestrial RF").Page("SPLAT! A Terrestrial RF").Link("NASA").Exist then
    browser("SPLAT! A Terrestrial RF").Page("SPLAT! A Terrestrial RF").Link("GNU General Public License").Click
    else
    reporter.ReportEvent micDone,"Gne public license", "License page"
end if
Set oFSO=CreateObject("scripting.FileSystemObject")
Set oFile=oFSO.CreateTextFile("C:\temp\another.txt", 2, True)
sCont=browser("SPLAT! A Terrestrial RF").Page("The GNU General Public").Object.documentElement.innertext
ParseSpaces "sCont"
oFile.write sCont
oFile.close
Set oFile=nothing
Set oFSO=Nothing

--------------------

Code:
Function ParseSpaces(TextIn)
   ParseSpaces=Replace(TextIn, " ", "")
   While (Instr(ParseSpaces, " ")>0)
         ParseSpaces=Replace(ParseSpaces, " ","")
   Wend
   While (Instr(ParseSpaces,vbNewLine)>0)
       ParseSpaces=Replace(ParseSpaces, " ", "")
   Wend
   While (Instr(ParseSpaces, vbTab)>0)
       ParseSpaces=Replace(ParseSpaces, " ", "")
   Wend
   While (Instr(ParseSpaces, vbCr)>0)
       ParseSpaces=Replace(ParseSpaces, " ", "")
   Wend
End Function

I am getting invalid parameters and sometime different error. What should I do apart from calling this function? Do I need to make any changes in the setting?

I tried with ParseSpaces(sCont) also, no use.

Please help, its very urgent.
Thanks,
kishore
Reply
#2
Solved: 11 Years, 4 Months ago
Code:
ParseSpaces=Replace(ParseSpaces, chr(10),"")
ParseSpaces=Replace(ParseSpaces, chr(14),"")
ParseSpaces=Replace(ParseSpaces, chr(32),"")
Reply
#3
Solved: 11 Years, 4 Months ago
surya_7mar Wrote:ParseSpaces=Replace(ParseSpaces, chr(10),"")
ParseSpaces=Replace(ParseSpaces, chr(14),"")
ParseSpaces=Replace(ParseSpaces, chr(32),"")

Thanks for your reply Surya, I am able to remove couple of spaces, tabs. How can I remove any number of empty spaces in a line?
say for example, I have the following string.
Example:"Testing should be done everywhere.
In the above line, after everywhere, rest of the line is blank. How can I remove these kinds of spaces?

Thanks,
kishore
Reply
#4
Solved: 11 Years, 4 Months ago
HI Kishore ,

For returning a string without Trailing & Leading Blank spaces can be done by using "Trim" built in function.
( i.e Rtrim,Ltrim,Trim)

Code:
str= "     hai"   ; ltrim(str) --> "hai"

str= "hai    "    ; rtrim(str) --> "hai"

str= "   hai     " ; trim(str) ---> "hai"
If your question is regarding the eliminating leading & trailing blank spaces then , the above solution might be useful to u.
Reply
#5
Solved: 11 Years, 4 Months ago
You can Use Trim () which will trim all the spaces
Reply
#6
Solved: 11 Years, 4 Months ago
I used your answers and got the result. Thanks for the support!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to remove the spaces from a string Anand 7 29,450 08-12-2019, 04:47 PM
Last Post: sreekanthP
  How to remove text in the webedit silpavinod 3 13,791 07-12-2018, 11:08 AM
Last Post: vijaychourasiya0109@gmail.com
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 4,905 09-13-2015, 12:06 AM
Last Post: ADITI1992
  How to retrieve specied string from text file nsuresh316 1 2,474 06-09-2015, 12:24 AM
Last Post: nsuresh316
  Reading and writing is the same text file poulomi21b 2 6,096 07-08-2014, 12:39 PM
Last Post: poulomi21b

Forum Jump:


Users browsing this thread: 2 Guest(s)