|
-
Feb 24th, 2001, 09:36 AM
#1
Thread Starter
transcendental analytic
This code in a public classmodule:
Code:
Friend Static Function Useoffset&(Optional offset& = -1)
Static temp&
Useoffset = temp
If offset >= 0 Then temp = offset Else temp = 0
End Function
tell me where this could be usefull. If you guess correctly what i'm using it for (and note i can't find another better way to do than this) 10 points, find another usage for it 6 points and bonus 5 points if you find a better way to do it.
Note every single keyword has to have it's purpose.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 09:52 AM
#2
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 24th, 2001, 10:05 AM
#3
PowerPoster
No idea where you could use that...
Code:
Friend Static Function UseOffset&(Optional Offset& = -1)
Static Temp&
UseOffset = Temp
Temp = IIf(Offset < 0, 0, Offset)
End Function
-
Feb 24th, 2001, 10:32 AM
#4
Thread Starter
transcendental analytic
Nope, it's not part of kedapack 
Immediate if's are ugly, at least from what i've heard.
Why optional? As a hint, there's one usage which is done with two calls.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 11:14 AM
#5
Frenzied Member
Code:
Code:
Friend Static Function Useoffset&(Optional offset& = -1) 'declaring a freind static which means that the variables do not interfear with the rest of the code
Static temp& 'declaring a temporary value which will expire
Useoffset = temp 'the value 'USER OFF SET' is equal to the temporary vaue
If offset >= 0 Then 'if its greater thenor equal to 0 then
temp = offset ' temp is greater thenor qual to 0
Else temp = 0 ' if its under then-1 thenit is set to 0
End Function
I'm guessing thing would be useful in solving some sort of math equation.
Last edited by dimava; Feb 24th, 2001 at 11:19 AM.
NXSupport - Your one-stop source for computer help
-
Feb 24th, 2001, 01:42 PM
#6
Thread Starter
transcendental analytic
keep guessing :)
math equation? hahah ok keep guessing, if you get close i'll give point
Friend means procedure is only accessible inside project, Static Function mean its shared for all objects of that class, static declaration does not expire due to procedure scope, but isn't accessible as module scope either.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 01:48 PM
#7
Frenzied Member
here's another guess:
It does absolutly nothing
and is used to crash the computer
NXSupport - Your one-stop source for computer help
-
Feb 24th, 2001, 01:56 PM
#8
Thread Starter
transcendental analytic
eh, nope it's not contradicting itself
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 02:55 PM
#9
Addicted Member
I think
Temp is a Number holder that could be reset by Calling
the Function without a Parameter
-
Feb 24th, 2001, 03:06 PM
#10
Thread Starter
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 03:07 PM
#11
Monday Morning Lunatic
A wrappable, resettable counter?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 24th, 2001, 03:08 PM
#12
Frenzied Member
could this be used to validate numbers?
NXSupport - Your one-stop source for computer help
-
Feb 24th, 2001, 03:14 PM
#13
Thread Starter
transcendental analytic
I just have to give a point to parksie althought it's not it's ultimate purpose offset actually is a counter, and is being reset at times. But why all these specifics?
Note the calls are done in pairs.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 03:23 PM
#14
Frenzied Member
are you validating a serial number
NXSupport - Your one-stop source for computer help
-
Feb 24th, 2001, 03:38 PM
#15
Thread Starter
transcendental analytic
Nope, this code has one purpose, and parksie revealed some of it
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 24th, 2001, 03:41 PM
#16
Frenzied Member
making your own 'timer'?
counting items in arrays?
NXSupport - Your one-stop source for computer help
-
Feb 24th, 2001, 11:22 PM
#17
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Feb 24th, 2001, 11:38 PM
#18
Frenzied Member
Do you call it like this?
Code:
whatever = Useoffset(Useoffset + SomeValue)
Or
Code:
whatever = Useoffset(SomeOtherFunction(blah))
where SomeOtherFunction can call Useoffset?
Perhaps it's used to count the level of recursion in functions that call each other.
Harry.
"From one thing, know ten thousand things."
-
Feb 25th, 2001, 06:12 AM
#19
Thread Starter
transcendental analytic
dimava and harry: nope, another guess?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 25th, 2001, 06:38 AM
#20
Frenzied Member
is it always called in pairs? It could be used to retrieve a new offset and store the old offset, then later used to get the old offset back again, but it would need to be initialised first.
Perhaps the offset that gets passed in the second time it's called is incremented from the value returned by the first call.
Harry.
"From one thing, know ten thousand things."
-
Feb 25th, 2001, 06:45 AM
#21
Thread Starter
transcendental analytic
okok, Harry get's a point, but it's actually the other way round, you pass the value to retrieve it later, but since if you look it in another way, you could interpret it as returned and passed, and it actually is incremeanted between the calls. And also, yes this is used within a recursive procedure.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 25th, 2001, 05:14 PM
#22
Thread Starter
transcendental analytic
Honeybee get's 2 points for a very detailed analysis And yes, the parameter is passed the first time and not the second time, which is the purpose of optional in this case. There are several instancec of the class too.
Honeybee get's a third point for noticing i could replace
If offset >= 0 Then temp = offset Else temp = 0
by
If offset > 0 Then temp = offset Else temp = 0
cleaver but there's no actual performance gain since both comparations takes one cpu cycle.
As i've already said, it is called in pairs, and it's only used for this purpose, and it's called in combination with recursion (itself selfevidently is not recursive)
As a final hint, there's a keyword involved that should lead you to the 10 points.
Honeybee 3 points
Harry 1 point
Parksie 1 point
Active 1 point
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 25th, 2001, 05:42 PM
#23
Thread Starter
transcendental analytic
Gamerelated? honeybee you knew i was working on a game, and this actually has, but the snippet is part of a scripting editor and gamedata file compiler, so it's not about moving objects around the screen but allocating space for data
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 25th, 2001, 06:01 PM
#24
PowerPoster
My code is shorter ... Do I get a point now? 
Code:
Friend Static Function UseOffset&(Optional Offset& = -1)
Static Temp&
UseOffset = Temp
Temp = IIf(Offset < 0, 0, Offset)
End Function
'Code improved by vBulletin Tool (Save as...)
*hehe* okok, IIF is much slower BUT: my code is shorter *g
Last edited by Fox; Feb 25th, 2001 at 06:24 PM.
-
Feb 25th, 2001, 06:22 PM
#25
Thread Starter
transcendental analytic
Okay Fox, you get a point for testing and prooving Immediate if's are slower than you thought (that means slower than if statements). Actually it looks way shorter and cool, so you get the point for that, and it has cool vb-colors too, but no extra bonus points for that
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 25th, 2001, 06:25 PM
#26
PowerPoster
-
Feb 26th, 2001, 07:34 AM
#27
Thread Starter
transcendental analytic
Another very detailed report Okay i'll give you another point for that, but this time you you weren't as lucky as last time. The first time it's called, it doesn't handle the return value at all:
Useoffset offset
Negative value validation is of no importance either, It's only for avoiding the default value -1 since it's the first negative value i choosed it by default as default value. only 0 and positive values are passed to the function. Api calls are not involved either, except copymemory in the recursion. Okay for you and other's, there are still points to collect, even if you don't hit the 10 points, you can still beat Honeybee, with his 4 points
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 26th, 2001, 07:56 AM
#28
Hyperactive Member
Kedaman - you're keeping count of the number of objects created in a control array or the number of instances of an object and use the offset to determine if there are any left. Complete shot in the dark.
That's Mr Mullet to you, you mulletless wonder.
-
Feb 26th, 2001, 09:19 AM
#29
Thread Starter
transcendental analytic
Good guess, although no luck. I was considering give you the 6 points for another usage, but since you could simplify that by passing the offset to a counter instead it's no points, close though
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 26th, 2001, 09:34 AM
#30
Hyperactive Member
What about if I simplify things by saying that you don't need to declare the Temp var. as static because the whole function is static so it's value would be kept anyway. Just dim Temp& would do it. Must be worth a few points.
That's Mr Mullet to you, you mulletless wonder.
-
Feb 26th, 2001, 09:43 AM
#31
Hyperactive Member
Clues so far :
1. It's part of a class
2. It's not part of the public interface
3. It's holds a reference of some type
A reference to the object instance in which the code is running ? The friend bit allows other objects which include your class to reference the ID so it would become a kind of object handle ?
That's Mr Mullet to you, you mulletless wonder.
-
Feb 26th, 2001, 10:18 AM
#32
Thread Starter
transcendental analytic
3 points.
Yes, i knew, actually i discovered about Static modifier for the function was not a actual modifier, but declared all varialbes static automatically, but instead of mentioning it i waited for someone to notice it 1 point for that. The problem was solved easily, the recursion needs the reference object to be passed, so that you can call it from there. 2 points for hitting me right there. No the offset is not the handle, it's as said passed with the recursion, Friend is not used in that sense either. That was pretty close Paul, much is now revealed so anyone could easily get the 10 points now
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 26th, 2001, 10:28 AM
#33
Hyperactive Member
You're using it to create a call stack which you can collapse gracefully ? Useoffset is used to store the child process ID which is kicked off. Then if the object which created the child is terminated it can remove the child before closing neatly thus avoiding memory leaks ?
That's Mr Mullet to you, you mulletless wonder.
-
Feb 26th, 2001, 10:51 AM
#34
Thread Starter
transcendental analytic
Whoa, you have ideas. i'm not doing anything in that direction, but if you elaborate it a bit convicing me you could use it for this purpose, i'll give you the 6 points. All keywords have it's purpose, except the superfluous Static modifier
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 26th, 2001, 10:52 AM
#35
Hyperactive Member
Ok but it'll have to wait until tomorrow now. See you then.
That's Mr Mullet to you, you mulletless wonder.
-
Feb 26th, 2001, 08:48 PM
#36
Thread Starter
transcendental analytic
hmm not really honeybee, could you explain how you think it all fits together?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 26th, 2001, 10:37 PM
#37
Frenzied Member
To clean things up:
its used in a class module
if you call the function with no parameter you get 0
its stored to be used later
its a couter that can be reseted
does this have to do with the High Score part of the game?
guess 1:
somehow validating if the player did what they were supposed to, and if so, then they get a point, which would be stored, so when they get another point, the points would be added
guess 2:
stores the file name?
guess 3:
random number generator
I am positive it has to do with numbers
NXSupport - Your one-stop source for computer help
-
Feb 26th, 2001, 10:46 PM
#38
Frenzied Member
It's something to do with finding data in a file where the starting position to read from in the file is dependant on the length of the previous item of data in the file. So each time you read in a data structure you set the new offset for the next read.
Or
The offset is the length to read in when you don't know the length of the data coming in, and you get the length from a header of some description.
Closer?
Harry.
"From one thing, know ten thousand things."
-
Feb 27th, 2001, 03:21 AM
#39
Hyperactive Member
kedaman, it's obviously not a counter, you must be using it to store a value which a friend looks at and uses. Therefore it must provide that friend with a piece of information which relates to the object itself. It returns 0 if it has never been set but some number if it has.
Therefore the object (A) must put a value into offset so that object (B) can read it. The name offset might mean that it is some kind of memory pointer to something which A has created and B wants to access.
Is that worth any points ?
Going back to what I said yesterday you could use this routine to create a linked list of objects with Temp holding the name of the parent object. When the parent object is removed from the list then all children who have the parents name in Temp also get unloaded. You could create a tree structure with each node holding an object. Might be useful for mapping documents ( which contain many sub-documents ) or directory structures with each node a document or directory full of details and capable of running methods against those docs/dirs.
Just a thought.
That's Mr Mullet to you, you mulletless wonder.
-
Feb 27th, 2001, 07:50 AM
#40
Thread Starter
transcendental analytic
ok dimava, you get a point for most amount of guesses , but no more points for similar approach, yep it has to do with numbers, if you guess a couple of more times you maybe hit something..
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|