Page 9 of 10 « First<678910>
Topic Options
#178970 - 2007-08-08 11:42 PM Re: KiXgolf: Top Secret [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just typing something and executing.
most of the times it fails, rarely it produces a working result.

you should try ;\)
_________________________
!

download KiXnet

Top
#178979 - 2007-08-09 06:16 AM Re: KiXgolf: Top Secret [Re: Lonkero]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
I have to apologize for not getting back to you guys earlier. The days at work are a bit hectic right now and I just finished a 14 hour shift :-(

Anyway, as my instructions were a bit unclear and caused confusion I am therefore decreeing the following:
1) Characters are only the characters within the range of A-Z and a-z, thus ASCII codes 65-90 and 97-122. Any other character is thus classified as punctuation and should be left in their original positions. This includes numbers, special charattcers that some languages are using and any other symbol, etc.
2) I'm adding some of DrillSergeant's test cases to the package (but not 7 or 10). I added a test case 11, which is a modification from test case 1 with the spaces replace by numeric characters. As this should not change the encoded message it's a quick way to test for numerics.
3) I'll extend the private round until Thursday 6pm EST to give everybody a chance to digest the decrees.

I believe that with these clarifications nobody is being put at an disadvanges, though the Europeans may have a head-start now.


Edited by Sealeopard (2007-08-09 06:17 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#178980 - 2007-08-09 06:51 AM Re: KiXgolf: Top Secret [Re: Sealeopard]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Originally Posted By: Sealeopard

3) I'll extend the private round until Thursday 6pm EST to give everybody a chance to digest the decrees.


Thank you Jens,

I half feared that though ... Oh, my poor head
_________________________



Top
#178981 - 2007-08-09 08:40 AM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
And again I have to retract my scores posted so far as my 426 code fails test case #6
_________________________



Top
#178982 - 2007-08-09 08:45 AM Re: KiXgolf: Top Secret [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn!
for once I was leading and now 2 extra days!?!?

come on!

now I feel abandoned!
_________________________
!

download KiXnet

Top
#178990 - 2007-08-09 10:32 AM Re: KiXgolf: Top Secret [Re: Lonkero]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
this is more fun then to watch tv. I think I need to take vacation and try this myself :).
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#178992 - 2007-08-09 10:53 AM Re: KiXgolf: Top Secret [Re: Björn]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
k,

here is my NEW score using the latest official test cases, please disregard all previous score postings \:\)
 Quote:

Running Test 1 Encoding...Decoding...Done
Running Test 2 Encoding...Decoding...Done
Running Test 3 Encoding...Decoding...Done
Running Test 4 Encoding...Decoding...Done
Running Test 5 Encoding...Decoding...Done
Running Test 6 Encoding...Decoding...Done
Running Test 8 Encoding...Decoding...Done
Running Test 9 Encoding...Decoding...Done
Running Test 11 Encoding...Decoding...Done
Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_ts.kix

Computer
OS = Windows 2000 Professional
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 504 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Top Secret
Processing Start = 2007/08/09 10:42:33.578
Processing End = 2007/08/09 10:42:33.593
Duration = 0000/00/00 00:00:00.014
KiXGolf Score = 439

Thank you for participating in KiXtart Golf!



The bug I produced for blocksize = 10 was a real noobish fault ... I'd bite my rear if only I could reach it
_________________________



Top
#178993 - 2007-08-09 10:58 AM Re: KiXgolf: Top Secret [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Originally Posted By: Jooel
just typing something and executing.
most of the times it fails, rarely it produces a working result.

you should try ;\)



ehmmmm ... ja ... LOL
_________________________



Top
#178994 - 2007-08-09 11:03 AM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
btw, my 439 score, for good measure, passes as well the 10 test cases Rogier provided...

I don't dare to say it is 100% water proof as there might be a yet unknown evil ascii cahracter that will eventually break it
_________________________



Top
#178995 - 2007-08-09 11:11 AM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
stripping it down to:

 Quote:

