Solved

About linked variant record's tagfield in Turbo Pascal 7.0

Posted on 1998-02-14
5
249 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now