In Revolution, you might say: And the Java Equivalent is: Information
  GREP search & replace info
put 3 into x
set y to 7
x = 3;
y = 7;
suggestion: "=" is pronounced "gets"
(so the line to the left says "x gets 3")
find:
replace:
 
if k=37 then
   put 12 into z
else
   put  42 into z
end if

if k=37 then put 12 into z
else put  42 into z   
#notice no 'end if' since 
#these are one liners
if (k == 37) {
   z = 12;
} else {
   z = 42;
}
There HAS to be a set of parentheses around the (comparison), and you HAVE to use == (double equals) to compare things, and you HAVE to put {curly braces} around the things to do.
  if to end if|else
find:
replace:
  original (if with return)
find:
replace:
  (single line if...else) find:
replace:
 
repeat with z = 1 to 3
   add 1 to x
   put z after fld "bob"
end repeat
for (int z=1; z < 4; z++) {
   System.out.println(z);
}
It's like there is an invisible word "while" after the first ";" semi-colon. This statement means "start with z at 1, and (while z is less than 4) keep printing out z and adding 1 to it.
on moveTheLander
  set the y of gcLander \
     to the y of gcLander \ 
     + the dy of gcLander
end moveTheLander
    
public void moveTheLander() {
  y = y + dy;
} // moveTheLander
    
function squareRoot x
  y = bunchOfMath( x ) 
  # do a bunch of math
  return y
end squareRoot
    
public double squareRoot(int x) {
  y = math.bunchOfMath( x); 
      // do a bunch of math
  return y;
} // squareroot()
    
Note that comments begin with //
if the loc of gcLander is 
    within the rectangle 
       of gcTarget then ...
if ( gcTarget.getRect().contains(x,y) ) {
   ...
gcTarget needs a "getRect()" program which describes gcTarget's Rectangle* to anybody who asks.
*( return new Rectangle( (int) left, (int) top, (int) width, (int) height) ).

The following are notes I've started to make about how to partially convert a revolution program into a java program...

#first, before fixing assignments, fix all the "=" (which will be
#comparisons) so they are "==" java comparisons...
find:=
replace:==

find:is
replace:==


#fix assignments:
find:put (.+)into (.+)
replace:\2 = \1 ;


#fix one-line if/then:
find:if (.+) then (.+)$
replace:if (\1) { \2 }

#prepare for multi-line if/else ifs by cleaning single line "else if"s...
#note: revolution treats else\rif... differently than else if...
find:else +if (.+)then
replace:} elsif (\1) {


#fix multi-line if/else 
#note: this search has to start from the top of the file!
#note:(?s) means "." includes returns (otherwise it doesn't).
#hmmm: this does NOT work with "else if..." ???
#perhaps precede this with "else if" becomes "elsif" for later fixing...
find:(?s)if\W(.+?)\Wthen\W(.+?)\Welse\W(.+?)\Wend if
replace:if (\1) { \r \2 \r } else { \r \3 \r }


#fix multi-line if w/o else 
#note:(?s) means "." includes returns (otherwise it doesn't).
#hmmm: will this work with "else if..." ???
find:(?s)if\W(.+)\Wthen\W(.+)\Wend if
replace:if (\1) { \r \2 \r } 

#finish multi-line if/else ifs by cleaning single line "else if"s...
#note: revolution treats else\rif... differently than else if...
find:elsif
replace:else if


#turn repeat with... into for loop:
find:repeat with (.+)=(.+) to (.+)
replace:for (int \1 = \2; \1 < \3; ++\1) {

find:end repeat
replace:}


#convert "add .. to __" to "__ = __ + .."
#note: this could of course also become "__ += .."
find:add (.+) to (.+)
replace:\2 = \2 + \1;


#convert "on ..." into void function 
#note: find the matching end of function by hand and
#turn it into "} // end funcname()" unless I figure out how
#to search for something I've already found ("\1"?) and then
#search for "end \1" which changes to "} // end \1"
find:^on (.+?) (.+)
replace:public void \1 (<type(s)?> \2) {


#hide "play" commands (or find the java equivalent)
find:^(\W*)play (.+)$
replace:// play \2


#convert "exit ..." into return
find:^(\W*)exit (.+)$
replace:return // exit \1


#convert " and " to " && "
find: and 
replace:&&


#convert " or " to ||
find: or 
replace:||


#ideally, FIRST occurrences of variables would get some "<type?>" 
#and remember, there's a revolution preference that forces you to
#declare variables (like that perl strict option).
prefix

revised 27 feb 2005, mjr