String Things - Stand-alone string manipulation functions

Post your working scripts, libraries and tools
Verdlin
Posts: 61
Joined: 04 Oct 2013, 08:55
GitHub: Aatoz

Re: String Things - Stand-alone string manipulation function

29 May 2014, 04:35

Thanks, Tidbit!

@guest3456: Yes, those first braces are unnecessary. It's there because I paste all of my examples from a scratchpad function. It's doesn't hurt to include them in posts, and it is less work for me to remove braces and indentation.

@AfterLemon: I considered that at first, too. The particular case where I find this function beneficial is outlined below. It saves a little bit of coding headache and also reduces potential for small errors.

Shown below, I use this type of on-the-fly debugging on a daily basis, and the concat function makes my life a little easier...

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus

User avatar
tidbit
Posts: 982
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

30 May 2014, 14:59

2.6 is out.
I've been slacking and not paying attention to what I've changed/added/removed.
All I can remember is I just added st_concat() and have an alternative (better, but harder to read) version of st_printArr().
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
sv270190
Posts: 43
Joined: 06 Feb 2014, 11:48
Facebook: svsammaponnu@gmail.com

Re: String Things - Stand-alone string manipulation function

15 Aug 2014, 08:56

dear sir

what are the functions in which i can use the entire file and how could i get the output file

for eg st_insertline st_deleteline how can i use the entire file

i.e i want the 3rd of input.txt to be inserted with "new 3rd line" so that the original 3rd line is now the fourth line.

kindly guide me what are all the other functions in which the operation is conducted in the entire file
S.V. SRINIVASAN
SRIVILLIPUTTUR
TAMIL NADU
User avatar
tidbit
Posts: 982
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

15 Aug 2014, 11:09

kindly guide me

you will need these commands and steps:

1. Read the file into a variable: http://ahkscript.org/docs/commands/FileRead.htm

2. Use this function from String Things to insert stuff where you want: giraffe:=st_insertLine("Pandas cannot fly", Variable, 3). %giraffe% will contain the new text.

3. Delete the original file from step [1] using: http://ahkscript.org/docs/commands/FileDelete.htm

4. Re-create the original file with the new text stored in %giraffe% using: http://ahkscript.org/docs/commands/FileAppend.htm

Note: I color-coordinated important stuff for you to easily study/learn.
I would suggest testing on a backup version of your file(s).
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
sv270190
Posts: 43
Joined: 06 Feb 2014, 11:48
Facebook: svsammaponnu@gmail.com

Re: String Things - Stand-alone string manipulation function

17 Aug 2014, 00:08

thank you for your immediate response/guidance
may i conclude that the subject file be read to a variable and that we can use string function / operation to the entire file

i will test and revert to you.
S.V. SRINIVASAN
SRIVILLIPUTTUR
TAMIL NADU
User avatar
tidbit
Posts: 982
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation function

17 Aug 2014, 10:14

Working directly with files is not easy in AHK. There is already a library for that, TF.ahk. But iirc, it needs to do the same steps as I mentioned above (read, delete, build, rewrite). And it's massive. And with TF() you can't simply copy/paste the functions you need into your code and ignore everything else. You'll need all 1300+ lines.

so with ST(), you can remove the 1300 lines and just add 4 lines to read, delete, build then rewrite. Only if you need them.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
Stevoisiak
Posts: 11
Joined: 24 Aug 2017, 14:19
GitHub: Stevoisiak
Contact:

Re: String Things - Stand-alone string manipulation functions

01 Sep 2017, 12:44

Any particular reason to host this on DropBox and not GitHub? (My workplace blocks access to DropBox due to security concerns)
User avatar
RUNIE
Posts: 246
Joined: 03 May 2014, 14:50
GitHub: Run1e

Re: String Things - Stand-alone string manipulation functions

01 Sep 2017, 17:38

Stevoisiak wrote:Any particular reason to host this on DropBox and not GitHub? (My workplace blocks access to DropBox due to security concerns)

tidbit really likes dropbox.
User avatar
tidbit
Posts: 982
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation functions

01 Sep 2017, 20:26

dropbox is nice and easy. git is annoying. I'll put it on pastebin instead.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
Stevoisiak
Posts: 11
Joined: 24 Aug 2017, 14:19
GitHub: Stevoisiak
Contact:

Re: String Things - Stand-alone string manipulation functions

06 Sep 2017, 10:14

I may be mistaken, but I didn't see any way of handling 2D arrays with st_split, such as ones found in CSV files.

Based on code by Oleg, here's a function for splitting a delimited string to a 2D array.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Example usage

Code: [Select all] [Download] GeSHi © Codebox Plus

jobString = 
(
Unit,Dept_ID,Name
CORP,0368,Admin
CORP,3945,Programmer
SESHAN,4596,Software Engineer
)

jobArray2D = ad_split2D(jobString, ",")
User avatar
tidbit
Posts: 982
Joined: 29 Sep 2013, 17:15
Location: USA

Re: String Things - Stand-alone string manipulation functions

06 Sep 2017, 10:42

st_split is useless now. ahk finally has it built-in, strsplit()
then you work on it (either my function or the returned var of strsplit()) the same way you use arrays. arr[blah] arr[1] arr[5] etc

But I guess you knew that since you used it :P
yours does save a step for multi-lined inputs, though. neat.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: gnt101 and 29 guests