Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Idea: Dry Run Program

Author
Message
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jul 2007 20:56
Has anyone made a "dry run" program for DBC, I had the idea when I was going through my program in Notepad.
something like this:



becomes


I found this method really useful and to make a program would be awesome.

I am King of the noobs!
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Jul 2007 04:53
Are you talking about a trace that lists the values of the variables based on the loop iteration and/or the program counter?

Enjoy your day.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Jul 2007 06:07 Edited at: 30th Jul 2007 06:09
Yeah, well it would run through the program showing what is happening to all the variables etc.
I'm not really sure how the program counter works, but it would show what line the program's on (is that what the program counter does?)
Could you make this in DB?

I am King of the noobs!
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Jul 2007 09:01
Well,

the program line counter is displayed in a file named Db.dba in the dark basic main directory. It is only updated when you have tracemode = 1 in the setup.ini file also in the main directory. This file will display every line in order of the dbc script you most recently ran numbering from 1 up. It will even show empty lines.

As far as the variable values, since DBC doesn't have access to memory pointers, it's kinda hard to get that info unless you reassign the values of your variables to other variables or just write them every so often to a file.

I was thinking, a function could be created that maybe takes 12 parameters: 2 integers and the 2 names of the variables
2 floats and the 2 names of the variables
2 strings and the 2 names of the variables

Maybe also a program line parameter (to keep track of where you will run the trace from in the program)

Inside the function, the names and values are written as strings to a file along with the program line. You would place the function in areas of the program where you want to check the values of the variables. Later, you can review the file to see what the values of the variables were.

As far as tying it to the Db.dba file, I'd have to think about it a little bit.

Enjoy your day.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Jul 2007 21:12
What annoys me is there doesn't seem to be anyway of grabbing a variable's name.

I am King of the noobs!
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 30th Jul 2007 23:10
Quote: "doesn't seem to be anyway of grabbing a variable's name"


The user would most likely have to type it in somewhere.

I decided to write a trace program based on what I suggested earlier. It works - logs the variables to a file. I think I will try to expand it to make it real time instead of just logging the variables in a file. This is an example of the draft version output. The variables obj and test repeat because they are nested for next loop controllers. The other variables are displayed to show that they aren't changing during the loop:



I'll probably post the source once I add a real time display.

Enjoy your day.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Jul 2007 02:28
Cool, nice one latch

I am King of the noobs!
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Aug 2007 19:48 Edited at: 2nd Aug 2007 19:51
This is the sort of thing you could sell if it works well
I tried doing the tracemode = 1.

here's what I got using DBEdit


Here's what I got with the same program in the built-in editor


Does it have to be in the built-in editor? I can't see anything that would recognise this as my program.

Your signature has been erased by a mod because it was rubbish.

Login to post a reply

Server time is: 2026-07-05 22:39:12
Your offset time is: 2026-07-05 22:39:12