Sign in to follow this  
Followers 0
styles3000

StringStripWS Complications

10 posts in this topic

I've been looking within the help files and ran across StringStripWS ( "string", flag )I've tried StringStripWS(aRecords, 8) and StringStripWS(aRecords[$x], 8) but it wasn't takin the space out.

#include <file.au3>
_CreateTaggedKeywords()

Func _CreateTaggedKeywords()
    Dim $aRecords
    $PthFile = 'D:\Rename.txt' ;Full path and filename to read
    $outputFileName = 'D:\New Text Document (2).txt'

    If Not _FileReadToArray($PthFile,$aRecords) Then
       MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
       Exit
    EndIf

    $file = FileOpen($outputFileName, 2)
    For $x = 1 to $aRecords[0]
        FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF)

    Next
    FileClose($file)
EndFunc

Share this post


Link to post
Share on other sites



styles3000,

Works fine for me: :evil:

$sText = 'D:\New Text Document (2).txt'

ConsoleWrite(StringStripWS($stext, 8) & @CRLF)

Did you use the right flags? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I'm going to guess he called the function without subsequently assigning it's output.

Share this post


Link to post
Share on other sites

weaponx,

Having done that myself when I first used that type of String* function, I am quite prepared to believe that could be the solution. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

The output is looking like this...

<a href="banco patagonia .htm">banco patagonia </a><BR>

<a href="aig stock .htm">aig stock </a><BR>

<a href="optionsxpress .htm">optionsxpress </a><BR>

<a href="colonial bank .htm">colonial bank </a><BR>

<a href="banco estado .htm">banco estado </a><BR>

<a href="aig .htm">aig </a><BR>

Do you see the white space before .htm?

I've tried .....

$PthFile = 'D:\New Text Document (2).txt'

ConsoleWrite(StringStripWS($PthFile, 8) & @CRLF)

I've tried....

$outputFileName = 'D:\New Text Document (2).txt'

ConsoleWrite(StringStripWS($outputFileName, 8) & @CRLF)

I've tried....

$file = 'D:\New Text Document (2).txt'

ConsoleWrite(StringStripWS($file, 8) & @CRLF)

Maybe I'm approaching things the wrong way? Or placing the function in the wrong place.

Func _CreateTaggedKeywords()
    Dim $aRecords
    $PthFile = 'D:\Rename.txt' ;Full path and filename to read
    $outputFileName = 'D:\New Text Document (2).txt'

    If Not _FileReadToArray($PthFile,$aRecords) Then
       MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
       Exit
    EndIf

    $file = FileOpen($outputFileName, 2)
    For $x = 1 to $aRecords[0]
        FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF)
    Next
$PthFile = 'D:\New Text Document (2).txt'

ConsoleWrite(StringStripWS($PthFile, 4) & @CRLF)

    FileClose($file)
EndFunc

Share this post


Link to post
Share on other sites

$PthFile = 'D:\New Text Document (2).txt'
ConsoleWrite(StringStripWS($PthFile, 8) & @CRLF)

This work fine for me.... all spaced are gone or are you expecting something else?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

styles3000,

The ConsoleWrite was just to show you that it worked! Not a suggestion for your code!

You need to go to wherever you get your 'D:\New Text Document (2).txt' from and use the StringStripWS before you get to your function:

$outputFileName = 'D:\New Text Document (2).txt'
$outputFileName = StringStripWS(outputFileName , 8)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

$PthFile = 'D:\New Text Document (2).txt'
ConsoleWrite(StringStripWS($PthFile, 8) & @CRLF)

This work fine for me.... all spaced are gone or are you expecting something else?

Yes Jos,

Maybe I am. I'm getting this below......

<a href="banco patagonia .htm">banco patagonia </a><BR>

<a href="aig stock .htm">aig stock </a><BR>

<a href="optionsxpress .htm">optionsxpress </a><BR>

<a href="colonial bank .htm">colonial bank </a><BR>

<a href="banco estado .htm">banco estado </a><BR>

<a href="aig .htm">aig </a><BR>

but I want this......

<a href="banco-patagonia.htm">banco patagonia </a><BR>

<a href="aig-stock.htm">aig stock </a><BR>

<a href="optionsxpress.htm">optionsxpress </a><BR>

<a href="colonial-bank.htm">colonial bank </a><BR>

<a href="banco-estado.htm">banco estado </a><BR>

<a href="aig.htm">aig </a><BR>

I'll review over all that yall have gave me....Thanks for all your help.....

Share this post


Link to post
Share on other sites

Maybe I am. I'm getting this below......

<a href="banco patagonia .htm">banco patagonia </a><BR>

<a href="aig stock .htm">aig stock </a><BR>

<a href="optionsxpress .htm">optionsxpress </a><BR>

<a href="colonial bank .htm">colonial bank </a><BR>

<a href="banco estado .htm">banco estado </a><BR>

<a href="aig .htm">aig </a><BR>

but I want this......

<a href="banco-patagonia.htm">banco patagonia </a><BR>

<a href="aig-stock.htm">aig stock </a><BR>

<a href="optionsxpress.htm">optionsxpress </a><BR>

<a href="colonial-bank.htm">colonial bank </a><BR>

<a href="banco-estado.htm">banco estado </a><BR>

<a href="aig.htm">aig </a><BR>

I'll review over all that yall have gave me....Thanks for all your help.....

Hi,

What others are trying to tell you is that you need to _assign_ the result of StringStripWS($PthFile, 8) to some variable.

But wait a minute: aren't you trying to apply the function to the filename that contains the records you want to process?

StringStripWS($PthFile, 8) will simply return the contents of variable $PthFile with whitespaces removed. It won't open the file and butcherize the strings inside it!

Try this:

Func _CreateTaggedKeywords()
 Dim $aRecords
 $PthFile = 'D:\Rename.txt' ;Full path and filename to read
 $outputFileName = 'D:\New Text Document (2).txt'

 If Not _FileReadToArray($PthFile,$aRecords) Then
 MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
 Exit
 EndIf

 $file = FileOpen($outputFileName, 2)
 For $x = 1 to $aRecords[0]
 FileWriteLine($file,'<a href="'&StringStripWS($aRecords[$x], 4)&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF)
 Next

 FileClose($file)
EndFunc

But even then, notice that 'banco patagonia ' won't change to 'banco-patagonia'. You need to use something like StringReplace in addition to the WS strip to convert middle space to hyphen. That or use one call to StringRegexpReplace to do it all in one shot.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0