Create copies of code part with increasing numbers

Help with writing and playing macros

Create copies of code part with increasing numbers

Postby Speedo » Tue May 29, 2007 6:42 pm

I've never messed with macros in UE before, 'til this need... The documentation isn't giving me much of an idea on how to do this, but it can't be that difficult, surely.

Basically, I need to duplicate this piece of code 750 times, incrementing the numbered variable each time (aren't scripting languages without arrays wonderful?).

Code: Select all
elseif ( tltravvars.trav002 == 0 )
   set tltravvars.trav002 to newtrav


Thanks in advance. :)
User avatar
Speedo
Newbie
 
Posts: 1
Joined: Mon Apr 23, 2007 11:00 pm

Re: Create copies of code part with increasing numbers

Postby jorrasdk » Tue May 29, 2007 9:04 pm

First you go and get Mofis macro examples which you can download from the sticky in the macro section of the forum. We need Mofis excellent CountUp macro.

Then try this macro:

Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOff
Clipboard 0
Loop 750
"elseif ( tltravvars.trav000 == 0 )
   set tltravvars.trav000 to newtrav
"
Key HOME
EndLoop
Top
Find "000"
Copy
Top
Loop
Find "000"
IfNotFound
ExitLoop
EndIf
PlayMacro 1 "CountUp"
Find "000"
IfNotFound
ExitLoop
EndIf
Paste
EndLoop
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Create copies of code part with increasing numbers

Postby Mofi » Wed May 30, 2007 6:36 am

I think for this simple job following macro is better because it is much faster.

InsertMode
ColumnModeOff
HexOff
NewFile
Clipboard 9
Loop 10
"elseif ( tltravvars.trav == 0 )#!#   set tltravvars.trav to newtrav
"
EndLoop
SelectAll
Copy
EndSelect
Bottom
Loop 74
Paste
EndLoop
ClearClipboard
Clipboard 0
Key BACKSPACE
Top
Loop 24
Key RIGHT ARROW
EndLoop
ColumnModeOn
ColumnInsertNum 0 1 LeadingZero
Loop 35
Key RIGHT ARROW
EndLoop
ColumnInsertNum 0 1 LeadingZero
ColumnModeOff
Bottom
InsertLine
Top
Find "#!#"
Replace All "^p"
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4056
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros