This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Deleting a specific thing in an output file

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
M
Mas
Voice
Posts: 2
Joined: Thu Feb 04, 2016 4:37 pm

Deleting a specific thing in an output file

Post by Mas »

Hello ... I have a score file in which there are two things when its output it seems like this
teamname,points
example
Gladiators,5000 Titanic,3000 Clusters,2000
at months end it reset whole file and i just want to delete the scores and reset it to 0 as below
Gladiators,0 Titanic,0 Clusters,0

#MANUALLY reset current Team Member scores & Team Scores for month MANUALLY
proc tgresetscores {nick host hand text} {
global tgteambyname tgteamscore tgscoresbyname tgteamscoretotal
global tgtscf tgteamscore
if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
if {[file exists member.scores]&&[file size member.scores]>2} {
set _sfile [open member.scores w]
puts $_sfile ""
close $_sfile
set tgteamscore ""
set tgteamscoretotal 0
}
#THIS IS THE 2ND PART WHICH IS RESETTING WHOLE FILE WE JUST NEED TO DELETE THE SCORE NOT THE TEAM

if {[file exists $tgtscf]&&[file size $tgtscf]>2} {
set _sfile [open $tgtscf w]
puts $_sfile ""
close $_sfile
set tgteamscore ""
set tgteamscoretotal 0
}
tggamemsg "[tgcolrset]===== Score table & Stats reset by $nick! ====="
}
}
[/code]
Last edited by Mas on Thu Mar 03, 2016 5:00 pm, edited 1 time in total.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Code: Select all

proc tgresetscores {nick host hand text} { 
  global tgteambyname tgteamscore tgscoresbyname tgteamscoretotal 
  global tgtscf tgteamscore 

  if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} { 


    if {[file exists member.scores]&&[file size member.scores]>2} { 
      set _sfile [open member.scores w] 
      puts $_sfile "" 
      close $_sfile 

### remove 2 lines here ###

    }  
 #THIS IS THE 2ND PART WHICH WE JUST NEED TO DELETE THE SCORE NOT THE TEAM 

    set tlist [array names tgteamscore]
    foreach team $tlist { 
      set tgteamscore($team) 0
    } 
    tgsavescores
    set tgteamscoretotal [llength $tlist]


    tggamemsg "[tgcolrset]===== Score table & Stats reset by $nick! =====" 
  } 
} 

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
M
Mas
Voice
Posts: 2
Joined: Thu Feb 04, 2016 4:37 pm

Thank you very mich Spike^^

Post by Mas »

Thank you very much Spike^^ bro you are a life saver really your code worked like a charm ... thanks once again....
Post Reply