Jump to content

refusing to do math O_o


Recommended Posts

i'm having an... odd problem, to the very least.

i made a little script to track how many hours i spend working, to make sure my boss isn't ripping me off.

he's a <manually censored> like that. so, to make sure, he writes down my hours, and so do i.

he knows that comparing to him, i'm a computer guru, so when i showed him a script that i use to track down the hours, he said it's cool with him.

now, today we found out a little problem.

my pay is 22 shekels an hour. yes. low. i know. i tried looking for a better job, but the other options is currently cleaning cow rafts (i'm not Mike Rowe) and "guarding" the mall, basically, scanning people with the metal detector thing, which was horrible, and the pay is the same.

here's a function i call once a month to generate a nice little log.

Func EndOfLog($eol_g_info)
    Dim $eol_i_switch=1 ;used to deactivate while at line 30
    Dim $eol_i_linnum=1 ;counting lines for For at line 41
    dim $eol_i_pay ;calculation of total salary at line 45
    Dim $eol_i_th ;total hours read at line 28

    $eol_g_logfile=FileOpen($eol_g_info[5],1)
    $eol_g_finlogfile=FileOpen("Finished logs\"&@MON-1&"."&@YEAR&".txt",9)
    $eol_g_thlog=FileOpen("th.txt",0)

    $eol_i_th=FileReadLine($eol_g_thlog,1)

    While $eol_i_switch=1   ;counting the lines of the log
        $eol_s_readlog=FileReadLine($eol_g_logfile,$eol_i_linnum)
        If $eol_s_readlog="" Then
            $eol_i_switch=0
        Else
            $eol_i_linnum=$eol_i_linnum+1
        EndIf
    WEnd

    FileWrite($eol_g_finlogfile,"GFSCorp Working-hour log."&@CRLF&"Created at "&@MDAY&"."&@MON&"."&@YEAR&@CRLF&@CRLF)

    For $eol_i_curlinnum=1 to $eol_i_linnum
        $eol_s_readlog=FileReadline($eol_g_logfile,$eol_i_curlinnum)
        FileWrite($eol_g_finlogfile,$eol_s_readlog&@CRLF)
    Next
    $eol_i_pay=abs($eol_i_th*22) ;<---ISSUE HERE
    FileWrite($eol_g_finlogfile,"Total hours: "&$eol_i_th&@CRLF&"Expected pay: "&$eol_i_pay&@CRLF&@crlf&"Paid:__________/"&$eol_i_pay&" on ____.____.____"&@CRLF&"Paid:__________/"&$eol_i_pay&" on ____.____.____"&@CRLF&"Paid:__________/"&$eol_i_pay&" on ____.____.____"&@CRLF&"Paid:__________/"&$eol_i_pay&" on ____.____.____"&@CRLF)
EndFunc

the issue is at around the end, i marked it, and the problem is... it multiplies the number of hours by 21 instead of 22, so i end up redoing the last bit by hand. and while it sorta works, my program is not working the way it supposed to be.

i tried looking for the problem, and failed.

please give this a second look to see where exactly i messed up as i can't figure it out. i tried literally everything i can think of.

Link to comment
Share on other sites

Looking at your code I don't see anything that might directly explain the odd result you getting. But that not saying much as I generally use more debugging code than normal code when creating or testing code.

I do wonder about:

- seemingly missing Fileclose() calls.

- seemingly missing EOF checks. ($eol_g_thlog could return a empty string as last case -> number('') * 22 = 0)

- the data thats inside the files your feeding into this function.

---

And yes, ABS() use?

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

@shawn: $eol_i_th acts normally, displaying the hours properly. the problem is with the *22, apparently. i may be missing something out O_o

the abs()... well, i thought i'd try some shaman-work here XD

thought it might help. i was tired ._.

@MvGulik: ah crap, you're right about the fileclose(). i forgot about it totally.

my EOF check is expecting an empty string in the first loop, marked "counting the lines of the log", so when $eol_s_readlog recieves an empty string, it doesn't register it as an extra line, instead it turns the switch to 0. to start the next loop.

the data in the files goes like this

01.06.2010 S: 06:00 E: 14:00 TH:8

the second loop is out there just to copy the data and add a nice little... thing in the end for my boss to fill in and sign.

ABS() use - see my responce to shawn.

Link to comment
Share on other sites

maybe

"Dim $eol_i_th ;total hours read at line 28" ... line 28 ?

...

"$eol_g_thlog = FileOpen("th.txt", 0)"

...

"$eol_i_th = FileReadLine($eol_g_thlog, 1)" -> reading first line!

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Well give me some example output of what the last FileWrite outputs. I can't see why if you have 2 lines in a row with no code in between, and the 1st says A = B * 22 then the 2nd outputs A and B but A = B * 21 instead.

In my opinion either $eol_i_th is wrong when displayed in the last section, or $eol_i_pay really is multiplied by 22.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...