Running Test 1 Encoding...Decoding...Done
Running Test 2 Encoding...Decoding...Done
Running Test 3 Encoding...Decoding...Done
Running Test 4 Encoding...Decoding...Done
Running Test 5 Encoding...Decoding...Done
Running Test 6 Encoding...Decoding...Done
Running Test 8 Encoding...Decoding...Done
Running Test 9 Encoding...Decoding...Done
Running Test 11 Encoding...Decoding...Done
Your solution passed all tests

KiXtart
KiXtart Version = 4.53
KiXGolf Script = kixgolf_ts.kix

Computer
OS = Windows 2000 Professional
CPU = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed = 2793 MHz
Memory = 504 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Top Secret
Processing Start = 2007/08/09 11:09:18.156
Processing End = 2007/08/09 11:09:18.187
Duration = 0000/00/00 00:00:00.030
KiXGolf Score = 435

Thank you for participating in KiXtart Golf!


Edited by Jochen (2007-08-09 11:12 AM)
_________________________



Top
#178997 - 2007-08-09 11:36 AM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
please delete

Edited by Jochen (2007-08-09 01:43 PM)
_________________________



Top
#178998 - 2007-08-09 11:49 AM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
please delete

Edited by Jochen (2007-08-09 01:44 PM)
_________________________



Top
#178999 - 2007-08-09 01:20 PM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
please delete

Edited by Jochen (2007-08-09 01:44 PM)
_________________________



Top
#179000 - 2007-08-09 01:35 PM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
OMG, I accidentally erased the decoding part out of the calling script whilst adding screen output for failed tests.

I will download a fresh copy and edit all previous post with too less scores ... Sorry
_________________________



Top
#179002 - 2007-08-09 01:48 PM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Right, with a fresh copy of kixgolf_ts.kix my scores are now:

Running Test 1 Encoding...Decoding...Done
Running Test 2 Encoding...Decoding...Done
Running Test 3 Encoding...Decoding...Done
Running Test 4 Encoding...Decoding...Done
Running Test 5 Encoding...Decoding...Done
Running Test 6 Encoding...Decoding...Done
Running Test 8 Encoding...Decoding...Done
Running Test 9 Encoding...Decoding...Done
Running Test 11 Encoding...Decoding...Done
Your solution passed all tests

KiXtart
KiXtart Version  = 4.53
KiXGolf Script   = kixgolf_ts.kix

Computer
OS               = Windows 2000 Professional
CPU              = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed            = 2793 MHz
Memory           = 504 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.3

KiXtart Golf Score
Tournament       = Top Secret
Processing Start = 2007/08/09 13:46:41.546
Processing End   = 2007/08/09 13:46:41.578
Duration         = 0000/00/00 00:00:00.031
KiXGolf Score    = 429

Thank you for participating in KiXtart Golf!
_________________________



Top
#179003 - 2007-08-09 01:54 PM Re: KiXgolf: Top Secret [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Whoops, I forgot ...

Running Test 1 Encoding...Decoding...Done
Running Test 2 Encoding...Decoding...Done
Running Test 3 Encoding...Decoding...Done
Running Test 4 Encoding...Decoding...Done
Running Test 5 Encoding...Decoding...Done
Running Test 6 Encoding...Decoding...Done
Running Test 8 Encoding...Decoding...Done
Running Test 9 Encoding...Decoding...Done
Running Test 11 Encoding...Decoding...Done
Your solution passed all tests

KiXtart
KiXtart Version  = 4.53
KiXGolf Script   = kixgolf_ts.kix

Computer
OS               = Windows 2000 Professional
CPU              = Intel(R) Pentium(R) 4 CPU 2.80GHz
Speed            = 2793 MHz
Memory           = 504 MB

KiXGolf Scoring Engine
Scoring Engine   = 3.3

KiXtart Golf Score
Tournament       = Top Secret
Processing Start = 2007/08/09 13:51:23.312
Processing End   = 2007/08/09 13:51:23.359
Duration         = 0000/00/00 00:00:00.046
KiXGolf Score    = 426

Thank you for participating in KiXtart Golf!
_________________________



Top
#179017 - 2007-08-09 05:05 PM Re: KiXgolf: Top Secret [Re: Jochen]
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Crap. Only letters (A-Z and a-z) will add to my code.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#179018 - 2007-08-09 05:05 PM Re: KiXgolf: Top Secret [Re: Jochen]
DrillSergeant Offline
MM club member
*****

Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
must...lose...two...more...





KiXtart
KiXtart Version = 4.52
KiXGolf Script = kixgolf_ts.kix

Computer
OS = Windows XP Professional
CPU = Intel Pentium Model 13
Speed = 2261 MHz
Memory = 1024 MB

KiXGolf Scoring Engine
Scoring Engine = 3.3

KiXtart Golf Score
Tournament = Top Secret
Processing Start = 2007/08/09 17:46:50.421
Processing End = 2007/08/09 17:46:50.453
Duration = 0000/00/00 00:00:00.031
KiXGolf Result = Solution passed all 18 tests
KiXGolf Score = 359

Thank you for participating in KiXtart Golf!




Edited by DrillSergeant (2007-08-09 05:48 PM)
Edit Reason: Jooel's format
_________________________
The Code is out there

Top
#179022 - 2007-08-09 05:26 PM Re: KiXgolf: Top Secret [Re: Jochen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hehe...
dude, I like you using the pre.
looks lot nicer.

I modded the kixgolf_ts.kix:
 Code:
; KiXtart Golf
;
;
break on

; standard KiXgolf variables
dim $sGolfScoreUDF, $bGolfScore, $sKiXgolfUDF, $sOutputFile
dim $sTitle, $iRC, $sKiXGolfScrEngVer, $sKiXformsVer, $objKiXforms
dim $sStartTimeDate, $sEndTimeDate, $sRunTime
dim $iKiXGolfScore, $sOutput, $sResult,$outputResult

dim $sKiXGolfINI, $asTests, $iTests, $iValid, $sTest, $sInput, $sOutput, $sResult, $iBlockSize,$sPermutation


; set required options
$sTitle='Top Secret'
$iRC=SETTITLE('KiXtart Golf: '+$sTitle)
$iRC=SETOPTION('Explicit','on')
$iRC=SETOPTION('NoVarsInStrings','on')
$iRC=SETOPTION('NoMacrosInStrings','on')
$iRC=SETOPTION('WrapAtEOL','on')
$iRC=SETOPTION('CaseSensitivity','on')

cls

$sGolfScoreUDF=@scriptdir+'\'+'kixgolf3.3.udf'
if exist($sGolfScoreUDF)
  call $sGolfScoreUDF
  $bGolfScore=1
else
  ? 'Unable to find the KiXgolf Scoring Engine, exiting script'
  exit 2
endif
$sKiXGolfScrEngVer = '3.3'

; this is the actual KiXgolf UDF
$sKiXGolfUDF=@scriptdir+'\'+join(split(ucase(@scriptname),'.KIX'),'.udf')
if exist($sKiXGolfUDF)
  call $sKiXGolfUDF
else
  ? 'KiXgolf UDF not present!'
  exit 2
endif

; initialize official KiXtart Golf Score results file
$sOutputFile=@scriptdir+'\'+join(split(ucase(@scriptname),'.KIX'),'.txt')

; this is the start of the main loop
$sStartTimeDate=@DATE+' '+@TIME+'.'+right('000'+@MSECS,3)

$sKiXGolfINI=@scriptdir+'\'+join(split(ucase(@scriptname),'.KIX'),'.ini')
$asTests=split(readprofilestring($sKiXgolfINI,'',''),chr(10))
if $asTests[ubound($asTests)]=''
  redim preserve $asTests[ubound($asTests)-1]
endif
$iTests=(ubound($asTests)+1)*2
$iValid=0

for each $sTest in $asTests
  ? 'Running '+$sTest+' Encoding...'
  
  $iBlocksize=int(readprofilestring($sKiXgolfINI,$sTest,'Blocksize'))
  $sPermutation=readprofilestring($sKiXgolfINI,$sTest,'Permutation')
  $sInput=readprofilestring($sKiXgolfINI,$sTest,'Input')
  $sOutput=readprofilestring($sKiXgolfINI,$sTest,'Output')
  
  ; testing the encoding of a message
  $sResult=a($iBlocksize,$sPermutation,$sInput,'E')
  
  if $sOutput==$sResult
    $iValid=$iValid+1
  else
    ? "failed: '" $sOutput "' =! '" $sResult "'"?
  endif

  'Decoding...'

  ; testing the decoding of a message
  $sResult=a($iBlocksize,$sPermutation,$sResult,'D')
  
  if $sInput==$sResult
    $iValid=$iValid+1
  else
    ? "failed: " $sInput " =! " $sResult ?
  endif

  'Done'
next


; this is the end of the main loop
$sEndTimeDate=@DATE+' '+@TIME+'.'+right('000'+@MSECS,3)
$sRunTime=datetimediff($sStartTimeDate, $sEndTimeDate)
; this is the end of main loop

if $iValid=$iTests
  $outputResult='Solution passed all '+$iTests+' tests'
else
  $outputResult='Solution failed '+($iTests-$iValid)+' of '+$iTests+' tests.'
endif

; generate KiXtart Golf Score
$iKiXGolfScore=KiXGolf($sKiXGolfUDF)

; generating official KiXGolf Score
$sOutput=''
$sOutput=$sOutput+@CRLF+'KiXtart'
$sOutput=$sOutput+@CRLF+'KiXtart Version  = '+@KIX
$sOutput=$sOutput+@CRLF+'KiXGolf Script   = '+@SCRIPTNAME
$sOutput=$sOutput+@CRLF+''
$sOutput=$sOutput+@CRLF+'Computer'
$sOutput=$sOutput+@CRLF+'OS               = '+@PRODUCTTYPE
$sOutput=$sOutput+@CRLF+'CPU              = '+@CPU
$sOutput=$sOutput+@CRLF+'Speed            = '+@MHZ+' MHz'
$sOutput=$sOutput+@CRLF+'Memory           = '+(round(cdbl(MEMORYSIZE(0))/2)*2)+' MB'
$sOutput=$sOutput+@CRLF+''
$sOutput=$sOutput+@CRLF+'KiXGolf Scoring Engine'
$sOutput=$sOutput+@CRLF+'Scoring Engine   = '+$sKiXGolfScrEngVer
$sOutput=$sOutput+@CRLF+''
$sOutput=$sOutput+@CRLF+'KiXtart Golf Score'
$sOutput=$sOutput+@CRLF+'Tournament       = '+$sTitle
$sOutput=$sOutput+@CRLF+'Processing Start = '+$sStartTimeDate
$sOutput=$sOutput+@CRLF+'Processing End   = '+$sEndTimeDate
$sOutput=$sOutput+@CRLF+'Duration         = '+$sRunTime
$sOutput=$sOutput+@CRLF+'KiXGolf Result   = '+$outputResult
$sOutput=$sOutput+@CRLF+'KiXGolf Score    = <font color="red">'+$iKiXGolfScore+'</font>'
$sOutput=$sOutput+@CRLF+' '
$sOutput=$sOutput+@CRLF+'Thank you for participating in KiXtart Golf!'

; saving and displaying official KiXtart Golf Score
$iRC=redirectoutput($sOutputFile,1)
'<br><br><pre style="background:white;border-style:solid;border-color:silver;">'
? $sOutput+@CRLF+'</pre><br><br>'
$iRC=redirectoutput('')
? $sOutput

; display score when using WKIX32
if @SCRIPTEXE='WKIX32.EXE'
  ? 'Press any key to continue...'
  ? 'Remember to post your scrore!'
  get $iRC
  run 'notepad '+$sOutputFile
endif

exit 0

; any modifications below this line will result in immediate disqualification
;support UDFs for date/time calculations
;FUNCTION      DateTimeDiff
;
;ACTION        Calculates the time difference between two date-times-groups
;
;AUTHOR        Jens Meyer (sealeopard@usa.net)
;
;VERSION       1.1
;
;KIXTART       4.20
;
;SYNTAX        DATETIMEDIFF(DTG1 [,DTG2])
;
;PARAMETYERS   DTG1
;              Required string as a date-time-group (DTG) in one of the following formats:
;              "YYYY/MM/DD HH:MM[:SS.MSECS]"
;              "YYYY/MM/DD" which assumes that HH:MM[:SS.MSECS] = 00:00:00.000
;              "HH:MM[:SS.MSECS]" which assumes that "YYY/MM/DD" = @DATE
;
;              DTG2
;              Optional string as date-time-group (DTG) in one of the following formats:
;              "YYYY/MM/DD HH:MM[:SS.MSECS]"
;              "YYYY/MM/DD" which assumes that HH:MM[:SS.MSECS] = @TIME
;              "HH:MM[:SS.MSECS]" which assumes that "YYY/MM/DD" = @DATE
;              DTG2 will default to the current date and time if not provided in the form of
;              @DATE+' ' +@TIME+'.'+@MSECS
;
;
;
;RETURNS       Returns difference DTG2-DTG1 as "YYYY/MM/DD HH:MM[:SS.MSECS]"
;
;REMARKS       none
;
;DEPENDENCIES  SERIALTIME() @ http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000039
;              SERIALDATE() @ http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000089
;
;EXAMPLE       $rc=DATETIMEDIFF('23:20:33','01:01:01.245')
;
;KIXTART BBS   http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000374
;
function datetimediff($time1,$time2)
  Dim $date1, $date2, $datediff, $timediff

  $datetimediff=''

  if not instr($time1,' ')
    select
    case instr($time1,'/')
      $time1=$time1+' 00:00:00.000'
    case instr($time1,':')
      $time1=@DATE+' '+$time1
    case 1
      exit 87
    endselect
  endif

  if not instr($time2,' ')
    select
    case instr($time2,'/')
      $time2=$time2+' '+@TIME+'.'+right('000'+@MSECS,3)
    case instr($time2,':')
      $time2=@DATE+' '+$time2
    case 1
      $time2=@DATE+' '+@TIME+'.'+right('000'+@MSECS,3)
    endselect
  endif

  $time1=split($time1,' ')
  $date1=$time1[0]
  $time1=$time1[1]
  $time2=split($time2,' ')
  $date2=$time2[0]
  $time2=$time2[1]

  $datediff=serialdate($date2)-serialdate($date1)
  $timediff=serialtime($time2)-serialtime($time1)
  if $timediff=>86400
    $timediff=$timediff-86400
    $datediff=$datediff+1
  endif
  $datediff=serialdate(serialdate('0000/00/00')+$datediff-1)
  $timediff=serialtime($timediff)

  $datetimediff=$datediff+' '+$timediff
  exit 0
endfunction

