Recent

Author Topic: [Solved] Help with changing an app  (Read 3372 times)

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
[Solved] Help with changing an app
« on: January 12, 2020, 12:05:05 pm »
With the help of HowardPC we created a small reading app to read a certain page from a website (https://www.nijb.nl/nijbsheet.php?GameID=57788).
Howard used a different page as an example where no Penalty Shot (PEN-S) was given.

When I now have a games sheet where a PEN-S is given I get an error. (See picture)
I have traced it back to this part of the code
Module: uUtils.pp lines 308-312
Code: Pascal  [Select][+][-]
  1.     function HasMin(const ss: String; out p: Integer): Boolean; inline;
  2.     begin
  3.       p := Pos(' min ', ss);
  4.       Result := p > 0;
  5.     end;


How can I change it to that the result for this function is '50' (Thats the minutes I use for a Penalty Shot (PEN-S).
Code: Pascal  [Select][+][-]
  1.     function GetMinValueStr(const ss: String; spacePos: Integer): String; inline;
  2.     var
  3.       p: Integer;
  4.     begin
  5.       p := Pred(spacePos);
  6.       Result := '';
  7.       repeat
  8.         if ss[p] in ['0'..'9'] then   // ss can contain '.', ':' ...
  9.           Result := ss[p] + Result;
  10.         Dec(p);
  11.       until (p < 1) or (ss[p] = ' ');
  12.       while (Result[1] = '0') do     // remove leading zero(s)
  13.         Delete(Result, 1, 1);
  14.       Assert(TryStrToInt(Result, p),'Error in parsing minute value "'+Result+'"');
  15.       if p > 99 then                 // 2.00 if present will now be 200
  16.         begin
  17.           p := p div 100;
  18.           WriteStr(Result, p);
  19.         end;
  20.     end;
« Last Edit: January 20, 2020, 01:57:34 am by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

bytebites

  • Hero Member
  • *****
  • Posts: 632
Re: Help with changing an app
« Reply #1 on: January 12, 2020, 01:03:38 pm »
Code: Pascal  [Select][+][-]
  1. function GetMinValueStr(const ss: String; spacePos: Integer): String;
  2. begin
  3.   result:='50'
  4. end;

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #2 on: January 12, 2020, 01:23:44 pm »
Haha.


Nope not the solution I am looking for.
Because it also has to do the other part too.
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

bytebites

  • Hero Member
  • *****
  • Posts: 632
Re: Help with changing an app
« Reply #3 on: January 12, 2020, 01:34:12 pm »
What is input??

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #4 on: January 12, 2020, 02:05:33 pm »
See the zip-file....
it's a working example
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #5 on: January 14, 2020, 03:40:47 pm »
Does anyone have a good suggestion?

You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Help with changing an app
« Reply #6 on: January 14, 2020, 04:06:55 pm »
What are you trying to do- change this

Code: [Select]
        function HasMin(const ss: String; out p: Integer): Boolean; inline;
        begin
          p := Pos(' min ', ss);
          Result := p > 0;
        end;

into something like this?

Code: [Select]
        function HasMin(const ss: String; out p: Integer): integer;
        begin
          p := Pos(' min ', ss);
          if p > 0 then
            result := 50
          else
            result := 0
        end;

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #7 on: January 14, 2020, 09:26:49 pm »
What I am trying to do is explain in these threads:
https://forum.lazarus.freepascal.org/index.php/topic,44814.0.html
https://forum.lazarus.freepascal.org/index.php/topic,44769.msg315047.html#msg315047


In short. I am trying to read the game sheet of hockey games
and separate the different penalty times (which works) and penalty shots (which does not work) in a game sheet
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Help with changing an app
« Reply #8 on: January 14, 2020, 11:33:17 pm »
madref: I'm refactoring the code supplied earlier and making changes to parse correctly now I understand better all the variations/possibilities in the data.
It is complicated by inconsistencies in the formatting of the online data, and my lack of understanding of Dutch.

I'm almost there, but busy the next day or two. Hope to have something working for you soon.

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #9 on: January 15, 2020, 07:01:35 am »
@HowardPC
I am very patient :)
I am already working on it form April 2019
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Help with changing an app
« Reply #10 on: January 17, 2020, 02:27:28 pm »
madref, try the attached project.
Whether it works on a Mac I don't know, but it's giving me consistent results on Linux.
Obviously you'll have to adapt it to your needs. I've used a global variable, ParsedRec as the main data container which gets updated when you change web page. This is for testing, really. You might prefer a procedure that passes a parameter rather than using a global variable.

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #11 on: January 17, 2020, 09:51:23 pm »
Thank Howard !!


This works on a clean install of lazarus trunc with fps 3.2.x and 3.3.1
But is does not work with fpc 3.0.4


When I am trying to run my integrated app it keeps crashing (see attachment)
Is it possible to make it for fpc 3.0.4?
Because the unit opensslsockets is only known from fps 3.2.x and higher
« Last Edit: January 17, 2020, 09:54:26 pm by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #12 on: January 17, 2020, 09:59:46 pm »
Seems I don't need the unit opensslsockets
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Help with changing an app
« Reply #13 on: January 17, 2020, 10:30:57 pm »
Requirements for Mac development always seem to be a bit different!  Sorry I can't help you with that.
But I should have said I developed it using FPC 3.3.1
Maybe you can remove other units apart from opensslsockets if such things are already provided somehow by the Mac "walled garden".

Glad to hear you got it working.  However, that does not mean it is bug-free!
« Last Edit: January 17, 2020, 10:35:48 pm by howardpc »

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Help with changing an app
« Reply #14 on: January 19, 2020, 12:26:36 am »
Small question HowardPC.


In the example I provided the penalties where in minutes per period (Penalty Sore).
In your example it is the amount of penalties given per period.


How can I change that back?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

 

TinyPortal © 2005-2018