It is currently Sat Apr 29, 2017 10:28 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Check if debug.on
Unread postPosted: Thu Mar 16, 2017 8:24 pm 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 68
Location: France
Is it some better way than mine to detect, from inside a user-defined function, if the current instruction is within the scope of a debug.on command? I would have no code out of the checking function.

My current way to do that is:
Fn.def isDebugOn()
Console.line.count count1
Debug.print "Checking debug"
Console.line.count count2
Fn.rtn count2>count1
Fn.end

_________________
Alain


Last edited by Sprougnaf on Wed Mar 22, 2017 4:24 am, edited 1 time in total.

Report this post
Top
 Profile  
 
 Post subject: Re: Check if debug.on
Unread postPosted: Sat Mar 18, 2017 5:22 pm 
Offline

Joined: Sat Dec 22, 2012 2:32 pm
Posts: 805
Simple solution could be, to store the debug on/off status into a variable each time you change it.
When changing it in userfunctions, you could use a well known workaround for the fact, that BASIC! doesn't have "classic" global variables, see below.
The little trick here is, that if you create a list at a defined point of a program, you always know it's reference(=list-pointer) and so you can refer to it from inside a function w/o hand-over this reference every time (here the mentioned list is created at the very beginning and therefore has the reference "1")

regards, brochi


Code:

LIST.CREATE    n, globals
LIST.ADD       1, dummyGlob1, dummyGlob2, statDebug, dummyGlob4


FN.DEF        debugOn()
DEBUG.ON   : LIST.REPLACE  1, 3, 1
FN.END

FN.DEF        debugOff()
DEBUG.OFF  : LIST.REPLACE  1, 3, 0
FN.END


FN.DEF        isDebugOn()
LIST.GET      1,3, statDebug
FN.RTN        statDebug
FN.END

FN.DEF        switchDebugRandomly()
IF            RND()>0.5 THEN debugOn() ELSE debugOff()
FN.END


!main --------------
DO
ctr++
CALL          switchDebugRandomly()
PRINT  INT$(ctr); "  statDebug= "; INT$(isDebugOn())
PAUSE         100
UNTIL          forever

END



Report this post
Top
 Profile  
 
 Post subject: Re: Check if debug.on
Unread postPosted: Tue Mar 28, 2017 10:05 am 
Offline

Joined: Sat Feb 11, 2017 1:40 am
Posts: 68
Location: France
What I want is not to have anything coded outside the isDebugOn function.

_________________
Alain


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred