I am currently working on a script that requires me to take tons of raw text and paste it into my script in an array/arrays.
The issue would be that the text contains escape characters and I really don't want to have to go over even one line of the text to correct for it. ie. ' " ' becomes ' "" ' etc.
I know that I can first put the text in a var like this:
var = my_function(a,&b,c:="")
and then add var to my array
array[index]:=var
But... I think I would go crazy long before I got a fraction through it.
So what I need is a way to just copy and paste any raw text and know that there is not going to be any issues with any possible
escape characters.
Thanks in advance for any assistance.
Hellbent.
pasting raw text into an array without fixing escape characters Topic is solved
Re: pasting raw text into an array without fixing escape characters
It occurs to me that this is a much more complicated problem then I first assessed.
I suspect that even if most escape sequences could be dealt with, comments ";" "~;" "/* */" would still be a hold up.
I really didn't want to have to do this as a script and a text doc but it seems that it is going to be the case.
For the moment i'll leave this thread as a active one, but it seems to me to likely something undoable without doing something like having the script read and parse itself with the text being in a comment at the bottom or something like that.
I suspect that even if most escape sequences could be dealt with, comments ";" "~;" "/* */" would still be a hold up.
I really didn't want to have to do this as a script and a text doc but it seems that it is going to be the case.
For the moment i'll leave this thread as a active one, but it seems to me to likely something undoable without doing something like having the script read and parse itself with the text being in a comment at the bottom or something like that.
Re: pasting raw text into an array without fixing escape characters
- If you want to put verbatim text into a script, and assign that text to a variable, you could use a continuation section, or use FileRead to read text from a file.
- For a continuation section example see: ANSI (CP-1252) CHARACTERS (VERBATIM), here:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
- For a continuation section example see: ANSI (CP-1252) CHARACTERS (VERBATIM), here:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: pasting raw text into an array without fixing escape characters Topic is solved
Solution achieved.
Code: Select all
#SingleInstance,Force
Fileread,temp,some script name.ahk
My_Array:=StrSplit(temp,"•")
Loop 2
My_Array.Remove(1)
msgbox,% My_Array[1] ; output = function_1(` , `n , &, ", `t, ; , /* , */ , ;~ )
ExitApp
/*
•
function_1(` , `n , &, ", `t, ; , /* , */ , ;~ )
•
function_2(a,b,c:="")
•
etc.
*/
Re: pasting raw text into an array without fixing escape characters
jeeswg wrote:- ANSI (CP-1252) CHARACTERS (VERBATIM), here:
jeeswg's characters tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=26486
Dealing with text is something that I find very dry and have tried to stay away from anything to do with boring text as much as I can. I guess it's largely because I hate (HATE) typing or reading off a computer screen.
Would you mind showing me how I would put this as it is exactly into the - ANSI (CP-1252) CHARACTERS (VERBATIM)
Code: Select all
/*
; notes
; more notes
function_1(` , `n , &, ", `t, ; , /* , */ , ;~ )
*/
Re: pasting raw text into an array without fixing escape characters
NVM worked it out.
Cool trick, it looks like I would still have to add it to my array in another step on top of having to type out
(%` Join`r`n
)
for every index.
I think i'll go with the solution I came up with for this project, but I'm sure the continuation section will come in handy down the road.
Cool trick, it looks like I would still have to add it to my array in another step on top of having to type out
(%` Join`r`n
)
for every index.
I think i'll go with the solution I came up with for this project, but I'm sure the continuation section will come in handy down the road.
Re: pasting raw text into an array without fixing escape characters
- Well, I had in mind perhaps putting text in front of each line, to indicate the key names. Then using a parsing loop on each line. E.g. 'abc' -> 'key1:abc', then use the first colon as an indicator to where the key name ends and the value text begins while parsing.
- You could also use StrSplit and refer to each line by its number.
- Another possibility is to copy the text, replace special characters, and paste the text, and then work on that text manually for use with your script.
- Lots of possibilities.
- You could also use StrSplit and refer to each line by its number.
- Another possibility is to copy the text, replace special characters, and paste the text, and then work on that text manually for use with your script.
- Lots of possibilities.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: pasting raw text into an array without fixing escape characters
Thanks for the ideas,
Currently working on setting it up with a mix of the continuation section and the special characters.
If that fails I'll take a look at one of the methods you mentioned.
Currently working on setting it up with a mix of the continuation section and the special characters.
If that fails I'll take a look at one of the methods you mentioned.
Who is online
Users browsing this forum: Leli196 and 303 guests