Solved

About linked variant record's tagfield in Turbo Pascal 7.0

Posted on 1998-02-14
5
279 Views
Last Modified: 2010-04-16
I got a strange problem in my turbo pascal program
 I declare something like that:

type
  TagField = (term, rowheader, columnheader, polyheader);
  ListPointer = ^ListNode;

  ListNode = record
    NextX : ListPointer;
    NextY : ListPointer;
    case NodeInfo : TagField of
      term:                      
            (Coefficient : integer);
      rowheader:
            (XDegree : integer);
      columnheader:
            (YDegree : integer);
      polyheader:
            (NoOfTerm : integer)
  end;

Then I have a var called
var
  OtherCoeff : ListPointer

and the code like this

   while ((OtherCoeff^.NodeInfo = rowheader) and
               (OtherCoeff^.NodeInfo = polyheader)) do  
                        :
                        :

Somehow this while loop goes into an infinite loop. I check the OtherCoeff
and I am sure it is pointing to the rowheader and not the polyheader
it still doesn't terminate.
it seems that it can't recognize the tagfield

Do you have any idea?
                       
0
Comment
Question by:UTEK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:bslim
ID: 1217325
Hmm in order to be of use...try to state the rest of the while statement....as something there is to stop the while loop....Hmm...but I'm not used to Turbo Pascal 7 the only Pascal i did was on a Unix computer...
0
 
LVL 2

Accepted Solution

by:
kellyjj earned 20 total points
ID: 1217326
With out seeing the rest of the code,  I can only guess that the problem is in the  variant record.   polyheader and rowheader are actually the same variable, but accessed differently.  I have used variant records to to converstions from integer to hex.  If it is real important that you check both polyheader and rowheader then I would make them seperate items in the record.
0
 

Author Comment

by:UTEK
ID: 1217327
Sorry, I have mis-type the while loop expression in my posting.
My original ctrl statement is:

while ((OtherCoeff^.NodeInfo <> rowheader) and
                  (OtherCoeff^.NodeInfo <> polyheader)) do
:
:

the truth table for that

<> rowheader             <>polyheader           do the loop
     T                         T                     T
     T                         F                     F
     F                         T                     F
     F                         F                     F

Since the loop will never go into the situation of (= rowheader) and (= polyheader), so the last line can be ignored.

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1217328
Are you modifying OtherCoeff^.NodeInfo inside the loop?
0
 
LVL 1

Expert Comment

by:santhosh022698
ID: 1217329
Without looking into the code i cannot answer. Try solving
this problem without using variant records, since variant records
are handled in a funnay manner in Pascal.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question