Hello, I'm totally new to scripting so I need some help here.
I'm trying to import some recipes to a webapp, however the simple copy and paste method don't work.
Here is the original text:
Carrot
3
Garlic
6 cloves
...etc
I want to turn it into:
3 Carrot
6 cloves Garlic
Basically cut the first line and paste it after the following line.
Is it possible?
Thank you for your help
Edit text lines
-
- Posts: 4
- Joined: 10 Aug 2018, 08:59
Re: Edit text lines
Code: Select all
sample =
(
Carrot
3
Garlic
6 cloves
)
Lines := StrSplit(sample, "`n", "`r")
while(Lines.Count())
{
food := Lines.RemoveAt(1)
amount := Lines.RemoveAt(1)
result .= Format("{} {}`n", amount, food)
}
MsgBox % result
-
- Posts: 4
- Joined: 10 Aug 2018, 08:59
Re: Edit text lines
I ran the script with the text file opened and nothing happened.
Re: Edit text lines
you need :
fileread,sample,myfile.txt
fileread,sample,myfile.txt
Code: Select all
sampl1 =
(
Carrot
3
Garlic
6 cloves
)
f1=%a_scriptdir%\test55.txt
ifnotexist,%f1%
fileappend,%sampl1%,%f1%
;--------- end test -----------------
fileread,sample,%f1% ;- <<< read your file
Lines := StrSplit(sample, "`n", "`r")
while(Lines.Count())
{
food := Lines.RemoveAt(1)
amount := Lines.RemoveAt(1)
result .= Format("{} {}`n", amount, food)
}
MsgBox % result
return
-
- Posts: 4
- Joined: 10 Aug 2018, 08:59
Re: Edit text lines
Thank you that worked perfectly!
Who is online
Users browsing this forum: Google [Bot] and 333 guests