Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic Misc > Re: QBASIC colo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1377 of 1466
Post > Topic >>

Re: QBASIC color numbers

by david.williams@[EMAIL PROTECTED] (David Williams) Nov 13, 2007 at 09:52 AM

-> > If Twiddle changes the value of its input parameter, the value of X in

-> > the calling routine will *not* be changed. 
-> >    
-> > But how easy is it to do the other way around? If the language is set

-> > up to call by value, can we write simple code that effectively calls
by 
-> > reference? I can't think of an easy way to do it. 
-> >    
-> > Of course, the language may have specific commands to switch from one

-> > method of calling to the other, but without them, a dialect that
calls 
-> > by value can't easily be made to call by reference. 
 
-> Passing a pointer using VARPTR should work, shouldn't it? 
  
Hmmm... Maybe. I'd have to think about that. 
  
What I'm concerned about is the ability to pass numbers back from a SUB 
to the calling routine. For example, in the program SUNALIGN, which I 
posted here a couple of days ago, some three-dimensional trigonometry is 
done by using two methods of representing a direction in space - e.g. 
the direction of the sun in the sky, as seen by an observer on the 
ground. One method is to state the azimuth (compass bearing) and angle 
of elevation. The other is to state the X, Y, Z co-ordinates of the 
endpoint of a unit vector pointing to the sun, with the observer at the 
origin. A lot of 3D trig can be done very easily by switching to and 
fro between these methods, with small operations on the arguments along 
the way. To do this, the program has two SUBs, D2P and P2D. Each has 
five arguments, X, Y, Z, AZ, and EL. D2P takes X, Y, and Z as inputs, 
calculates AZ and EL and passes them back to the calling routine. P2D 
does the conversion in the opposite direction. So, basically, each SUB 
puts values into the variables in its parameter list that it uses as 
outputs, and expects the calling routine to be able to receive them and 
use them in later calculations. 
  
Could this be done with VARPTR? Certainly, not as easily. 
  
                       dow




 2 Posts in Topic:
Re: QBASIC color numbers
david.williams@[EMAIL PRO  2007-11-13 09:52:47 
Re: QBASIC color numbers
winston19842005 <bjjly  2007-11-13 10:53:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 13:04:07 CDT 2008.