Bitcoin Forum
June 29, 2024, 09:04:38 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Any ideea?  (Read 553 times)
john85gotti (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
December 03, 2016, 11:27:30 PM
 #1

Hey, i'm new on codeing and i am stuck
I have a code in bash and i want to make it to increment or decrement, but i can t make it right
When i run the script, it\s workin' but increments only 1 number
Exemple:
1
1
1
1


This is the code

Code:
#!/bin/bash#
#Alchimie Fibonacci




nrstreak=0
bet=0.00000000




id=$1




echo "BET $bet"
won=`./bet 0.1 49 "<"`




############# CURRENTSTREAK #######################
if [ "$won" == "true" ] && [ "$nrstreak" -ge 0 ];
then
((nrstreak++))
echo "WON! +++"
elif [ "$won" == "true" ] && [ "$nrstreak" -lt 0 ];
then
echo "WON!"
fi






if [[ "$won" == "false" && "$nrstreak" -le 0 ]];
then
((nrstreak--))
echo "LOSE! ---"
elif [[ "$won" == "false" && "$nrstreak" -gt 0 ]];
then
echo "LOSE!"
fi
####################################################




echo "Nr_Streak = $nrstreak"


echo "---------------------------"
sleep 0.5



This in the result

Code:
BET 0.1
LOSE!
Nr_Streak = -1
---------------------------
BET 0.1
LOSE!
Nr_Streak = -1
---------------------------
BET 0.1
WON!
Nr_Streak = 1
---------------------------
BET 0.1
WON!
Nr_Streak = 1
---------------------------








Thank you, please excuse my bad english.
Vod
Legendary
*
Offline Offline

Activity: 3752
Merit: 3099


Licking my boob since 1970


View Profile WWW
December 04, 2016, 08:43:37 AM
 #2

1) This is a bitcoin forum, not a coding forum
2) You posted in off topic; coders probably don't read here
3) You didn't include a proper subject to attract the proper attention.

https://nastyscam.com - featuring 13 years of OGNasty bitcoin scams     https://vod.fan - advanced image hosting - coming sooner than you think!
Joel_Jantsen
Legendary
*
Offline Offline

Activity: 1918
Merit: 1310

Get your game girl


View Profile
December 04, 2016, 08:47:55 AM
 #3

What is this ?

Code:
id=$1

Where is the for-loop ?
john85gotti (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
December 04, 2016, 08:49:51 AM
 #4

Yes, you are right, but i don't know where to put it
TooQik
Sr. Member
****
Offline Offline

Activity: 337
Merit: 258


View Profile
December 04, 2016, 08:50:12 AM
 #5

I'd say you're calling nrsteak=0 EVERY time your code is called, so you're always either adding or subtracting one from 0.
Joel_Jantsen
Legendary
*
Offline Offline

Activity: 1918
Merit: 1310

Get your game girl


View Profile
December 04, 2016, 08:55:13 AM
 #6

What is this ?

Code:
id=$1

Where is the for-loop ?

Edit : Put your CURRENTSTREAK,both the if conditions inside a for loop.
Syntax :
Code:
for VARIABLE in file1 file2 file3
do
command1 on $VARIABLE
command2
commandN
done
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!