;FUNCTION      SerialDate
;
;ACTION        Convert dates to numbers (and back) for the purpose of performing date math
;
;AUTHOR        ScriptLogic (http://www.scriptlogic.com)
;
;CONTRIBUTOR   Jens Meyer (sealeopard@usa.net)
;
;VERSION       1.1
;
;SYNTAX        SERIALDATE(DATE)
;
;PARAMETERS    DATE or NUMBER
;              if a date is used, it must be in the form of "YYYY/MM/DD"
;              if a number is used, it must be a number previously derived from this function.
;
;RETURNS       If a date is passed to this function, the function returns a number. If a number is
;              passed to this function, a date "YYYY/MM/DD" is returned
;
;REMARKS       This function was developed as a core routine for the DateMath( ) function. In
;              normal usage, you would most like just use the DateMath( ) function which depends
;              on this function.
;              Algorithms used in the development of this routine were obtained from:
;              http://www.capecod.net/~pbaum/date/date0.htm
;
;              Fixed a couple of inconsistencies in the returned values and formatting
;
;DEPENDENCIES  none
;
;EXAMPLE       $rc=serialdate('2001/07/01')
;
;KIXTART BBS   http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000089
;
function serialdate($ExpD)
  dim $z,$h,$a,$b,$c,$y,$m,$d
  if instr($ExpD,'/')
    $ExpD=split($ExpD,'/')
    $y=val($ExpD[0])
    $m=val($ExpD[1])
    $d=val($ExpD[2])
    if $m<3
      $m=$m+12
      $y=$y-1
    endif
    $SerialDate=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306
  else
    $z=0+$ExpD+306
    $h=100*$z-25
    $a=$h/3652425
    $b=$a-$a/4
    $y=(100*$b+$h)/36525
    $c=$b+$z-365*$y-$y/4
    $m=(5*$c+456)/153
    $d=$c-(153*$m-457)/5
    if $m>12
      $y=$y+1
      $m=$m-12
    endif
    $SerialDate=right('0000'+$y,4)+'/'+right('00'+$m,2)+'/'+right('00'+$d,2)
  endif
endfunction

;FUNCTION      SerialTime
;
;AUTHOR        Jens Meyer (sealeopard@usa.net)
;
;ACTION        Convert time to numbers (and back) for the purpose of performing time math
;
;VERSION       1.1
;
;KIXTART       4.20
;
;SYNTAX        SERIALTIME(STRTIME)
;
;PARAMETERS    STRTIME
;              Reqired string containing either a time "HH:MM[:SS.MSECS]" or an integer greater
;              than zero and less than 86400 representing seconds and fractions
;              e.g 20.040 for 20 seconds and 40 milliseconds
;
;RETURNS       If supplied a time, returns seconds since midnight. If supplied seconds since
;              midnight, returns time.
;
;REMARKS       Reworked function based on the ScriptLogic UDF but without dependencies and adapted for milliseconds
;              The original ScriptLogic UDF at
;              http://www.scriptlogic.com/kixtart/FunctionLibrary_ViewFunction.aspx?ID=SerialTime
;              cannot manage milliseconds and relies on three dependencies.
;
;DEPENDENCIES  none
;
;EXAMPLE       $rc=SERIALTIME('02:20:33.187')
;
;KIXTART BBS   http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000039
;
function serialtime($strtime)
  dim $hours, $minutes, $seconds, $milliseconds

  if instr($strtime,':')
    $strtime=split($strtime,':')

    select
    case ubound($strtime)<3
      redim preserve $strtime[3]
      if instr($strtime[2],'.')
        $strtime[3]=right($strtime[2],len($strtime[2])-instr($strtime[2],'.'))
        $strtime[2]=left($strtime[2],instr($strtime[2],'.')-1)
      else
        $strtime[3]=0
      endif
    case ubound($strtime)>3
      $serialtime=-1
      exit 87
    endselect

    $hours=val($strtime[0])
    if $hours<0 or $hours>23
      $serialtime=-1
      exit 87
    endif
    $minutes=val($strtime[1])
    if $minutes<0 or $minutes>59
      $serialtime=-1
      exit 87
    endif
    $seconds=val($strtime[2])
    if $seconds<0 or $seconds>59
      $serialtime=-1
      exit 87
    endif
    $milliseconds=cdbl($strtime[3])
    if $milliseconds<0 or $milliseconds>999
      $serialtime=-1
      exit 87
    endif
    $serialtime=0.0+($hours*3600)+($minutes*60)+($seconds)+($milliseconds/1000)
  else
    $strtime=val(cdbl($strtime)*1000)
    if $strtime<=86400000 and $strtime>=0
      $hours=$strtime/3600/1000
      $strtime=$strtime-($hours*3600*1000)
      $hours=right('00'+$hours,2)
      $minutes=$strtime/60/1000
      $strtime=$strtime-($minutes*60*1000)
      $minutes=right('00'+$minutes,2)
      $seconds=$strtime/1000
      $strtime=$strtime-($seconds*1000)
      $seconds=right('00'+$seconds,2)
      $milliseconds=left($strtime,3)
      $milliseconds=right('000'+$milliseconds,3)
      $serialtime=$hours+':'+$minutes+':'+$seconds+'.'+$milliseconds
    else
      $serialtime='-1'
      exit 87
    endif
  endif
endfunction

; this is a replacement for the formatnumber() function that seems to be buggy
function numberformat($number,$digits)
  dim $comma

  $comma=READVALUE('HKEY_CURRENT_USER\Control Panel\International','sDecimal')
  $digits=val($digits)
  if $digits<0
    $digits=0
  endif
  $number=''+round(cdbl($number),$digits)
  if not instr($number,$comma)
    $number=$number+$comma
  endif
  $number=split($number,$comma)
  if $digits=0
    $numberformat=$number[0]
    return
  endif
  while len($number[1])<$digits
    $number[1]=$number[1]+'0'
  loop
  $number=join($number,$comma)
  $numberformat=$number
endfunction

;FUNCTION      ATrim
;
;ACTION        Strips leading and trailing spaces from an input string or array and returns the result
;
;AUTHOR        Jens Meyer (sealeopard@usa.net)
;
;VERSION       1.3
;
;KIXTART       4.20
;
;SYNTAX        ATRIM(STRING)
;
;PARAMETERS    STRING
;              Required string or array from which to strip leading and trailing spaces
;
;RETURNS       Input string/array without leading and trailing spaces
;
;REMARKS       Function converts an array with a maximum of 26 dimensions
;
;DEPENDENCIES  none
;
;EXAMPLE       $array[0]=' String1'
;              $array[1]=' String2 '
;              $rc=atrim($array)
;
;KIXTART BBS   http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000031
;
function atrim($array)
  Dim $element, $maxelements, $arraydim, $rc, $a

  select
  case ubound($array,1)=-1
    $array=trim($array)
  case ubound($array,2)=-1
    $maxelements=val(ubound($array))
    for $element=0 to $maxelements
      $array[$element]=trim($array[$element])
    next
  case ubound($array,27)=-1
    $arraydim=0
    do
      $arraydim=$arraydim+1
    until ubound($array,$arraydim)=-1
    $arraydim=$arraydim-1
    if $arraydim<=26
      dim $cmd, $vars
      $vars='$sub_a'
      for $a=2 to $arraydim
        $vars=$vars+', $sub_'+chr($a+96)
      next
      $cmd='dim '+$vars+@CRLF
      for $a=1 to $arraydim
        $cmd=$cmd+'for $sub_'+chr($a+96)+'=0 to ubound($array,'+$a+')'+@CRLF
      next
        $cmd=$cmd+'$array['+$vars+']=trim($array['+$vars+'])'+@CRLF
      for $a=1 to $arraydim
        $cmd=$cmd+'next'+@CRLF
      next
      $rc=execute($cmd)
    endif
  case 1
  endselect

  $atrim=$array
endfunction


to note, when there is a failure, I think showing the failure is crucial, that's why there is print line on the check part.
with wkix32.exe, displaying the result could be totally supressed, if there are no errors, just splash the notepad open.
_________________________
!

download KiXnet

Top
#179024 - 2007-08-09 05:29 PM Re: KiXgolf: Top Secret [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn, you guys working on the script while I'm strucling with virtual servers here.

hoby, dude, I wanna see your code if that's the case!
_________________________
!

download KiXnet

Top
Page 9 of 10 « First<678910>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 370 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.082 seconds in which 0.031 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org