if-statement

PHP Quiz Radio and Checkbox Calculation

拥有回忆 提交于 2020-06-16 17:31:41
问题 I'm designing a simple quiz with PHP and would like to know if i'm approaching it the correct way before proceeding. The quiz will have approximately 25 questions, a mixture of radio buttons and checkboxes. The idea is to calculate the total and display this to the user when the quiz is submitted. I have just four questions so far. Questions 1 - 3 are radio buttons, one selection max. Question 4 is a checkbox and allows two selections max, each correct selection is worth 0.5 Here's a snippet

awk, if else conditional when record contains a value

依然范特西╮ 提交于 2020-06-16 17:27:11
问题 I'm having trouble getting an awk if/else conditional to properly trigger when the record contains a value. Running this in zsh on Mac OS Catalina. This script (issue is on second to last line)... echo "abcdefgh" > ./temp echo "abc\"\(\"h" >> ./temp echo "abcdefgh" >> ./temp echo "abcde\(h" >> ./temp val='"\("' key="NEW_NEW" file="./temp" echo $val echo $key echo $file echo "" echo "###############" echo "" awk ' BEGIN { old=ARGV[1]; new=ARGV[2]; ARGV[1]=ARGV[2]=""; len=length(old) } ($0 ~

awk, if else conditional when record contains a value

狂风中的少年 提交于 2020-06-16 17:25:28
问题 I'm having trouble getting an awk if/else conditional to properly trigger when the record contains a value. Running this in zsh on Mac OS Catalina. This script (issue is on second to last line)... echo "abcdefgh" > ./temp echo "abc\"\(\"h" >> ./temp echo "abcdefgh" >> ./temp echo "abcde\(h" >> ./temp val='"\("' key="NEW_NEW" file="./temp" echo $val echo $key echo $file echo "" echo "###############" echo "" awk ' BEGIN { old=ARGV[1]; new=ARGV[2]; ARGV[1]=ARGV[2]=""; len=length(old) } ($0 ~

awk: negative exponential is not correctly interpreted

孤者浪人 提交于 2020-06-16 03:37:38
问题 I have this table: a 0 b 0 c 1.6149e-315 d 5.2587e-265 e 8.2045e-227 f 8.2045e-227 If I type $awk '($2<1){print}' my_file.txt it returns a 0 b 0 d 5.2587e-265 e 8.2045e-227 f 8.2045e-227 but it considers the value in the third row, 1.6149e-315, to be larger than 1: $awk '($2>1){print}' my_file.txt c 1.6149e-315 Which is the reason for this behaviour? Is a negative exponential <1e-300 too small so it removes the "e-" part? It looks so, since $awk '($2>1.6149){print}' my_file.txt c 1.6149e-315

Test IF file exist, ELSE xcopy these two files

天涯浪子 提交于 2020-06-14 06:18:30
问题 Morning all. So I've been up hours trying to cobble together -a variety of replies to other posts- into my own code in order to see if I could get something usable. No-go. I'm sufficiently lost in the sauce that I've now got to ask for some help from you. Background: OS: Windows 10 I use the program text2folders.exe to create 20-30 new folders on a secondary drive every night. Primarily, I have a base file "aGallery-dl.bat" that I populate each folder with using an xcopy batch file.

Test IF file exist, ELSE xcopy these two files

纵饮孤独 提交于 2020-06-14 06:18:06
问题 Morning all. So I've been up hours trying to cobble together -a variety of replies to other posts- into my own code in order to see if I could get something usable. No-go. I'm sufficiently lost in the sauce that I've now got to ask for some help from you. Background: OS: Windows 10 I use the program text2folders.exe to create 20-30 new folders on a secondary drive every night. Primarily, I have a base file "aGallery-dl.bat" that I populate each folder with using an xcopy batch file.

Conditional @click with a method in vuejs

折月煮酒 提交于 2020-06-12 07:23:26
问题 This is my for loop: <li v-for="(crumb, index) in breadcrumbs" :class="{ 'is-active' : index==breadcrumbs.length-1 }"> <a href="javascript:void(0)" v-if="index==breadcrumbs.length-1">{{ crumb.name }}</a> </li> @click="methodName" shouldn't be available for the last iteration. I can check the last iteration with index==breadcrumbs.length-1 Is this possible using apply v-if? 回答1: There is a possibility by defining the event handler this way: v-on="condition ? { eventName: () => handler } : {}"

Conditional @click with a method in vuejs

风格不统一 提交于 2020-06-12 07:22:12
问题 This is my for loop: <li v-for="(crumb, index) in breadcrumbs" :class="{ 'is-active' : index==breadcrumbs.length-1 }"> <a href="javascript:void(0)" v-if="index==breadcrumbs.length-1">{{ crumb.name }}</a> </li> @click="methodName" shouldn't be available for the last iteration. I can check the last iteration with index==breadcrumbs.length-1 Is this possible using apply v-if? 回答1: There is a possibility by defining the event handler this way: v-on="condition ? { eventName: () => handler } : {}"

Using lapply with if to test each element in a list

大兔子大兔子 提交于 2020-06-09 12:56:09
问题 Suppose I have a list: alist<- list(4,6,8,9) I want test if each list element is greater than 7 and return a list of 1 if its true and 0 if false. However I must use lapply. lapply(alist,if,>7,1) or lapply(alist,if,cond>7,1) Of course none of these work and I keep getting the following error. Error: unexpected ',' in "lapply(alist, if," 回答1: It pains me to answer this because it's very un R to do this. You could try being more explicit and use brackets as in: lapply(alist, function(x) if (x >

Bash - what's the use of “fi ;;”?

你说的曾经没有我的故事 提交于 2020-06-07 08:15:10
问题 I have been searching everywhere for an explanation. Here's a real example taken from the apt-fast.sh script: if [ ! -x /usr/bin/axel ] then echo "axel is not installed, perform this?(y/n)" read ops case $ops in y) if apt-get install axel -y --force-yes then echo "axel installed" else echo "unable to install the axel. you are using sudo?" ; exit fi ;; n) echo "not possible usage apt-fast" ; exit ;; esac fi What's the use of "fi ;;" in the middle of the if block? 回答1: fi closes the if