• MPL division by 0

    From dream master@21:1/163 to All on Friday, August 25, 2017 02:13:07
    for some reason and on random people i see an error MPL divisi
    on by 0.it's coming from my file checker i called dm-
    rank. it takes the uploads anddownloads and creates a percen
    tage. i think i released it not sure but thisis what i have
    uses useruses cfgconstver = '2.1';
    var uploads : integer;downloads : integer;
    tmpup : integer;// temp upload value tmpdown : intege
    r;// temp download value stmpup : string;// MCI
    value stmpdwn : string;val1 : real;
    val2 : real;Function Score2Str(Sc:LongI
    nt):String;Var F,B : Integer;Var Score : LongInt;
    Begin Score:=(sc*100)/(tmpup*tmpdown)*100; F:=Score/100;
    B:=Score-(F*100); Score2Str:=Int2Str(F)+'.'+PadLt(Int2Str(B),2,
    '0');end // main programbegin
    getthisuser; stmpdwn := mci2str('DL')stmpup :=
    mci2str('FU');tmpup := str2int(stmpup); tmpdo
    wn := str2int(stmpdwn);val1 := str2int(stmpdwn) / str2int(stm
    pup) * 100;uploads := tmpup ;downloads := tm
    pdown; if downloads > uploads thenBegin/
    / if downloads are more then uploadswriteln('----
    -----<up/dl file rank v' + ver+'>----------------- -----------------------------------------------');write
    ln(' total downloads |DL total uploads |FU
    rank :[-----------------------'+
    real2str(val1,1)+'%-');end elseif downloads < uploads then
    // if downloads are less then uploads beginwrite
    ln(' total downloads |DL total uploads |FU
    rank :[ a bar goes here ]+ real2s
    tr(val1,1)+'%');end else if downloads = uploads then
    beginblah blah just pipe codes and ascii end
    endany ideas? it works for me and others but some people it do
    es not. .úùDream Mas
    terùú. øùúùøøù
    úùø DoRE!ACiDiC!D
    emonic[dreamland.darktech.org
    ]
    --- Mystic BBS v1.12 A35 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From g00r00@21:1/108 to dream master on Friday, August 25, 2017 12:32:44
    val1 := str2int(stmpdwn) / str2int(stmpup) * 100;

    You cannot divide by 0

    So if any of those values are 0 you will get that error. You aren't seeing
    it because your file stats aren't zero, but any new user would get that
    error.

    --- Mystic BBS v1.12 A35 (Windows/32)
    * Origin: Sector 7 [Mystic BBS WHQ] (21:1/108)
  • From dream master@21:1/163 to g00r00 on Friday, August 25, 2017 12:40:06
    On 08/25/17, g00r00 said the following...
    val1 := str2int(stmpdwn) / str2int(stmpup) * 100;
    You cannot divide by 0
    So if any of those values are 0 you will get that error. You aren't seeing it because your file stats aren't zero, but any new user would
    get that error.

    hmmm but they did some downloading and it stayed the same. should i add an if then statement to it to trap that and output something different?

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A35 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From dream master@21:1/163 to g00r00 on Friday, September 01, 2017 16:18:27
    On 08/25/17, g00r00 said the following...
    val1 := str2int(stmpdwn) / str2int(stmpup) * 100;
    You cannot divide by 0
    So if any of those values are 0 you will get that error. You aren't seeing it because your file stats aren't zero, but any new user would
    get that error.

    if they did a download it would still see the error because upload is 0. how can i get a true percentage if they download and not upload?

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A35 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From dream master@21:1/163 to g00r00 on Saturday, September 02, 2017 00:09:10
    On 08/25/17, g00r00 said the following...
    You cannot divide by 0
    So if any of those values are 0 you will get that error. You aren't seeing it because your file stats aren't zero, but any new user would
    get that error.

    how about this to work around it?

    getthisuser;
    stmpdwn := mci2str('DL')
    stmpup := mci2str('FU');
    tmpup := str2int(stmpup);
    tmpdown := str2int(stmpdwn);
    if str2int(stmpup) > 0 then
    begin
    val1 := str2int(stmpdwn) / str2int(stmpup) * 100;
    uploads := tmpup ;
    downloads := tmpdown; end

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A35 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)
  • From g00r00@21:1/108 to dream master on Saturday, September 02, 2017 11:07:30
    getthisuser;
    stmpdwn := mci2str('DL')
    stmpup := mci2str('FU');
    tmpup := str2int(stmpup);
    tmpdown := str2int(stmpdwn);
    if str2int(stmpup) > 0 then
    begin
    val1 := str2int(stmpdwn) / str2int(stmpup) * 100;
    uploads := tmpup ;
    downloads := tmpdown; end

    I am not sure what values you're looking to get in what variables but yes
    you are on the right track here. What values are you trying to calculate?

    --- Mystic BBS v1.12 A35 (Windows/32)
    * Origin: Sector 7 [Mystic BBS WHQ] (21:1/108)
  • From dream master@21:1/163 to g00r00 on Saturday, September 02, 2017 13:47:37
    On 09/02/17, g00r00 said the following...
    you are on the right track here. What values are you trying to
    calculate?

    a percentage of downloads of uploads. i sent another post to you saying i got it. it's working with that formula stmpup is uploads stmpdown are downloads
    of the user after using the mci2str so if they have one or more uploads it
    will do the math.

    |08 .|05ú|13ù|15Dr|07e|08am Ma|07st|15er|13ù|05ú|08.
    |08 øù|05ú|13ùø |13øù|05ú|08ùø
    |11 DoRE|03!|11ACiDiC|03!|11Demonic |08[|15dreamland|09.|15darktech|09.|15org|08]

    --- Mystic BBS v1.12 A35 (Windows/64)
    * Origin: |08--[|15!|07dreamland BBS dreamland.darktech.org (21:1/163)