debug issue

This forum is for general support of Xbase++
Message
Author
BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

debug issue

#1 Post by BruceN »

I have a logical variable (public) that is somehow changing value when it shouldn't. I have a break point at every place the variable can change value (thru VX20 2.0.338). I still can't tell when its changing. Thre's a
watch list' in VX, but I cant get variables into it.. and the variable view (view, debug window, variables) is always blank also. Under tools, debugger options I have all variabletypes clicked to show, but my Variable screen is different from thati n the help file (mine doesn't have the 'manipulation' section on it).

How can I get the variable values to display in the degug window to track their values? How can I get one or 2 into the watch window?

I tried using Roger's WTF... but that only shows the value AT THAT POINT. Is there a method in Express of watching the value as it chnges when I step thru the code?

as always.. thanks
There are only 10 kinds of people - those who understand binary and those who don't :)

User avatar
Tom
Posts: 1204
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: debug issue

#2 Post by Tom »

Hi, Bruce.

Move all accesses/assignments to the var(s) to a get/set-function which sets the value or returns it. Place your debug code there (use DC_CallStack). Do you work with XPF-files and "RESTORE FROM" / "SAVE TO"? Maybe you restore the value there.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
rdonnay
Site Admin
Posts: 4772
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: debug issue

#3 Post by rdonnay »

Tom -

That's what I was going to suggest, but I didn't know how many publics would be affected by this.

I'm working on updating a client application, written by another programmer, in which he used a large public array and accessed each value through a function named Publics(). At first, this was cumbersome code to look at but I find that it is much easier to debug because every public is Get or Set through this function.

I tend to use very few publics in my apps, so I don't usually need something like this, but it's a good programming idea.

Roger
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: debug issue

#4 Post by Auge_Ohr »

this "Technique" is used by "Summer 93"*** to get rid of PUBLIC Variabel.
(*** there was realy a Product with this Name )

Code: Select all

FUNCTION SP_Duration(nValue)
   IF PCOUNT() > 0
      nDuration := nValue
   ENDIF
RETURN (nDuration)
you can put all Function into one PRG and use #xtranslate with a "big" Array

Code: Select all

#xtranslate nDuration     => Stack\[SP, 1]
...
#xtranslate cHelloWorld   => Stack\[SP, 100]

STATIC Stack := {}
STATIC SP    := 0

FUNCTION _STACKINIT()
   AADD(Stack,ARRAY(100))
   SP ++
RETURN (SP)

FUNCTION _STACKEXIT(nThread)
LOCAL iMax

   ADEL(Stack,nThread)
   DO WHILE .T.
      iMax := LEN(Stack)
      IF iMax = 0
         EXIT
      ELSEIF Stack[iMax] = NIL
         ASIZE(Stack,LEN(Stack) - 1)
      ELSE
         EXIT
      ENDIF
   ENDDO
   SP := LEN(Stack)

RETURN (SP)
you can use same "Technique in a Class ( STATIC -> Class VAR ) when have multiple MDI-Client Windows , each have its own "Stack".
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4772
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: debug issue

#5 Post by rdonnay »

Jimmy -

I have used that technique many times in the past too, but it doesn't solve the problem of triggering a debug event when writing to the variable.

Roger
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: debug issue

#6 Post by Auge_Ohr »

hi,

Code: Select all

   nDuration := 100
   FindExpression ( {|| nDuration = 0} )

FUNCTION FindExpression (bBlock)
   oThread := Thread():new()
   oThread:start("Sp_StopHere",bBlock)
   oThread:setInterval(100)
RETURN

FUNCTION Sp_StopHere(bBlock)
  IF EVAL(bBlock)
     ? PROCENAME(2)
     ? PROCLINE(2)
     WAIT 
  ENDIF
RETURN
greetings by OHR
Jimmy

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: debug issue

#7 Post by BruceN »

thanks guys.. question: what's the problem with public variables?
There are only 10 kinds of people - those who understand binary and those who don't :)

User avatar
Tom
Posts: 1204
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: debug issue

#8 Post by Tom »

what's the problem with public variables?
Advantages:
1. PUBLICs are visible everywhere, even in different threads.
2. PUBLICs can be initialized in a function, they get visible "above".
3. PUBLICs can be stored to/restored from a XPF-file (as PRIVATEs).
4. PUBLICs can be changed everywhere, changed values are visible instantly - everywhere.

Disadvantages:
Same as above. ;)
If you run the same code in two threads and change a public var in one, it's changed for the other thread aswell. This may happen just in the midth of code which started with a different value of the var. Imagine a var switching an option. Now code runs for this option while this option is changed. Your app may crash. The results of the code may be wrong. Or, or, or.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: debug issue

#9 Post by Auge_Ohr »

BruceN wrote:question: what's the problem with public variables?
i do not think Xbase++ have "spezial" Problem with it. ( see what Tom say )

Cl*pper DGROUP is limited to 64Kb ( not MB ) which PUBLIC use, so when you Application growe you might got into Trouble with DGROUP.
greetings by OHR
Jimmy

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: debug issue

#10 Post by Cliff Wiernik »

I utilize a small number of public variables to house configuration parameters that are loaded at program startup and not changed by programs. It was due to the visability desire as the program was created originally in summer87 this way. I could use a get/set function also for the same purpose but never went fully that way.

So I don't have problems with things being inadvertently changed.

Post Reply