Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
inserting and replacing lines of text from functions
#1
how do I insert a line of text from one function to another, then later in the new function replace that line of text with another from the first function?

example:

function 1 needs to pull line 1 from function 0
then it runs a series of commands and loops

in the next loop line 1 from function 0 needs to be replaced with line 2 from function 0

it will repeat this several times till it ends up with line 120 from function 0

it is possible to set this up or will I have to copy the repeat series and just type in the text on each series?
#2
Lines cannot be replaced in this way, but maybe here can be used variables or sel. How different are lines in function 0? Please give several examples.
#3
The lines in function 0 are just simple one word lines of text that I need input, I stored them in the function thinking that maybe it would be easier to acces them.

Line 1
textforme

line2
textforyou

line3
textforthem

line4
textforboss

line5
textforwhoever

and so on, these are just some generic examples. But I think you get the idea, there are no integers involved so I didn't have any idea how to replace them. The begining of each line of text starts with 2 letters then - such as:

CI-textforme
CI-textforyou
CI-textforthem
CI-textforboss
CI-textforwhoever
#4
Example:

Code:
Copy      Help
str s ss
ss.getmacro("function0")
foreach s ss
,out "s now contains %s" s
,;...

Assume, whole text is in function0.
getmacro stores function0 text into variable ss.
foreach repeatedly executes following code, each time extracting new line.
The line is stored in variable s. You can use s in a way you want.

To repeatedly execute code, you probably used rep or for. Here instead is used foreach.
#5
Ginataras this is almost what I need, I set it up to run a test in Notepad:

here is the sequence I have:

act win(" Notepad" "Notepad")
'Y
str a
int n
for n 1 101
,a.from("test" n)
,key (a)
,'Y
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,str t tt
tt.getmacro("function0")
foreach t tt
,out "t now contains %t" t
,.....
,.....
,.....
,.....
,.....
,key (t)
,'YYYYY

the problem I have now is that it completes all of the "test" loop before starting the "function0" loop.

I need it to activate "test1"
then the first line from "function0"
then move back to the top and activate "test2"
then the second line from "function0"
and so on, what am I missing to get this to work?

I tried this variation to the sequence:

act win(" Notepad" "Notepad")
'Y
str a
int n
for n 1 101
,a.from("test" n)
,key (a)
,'Y
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,.....
,str t tt
,tt.getmacro("function0")
,foreach t tt
,,out "t now contains %t" t
,,.....
,,.....
,,.....
,,.....
,,.....
,,key (t)
,,'YYYYY

It is a little closer, now it runs the first loop of "test", but it inserts every line from "function0" and then does the same for each loop of "test" this runs into an almost unending notepad page when I test it, lol.

By the way thanks a ton for the help thus far it has been greatly appreciated.
#6
Here foreach should be used instead of for. Then you would have to use some extra code to increase n and break when it is > 100. Alternatively, instead of foreach, use str function getl to get n-th line:

Code:
Copy      Help
act win(" Notepad" "Notepad")
spe 10
'Y
str a
int n
str t tt
tt.getmacro("Chess3")

for n 1 101
,a.from("test" n)
,key (a)
,'Y
,;.....
,;.....
,;.....
,;.....
,;.....
,;.....
,;.....
,;.....
,;.....
,;.....
,;.....
,t.getl(tt n-1)
,;out "t now contains %s" t
,;.....
,;.....
,;.....
,;.....
,;.....
,key (t)
,'YYYYY
#7
Thanks again Gintaras, it works perfectly.


Forum Jump:


Users browsing this thread: 1 Guest(s)