You know you can do that in one dialog instead of 4...
set theValues to text returned of (display dialog "Enter X1 Y1 X2 Y2 separated by a space." default answer "")
set {tids, text item delimiters} to {text item delimiters, space}
set {x1, y1, x2, y2} to text items of theValues
set text item delimiters to tids
display dialog "Distance = " & ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ (1 / 2)
So you just enter all the values at once with a space between each value. Then in code you separate it out into your variables. If your values will always be positive then you can just get the "words" of theValues to make it even more simple. But I would stick with using text item delimiters in case you want to also use negative values. Using "words" strips off the "-" symbol from the numbers.
If you wanted to get really fancy you could have the user put each value on a separate line like this...
set theValues to text returned of (display dialog "Enter X1 Y1 X2 Y2 on separate lines." default answer (return & return & return))
set {x1, y1, x2, y2} to paragraphs of theValues
display dialog "Distance = " & ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ (1 / 2)
TO EXPLAIN TEXT ITEM DELIMITERS:
You can convert a string into a list by getting the "text items" of the string. There is a value called "text item delimiters" (tids) which determines how that string is broken up into a list. By default tids is "" (eg. nothing). So for example look at this script...
set theString to "some text words"
set theList to text items of theString
--> {"s", "o", "m", "e", " ", "t", "e", "x", "t", " ", "w", "o", "r", "d", "s"}
The list you get is each character of the string as a separate item. That's because tids is the default value of "". Now let's look what happens if we change tids to something else. Let's make tids a space character instead and run the script again...
set theString to "some text words"
set text item delimiters to space
set theList to text items of theString
--> {"some", "text", "words"}
By making it a space the string gets broken up into the items that had a space between them. So you see we can control how the string is turned into a list by controlling tids. One thing to note: when we change tids to something other than the default value, after using it we have to change tids back. This is safe programming because some other part of the script may depend on the value of tids. So get in the habit of resetting tids after you're done. That's the basics of what the tids code does. It stores the initial value of tids (so we can change it back later), changes tids to a space, uses tids to turn the string into a list, then resets tids back to its initial value.
I hope that helps.