This is how to make commands for finding the minimum and maximum number from a string of one-digit numbers.

Find Maximum Number Command

This command has to be called like this: 123. Typing 123 finds the maximum number out of 1, 2, and 3. It's possible to add as many numbers in the string.

Creating the Command

The first step for creating the command is to make a block called Find Biggest Number and then add a number input called Number string. Make this code under the define block:

define Find Biggest Number (Number string)
set [count v] to [0]
set [biggest number v] to [0]
repeat (length of (Number string))
change [count v] by (1)
if <(letter (count) of (Number string)) > (biggest number)> then
set [biggest number v] to (letter (count) of (Number string))
end
end

Using the Command

Now make a script like this one to test the command:

Find Biggest Number (123) :: custom
say (biggest number)

If the program is correct, the sprite should say the number 3. If the sprite says no number or another number, check the define block's script.

Find Minimum Number Command

This command uses a similar approach to the find maximum number command. The command is called the same way as the maximum number command.

Creating the Command

The first step for creating this command is to make a block called Find Lowest Number and then add a number input called Number string. Make this code under the define block:

define Find Lowest Number (Number string)
set [count v] to [0]
set [lowest number v] to [10] // start at 10 because otherwise the lowest number will always be 0
repeat (length of (Number string))
change [count v] by (1)
if <(letter (count) of (Number string)) < (lowest number)> then
set [lowest number v] to (letter (count) of (Number string))
end
end

Using the Command

Now make a script like this one to test the command:

Find Lowest Number (123) :: custom
say (lowest number)

If the program is correct, the sprite should say the number 1. If the sprite says no number or another number, check the define block's script.

Uses For These Commands

They are used for some reasons, like:

  1. Finding the maximum or minimum number of a number string.
  2. Quizzes where someone guess the highest or lowest number.
  3. Doing advanced calculations.