You are here: PSPad forum > English discussion forum > [feat req] Block align by delimiter
Posted by: Stefan | Date: 08/29/2004 20:17 | IP: IP Logged
Hi Jan,
i search for a feature and didn´t found the right one.
I have often CSV files or wordlists.
e.g. in such case:
berücksichtigen :: to bear in mind
durchführen :: to enforce
prozessieren :: to go to law
Haftung übernehmen :: to assume del credere liability
haltmachen [alt] :: to stop
handeln :: to trade
No i want the block vertikal align for nice print out (or do smtg with one column)
I tryed a RegEx s&r
search for ::
replace by \t\t\t\t::
but the effect is not so good.
Is it possible to implement a feature like
search for a delimiter and move it to pos xy at the same line
Dialog box example:
-----------------------------
Block Align
-------------
delimiters [ ]
move to pos. [ ]
[ ] Select. [ ] Entry scope
-----------------------------
silly code example:
(
- goto first line of selection/TOF
- store curent pos. of delimiter e.g. 12
- read wanted new pos. e.g. 30
- 30-12 =18
- (if result negative send error MsgBox)
- insert 18 blanks bevor delimiter
- If not end of selection /EOF GOTO next line
)
Works only for one block/delimiters after another.
The delimiters are : , ; :: blank space | or what else (good is if user can define herself).
--
greets, Stefan
(pleased user since 1722)
inofficial FAQs + Infos + Special Settings
Posted by: Stefan | Date: 08/29/2004 20:34 | IP: IP Logged
Extra fine would be a table generation:
-----------------------------------------
CSV table generator
[x] Ad delimiters line[-] every [2] Line
[x] Ad | at front of each line
[x] Ad | at end of each line
[x] Ad | instead [::] delimiter
[ ] Ad [ ] extra blanks on longest line
[ ] Horizontal Align for each cell
-----------------------------------------
to get
+----------------------------------------+
| test entry one | some another text |
| | in this cell |
+----------------+----------------------+
| First Line |
| Second Line |
+-----------------+------
| durchführen | to enforce
| prozessieren | to go to law
+-----------------+----------------
--
greets, Stefan
(pleased user since 1722)
inofficial FAQs + Infos + Special Settings
Posted by: gogogadgetscott | Date: 07/27/2005 21:14 | IP: IP Logged
Let me know how this works for you.
Const module_name = "Align"
Const module_ver = "1.00"
Sub AlignCol
text = handleSelText("")
Set regEx = New RegExp
delimiter = InputBox("Enter delimiter.", module_name, ",")
regEx.Pattern = "(.+)\s*" & delimiter & "\s*(.*)"
regEx.Global = TRUE
regEx.IgnoreCase = TRUE
Set Matches = regEx.Execute(text)
MaxLength = 0
For Each Match in Matches
length = len(Match.SubMatches(0))
If length > MaxLength Then
MaxLength = length
End If
Next
newtext = ""
For Each Match in Matches
Spaces = MaxLength - Len(Match.SubMatches(0)) + 1
newtext = newtext & Match.SubMatches(0) & delimiter & String(Spaces, " ") & Match.SubMatches(1)
Next
handleSelText newtext
End Sub
'// @param string Text to replace selected text
Private Function handleSelText(text)
On Error Resume Next
Set editor = newEditor()
editor.assignActiveEditor
If text = "" Then
'// Get selected text
handleSelText = editor.selText
If handleSelText = "" Then
'// No text was select. Get all text and select it.
handleSelText = editor.Text
editor.command "ecSelectAll"
End If
Else
'// Set selected text
editor.selText text
End If
End Function
Sub Init
menuName = "&" & module_name
addMenuItem "Align columns" , menuName, "AlignCol"
End Sub
Posted by: Stefan | Date: 07/28/2005 13:23 | IP: IP Logged
Woow thanks.
Here my tests.
First trim trailing spaces
--------------------------------------------------------------------
I have
berücksichtigen :: to bear in mind
durchführen :: to enforce
delimiter ::
i get
berücksichtigen :: to bear in mind
durchführen :: to enforce
--------------------------------------------------------------------
i have
Name, Tel/Fax extension, Bxl Building ,Bxl Office, Stb Building, Stb Office, Group
De Heer Ivo BELET, 623, Altiero Spinelli, 08F259, Louise Weiss, T09057, PPE-DE
Mevr. Frederika BREPOELS, 862, Altiero Spinelli, 08F266, Louise Weiss, T09055, PPE-DE
M. Antoine DUQUESNE 216 Altiero Spinelli 09G157 Winston Churchill M02080 ALDE
De Heer Saïd EL KHADRAOUI 564 Altiero Spinelli 12G103 Louise Weiss T07045 PSE
delimiter ,
i get
Name, Tel/Fax extension, Bxl Building ,Bxl Office, Stb Building, Stb Office, Group
De Heer Ivo BELET, 623, Altiero Spinelli, 08F259, Louise Weiss, T09057, PPE-DE
Mevr. Frederika BREPOELS, 862, Altiero Spinelli, 08F266, Louise Weiss, T09055, PPE-DE
the lines without delimiter , are deletet from the script.
And the last column is separated only.
-----------------------------------------------------------------------
Anyway thanks.
This script could be handy some times 
Maybe, if you want and have time,
you wanna improve your script to seperate multi columns as in a address list ?
-----------------------------------
I found some csv for testing:
www.mobiledb.com
Editor PSPad - freeware editor, © 2001 - 2013 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák