?
Solved

About linked variant record's tagfield in Turbo Pascal 7.0

Posted on 1998-02-14
5
Medium Priority
?
284 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 60 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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