Solved

About linked variant record's tagfield in Turbo Pascal 7.0

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Facebook has became the #1 social media platform. People share many funny videos there, yet you don't know how to download them? Now you can download Videos from Facebook in just 3 simple steps.
Original post  on Monitis Blog. Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 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