Get the Highest Value in Livecode - max

I have three variables with the following values...
put 10 into var1
put 7 into var2
put 2 into var3
How to get the highest value? For this example, I want to return 10 and display that "10 is the highest number". How can I achieve this?

This is quite standard in any programming language.
put max(var1,var2,var3) into myMax

Related

Syntax command to change specific value in column

I did a little research and gave my respondents the option "other" where they could specify where they're from if not from those categories that I gave them as options. This "other" category has been coded as category "6". But some people didn't read the existing categories well and wrote essentially what was given to them as an option. How can I change this in the dataset? So change a specific value "6" to "2" while using SPSS syntax? I tried looking everywhere but I haven't been able to find an answer :(
if your variable is var1; you can write and run in a syntax window:
recode var1 (6=2).
execute.
This will replace all 6 in var1 with a 2.
You can also create a new var2, hence making sure you are not overwriting your original var1:
recode var1 (6=2) (else=copy) into var2.
execute.
You might want to do this only for respondents you have identified as not having read all the answers correctly. Then you might want to create an additional variable:
misread
with values 1 if you want to change 6 into 2, and 0 if you want to keep 6.
Your code is, then:
do if (misread = 1).
recode var1 (6=2) (else=copy) into var2.
end if.

how to display 3 random pictures out of 8 using bash

I have 8 images in a directory.
the path is /blabla.com/img.
I need to access this path and choose 3 out of 8 randomly and display those.
If 3 pics are the same, it should echo "yeeey".
Otherwise, "neeey" and record these responses in a text file.
I am not going to do your homework for you!
However I can give you some insight:
store your 8 file names in an array
call $RANDOM % 8 3 times and store the value in 3 index variables
use the 3 index variables to extract your 3 files
use sha256sum, sha512sum or md5sum to compute the signature of your images and store the result in 3 variables
compare the values of the 3 variables if they are the same echo "yeeey" else echo "neeey"
if on top of that you want to display the picture as written in your post you could call eog or other similar tool with the finename as parameter and of course in background, with a & at the end of the command call.
Good luck with your assignment and let me know if you need help!
let's array an array of distinct elements (for example 8):
array=({A..H})
(1) use RANDOM special variable modulo the number of elements to get a random number between 0 and number-1 inclusive
number=$((RANDOM%${#array[#]}))
the first random element is
first=${array[number]}
remove the element from array and reassign the array to reindex without gap (declare -p array to see)
unset array[number]
array=("${array[#]}")
restart from (1)

Generate dynamic random variable in combination of alphabets and numbers for POST

I want to generate a dynamic random variable like ASDF123 during Post request and it should range from 7 digit to 10 digit and it should be unique everytime(if in case 500 threads). This field is required to generate order numbers. I'm new to Jmeter so not much idea.
My Scenarios is like this: .> I have to generate a variable in combination of alphabets and letters(like this ->ASDF12345) for post then need to provide same variable to get to retrieve the same order for each thread. It is working fine if I generate random variable ie. minimum 1000 to max:9999 and passing same to post and get. But the req is that the order no. can be alphabets & numeric/numeric/alphabet. Please suggest how to proceed for the same. And yes everytime it should be unique.
You can use Functions as:
RandomString - First parameter how many characters (10 in your case) and second parameter choose your combination of alphabets and numbers:
${__RandomString(10,abcdefg1234567890)}
Use Random if alphabets can be constant, and then add a number with 7-10 digits:
ASF${__Random(1000000,1000000000)}
Or use JSR223 element to use Random in your programming language as Java/Groovy.
You can try this:
${__javaScript(Math.random().toString(36).toUpperCase().substring(16))}
In jmeter it must looks like this:

Get an item randomly from a list

I've made a simple guessing game, which utilizes simple if-statement. Guess a number between 0 and 10. It'll hint you to put a higher/lower number. That's working fine. To make it a little more interesting, I'd like to taunt the user until the right answer is input.
Question: How to get a message item randonly and return this message if the user has not guessed the right number?
Example:
Guess a number: 5
You have no idea, huh? Try higher. 7
Ha! still far from it. Try higher. 8
Did you just fart? I'm sure it was a perfect 10! Try higher. 10
You momma did teach you how to count, right? Try lower. 9
Yes, well done!
Any ideas? :)
You can try:
# Store your string in a BASH array:
arr=( "foo" "bar" "baz" "abc" "xyz" )
# get a number between 0 and length of array:
len=${#arr[#]}
# get a random string from array using BASH variable $RANDOM
n=$(($RANDOM % len))
echo ${arr[$n]}

How do I create random in Eclipse?

I have 10 images and I want them to be prompt out randomly. What code should I use? I'm still an amateur so I hope I could get some answers here... The images are named like 'pic1', 'pic2' and so on. is it possible to get the number from the file name and use Math.random() ?
Store the pics in an Array.
Say array index is from 0 to 9
Use Java Math.random to get random number.
You need to multiply its result by 10 get indexes in your range

Resources