Results 1 to 8 of 8

Thread: Problem with pascal program

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    166

    Problem with pascal program

    Hi 2 all,
    I have a problem with the attached program. Here is a sample input
    B=230000
    N=123
    1. (G.711)
    1. (10ms)
    1. (Ethernet)
    1. (DA)
    K=100
    TIME=1

    and ... the program hangs. I think the problem is the high value of B=, because if I input B=100 - the program finished normal, except with one (other) problem - the values of Dsr - they're too high. I translated this program from C to pascal. The compiled C exe is running normaly - I can't find the problem in pascal.

    Best regards!
    Attached Files Attached Files
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  2. #2
    Senior Member
    Join Date
    Oct 2001
    Posts
    748
    Wow.. That is really hard code to follow. Nevermind.. I see that you have a user variable that you are calling B, and then you have a variable in the program called B that is used as a counter.

    You take the user Input of what B is in the function inputlink as N. N is then assigned to M. Absolutely horrible variable names and pretty difficult to follow the code. Especially considering that you have a user input called B that has nothing to do with what B is in the program.

    I'd suggest you put some pauses in and tie it to a space bar press. This way you can step through the code in individual sections to find out where it is hanging.

    You also seem to switch back and forth from Real, longint, and int without any rhyme or reason that I can see. Why do you change the variable type so much?
    Last edited by mohaughn; February 22nd, 2007 at 04:49 PM.

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    The c code isn't mine. A friend gave it to me to translate it to pascal - i just followed the c code and wrote it in pascal. The program hangs when:
    "ProbabilityOfLoss:=calculation;" in the cycle and sometimes it shows 4-5 results, sometimes - 7-8 and hangs.
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  4. #4
    Senior Member
    Join Date
    Oct 2001
    Posts
    748
    OK.. So put some pauses in the function calculation and see where it is hanging. You can also write out the contents of the variables before you do the calculations to see if a value is exceeding the size limits of your variables.

    You have global variables and local variables all over the place and you switch back and forth for what appears to be no good reason.

    For instance, T1, you have it defined as a global variable. But you only use it in the function calculation. Why not just define it as a local variable to that function? "Tim" is another one, you only use it in the procedure test. And you have "F" defined twice. Once as a global text variable and again as a local real.

  5. #5
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    I trace and Step-over it, but all I found is that when I input high value for B the program hangs after some results and the CPU is on 100%. For high value I mean for example 100000. When I input 10000 - there is no problem.
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  6. #6
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    If your CPU is spiking to 100% either you have a very intensive algorithm or you have a run-away loop...

    What you'll have to do is go to each function, minimally, and have it output that that function is being called, and you may even have to periodically in the function, output that you are at a certain place...

    Do this enough and you will be able to see where in the algorithm it is getting hung up and that should hopefully provide some insight into what is going wrong...

    Sorry I tried looking at it, but its some kind of sloppy and I couldn't follow it very easily (and after some failed attempts to make it work in gcc, I decided to just post some generic debugging advice) ...

    I'm also assuming that this CPU spike doesn't occur for the same input in the C version?

    I'm suspecting that if it works for a small value but not a larger one, you either have an overflow situation (where the value is actually rolling over and causing a loop to not terminate, ie, because the value being returned is too large for the typecast) or you have an inefficient algorithm that doesn't scale to larger values very well...

    Hope that is at least somewhat helpful...
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  7. #7
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    Here are the exe-s.
    And yes, you are right - the c version is working well.
    Attached Files Attached Files
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  8. #8
    Custom User
    Join Date
    Oct 2001
    Posts
    503
    My god, that's more obfuscated than code from the OCCC.

    ac

Similar Threads

  1. The Problem Saga Continues
    By The Texan in forum Operating Systems
    Replies: 16
    Last Post: June 22nd, 2006, 08:04 PM
  2. Guide to making a program
    By FlamingRain in forum Other Tutorials Forum
    Replies: 1
    Last Post: December 25th, 2003, 05:34 AM
  3. How To: Crack a File
    By SpydaByte in forum AntiOnline's General Chit Chat
    Replies: 1
    Last Post: January 20th, 2003, 10:55 PM
  4. Basic Program Logic and good programming practices.
    By zepherin in forum Other Tutorials Forum
    Replies: 2
    Last Post: July 6th, 2002, 10:09 AM
  5. The Worlds Longest Thread!
    By Noble Hamlet in forum AntiOnline's General Chit Chat
    Replies: 1100
    Last Post: March 17th, 2002, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •