Solved

About linked variant record's tagfield in Turbo Pascal 7.0

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Client Data Set - Wide Memo 6 1,773
HTTP-POST Delphi 7 5 2,972
How to slide a FMX tabcontrol tabitem up from the bottom 3 1,138
indy Tmemory stream non latin charcter issue 2 121
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Is your phone running out of space to hold pictures?  This article will show you quick tips on how to solve this problem.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 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