A start of a tutorial.
Displaying 21-38 of 38 total.
prev
1 2
Joewoof
|
Oh yea, and I'm looking forward to reading more of it. Keep up the good work! :D
Compared to Rysen's... um... less colorful work, this is a much more light-hearted read. :)
Posted on 2005-05-10 22:04:00
|
Omni
|
Er, notes.
1. [!] = negative/false/not. When used in conditional, returns TRUE if statement in brackets is FALSE.
'less than' really doesn't describe it at all.
2. && and || can be used in IF statements only. Not WHILE or anything else.
Though theoretically you could make your own function to compute different conditionals at once, ex:
void Checkvar(int var)
{
if (var == blah && var > blah)
return 1
else return 0
}
//back to code...
while (Checkvar(counter))
{
}
This would allow you to check for multiple conditionals with just a single function. Otherwise, WHILE only supports 1 conditional. IF supports any combination.
Posted on 2005-05-10 23:47:27
|
rpgking
|
'while' only supports 1 conditional? You sure about that? I just checked my code and found multiple conditionals in a 'while' which work perfectly. Like the following:
while(!b4 && !b1 && delay)
...
I don't see any reason why 'while' wouldn't support multiple conditional statements.
Posted on 2005-05-11 00:17:33
|
Joewoof
|
True to being a newbie. I'm going buh!? to those posts right now. T_T
Posted on 2005-05-11 06:10:01
|
Kildorf
|
As far as I know, and have experienced, while does support multiple conditionals... as long as (like if), they're not strung together with different operations. In other words, you can use all ANDs, or all ORs, but not a combination (which makes me sad).
More visually:
while(!b4 && !b1 && !done) // ok!
while(!b4 || !b1 || !done) // also ok!
while(!b4 || (!b1 && !done)) // no good, and Kildorf cries
Posted on 2005-05-11 06:41:07
|
Omni
|
I apologize. I have been under the impression for quite a while that While() indeed only supports one conditional.
Though, I must continue to announce the usefulness of a function evaluation method for your conditionals. It allows you to do such things as use conditionals in math and expressions.
int isEven(int value) { if (value%2 == 0) return 1; }
myset_color = color + (extracolor*isEven(timer));
//Only adds extracolor if timer is an even number.
//Yes, a weird effect, but demonstrates how the expressions could work.
As a side note I had to use something like this for the Scale2X algorithm in the utilities section.
I remember someone said that is was a shame that you couldn't evaluate conditionals in assignments and expressions, like
myflag = (4 > 3);
But using a function to return the conditional's value allows you to do just that.
myflag = isGreater(4, 3);
Anyway. It's pretty simple but I thought it was neat.
Posted on 2005-05-11 09:42:21 (last edited on 2005-05-11 09:43:33)
|
rpgking
|
I remember someone said that is was a shame that you couldn't evaluate conditionals in assignments and expressions, like
myflag = (4 > 3);
But using a function to return the conditional's value allows you to do just that.
myflag = isGreater(4, 3);
Anyway. It's pretty simple but I thought it was neat.
Yeah... Assigning a conditional's true/false value is the whole point of real boolean variables which languages like C++ have. In Verge, you have to fake booleans using ints, and thus you end up with redundant code like the following:
If(i > 3)
return true;
else
return false;
That's like saying 'If true, return true, else return false'...which is silly and redundant if you think about it :P
With real boolean variables you could do:
return (i > 3)
This doesn't make Verge inferior in any way though, since that's how Microsoft Win32 programmers do things with their ghetto TRUE/FALSE constants(called BOOLS) which are really just ints! :D
Posted on 2005-05-12 03:41:50
|
Gayo
|
Man, those trippy conditional statements are so annoying. The inability to handle || and && in one statement was one of those things that was supposed to get fixed ages ago but got left by the wayside when V3 development ground to a halt.
Posted on 2005-05-12 10:06:10
|
Omni
|
Using returned function values you could easily evaluate multiple ANDS and ORs in one statement.
Simple mathematics. If each of your conditional return functions, such as
int isCondition(int value) { if (condition) return 1; }
all return a numerical value, then you can easily implement ANDs and ORs at once.
1. ANDs. Multiply all conditional return values by each other. Thus if they all are 1 or >0, they will evaluate to true. A single false return will nullify the conditional.
2. ORs. Add all conditional return values. If they are at least >0, then one of them must be true.
Ex.
if (isOne(value)*isTwo(value))
{
stuff //Only does STUFF if isOne and isTwo are both true
}
if (isOne(value)+isTwo(value))
{
stuff //Only does STUFF if either isOne or isTwo are true
}
if (isOne(value)+(isTwo(value)*isThree(value))
{
stuff //Only does STUFF if A) isOne is true, and B) either isTwo or isThree are true
}
if ((isOne(value)*isTwo(value)) + (isThree(value)*isFour(value)))
{
stuff //Only does STUFF if (A) either isOne or isTwo is true, and (B) either isThree or isFour are true
}
Evaluating your conditionals to return values, whether in a function or in a variable, allow you do comparisons using math operations and parentheses, giving you control over logic grouping.
YES, I think it's definitely an effective workaround to do multiple conditionals. Plus it's neat and simple!
Posted on 2005-05-12 10:33:27 (last edited on 2005-05-12 10:34:28)
|
Gayo
|
WIDE THREAD, WIDE THREAD!
Posted on 2005-05-12 15:13:04 (last edited on 2005-05-12 15:17:54)
|
mcgrue
|
I wonder how hard it'd be to slap < pre>'s in 600-max-width frames with horizontal scrolls and a button above the area that lets you expand them all.
Posted on 2005-05-12 15:23:16
|
Omni
|
Sorry. Sometimes I forget everyone doesn't have 1680x1050...
Posted on 2005-05-12 16:23:05
|
mcgrue
|
Are we bragging? I have 3200x1200 at home. Soon as I get some free time, it'll be 4800x1200.
Posted on 2005-05-12 17:15:08
|
rpgking
|
all return a numerical value, then you can easily implement ANDs and ORs at once.
1. ANDs. Multiply all conditional return values by each other. Thus if they all are 1 or >0, they will evaluate to true. A single false return will nullify the conditional.
2. ORs. Add all conditional return values. If they are at least >0, then one of them must be true.
Heh, this is something I learned in undergrad that I really didn't have much interest in. But now I see how it can apply here, and it is an elegant solution to the ANDs and ORs at once problem. :)
I just got the coolest idea. Since verge allows you to #define practically anything from numerical constants to llamas, you could #define a GHETTO_AND as *, and a GHETTO_OR as +. You don't have to call it that, but you get the idea!
Then you could have code like:
#define GHETTO_AND *
#define GHETTO_OR +
if((A GHETTO_AND B) GHETTO_OR (C GHETTO_AND D))
DoSomethingGhetto();
How cool would that be to have so many Ghetto's in you code? :P
...Ok, I'm gonna go get some sleep that i've been neglecting now.
Posted on 2005-05-12 19:38:53 (last edited on 2005-05-12 19:45:52)
|
Overkill
|
Quote: Originally posted by mcgrue
I wonder how hard it'd be to slap < pre>'s in 600-max-width frames with horizontal scrolls and a button above the area that lets you expand them all.
<style>
pre
{
/* Blah Blah Blah background */
width: 600px;
overflow: auto;
}
</style>
I'm guessing to expand, you just make a hyperlink that triggers a javascript, this javascript toggling the overflow style property of the respective pre (probably can use 'this', since that way you don't need to id every single pre). Put a thing at the at top of each that says something like: 'Pre-formatted text <a_href_to_javascript>(Click to expand / contract)</a_href_to_javascript>'. In fact, maybe I'll try my hand at this thing and send a code for you to integrate, Grue.
Posted on 2005-05-12 20:09:09
|
Omni
|
Ghetto-fabulous code sounds very fabulous indeed. Also, if I was reading through page after page of source, any bit of refreshing humor you can get is a good thing.
Posted on 2005-05-12 22:20:57
|
mcgrue
|
Quote:Originally posted by overkill
Quote:Originally posted by mcgrue
I wonder how hard it'd be to slap < pre>'s in 600-max-width frames with horizontal scrolls and a button above the area that lets you expand them all.
(cut)
Does that work in boith IE and FF?
-Grue
Posted on 2005-05-13 00:16:16
|
Overkill
|
I've coded a solution to the pre stretching, and yes, now it works. The only extra thing you'd have to do besides the minimal Javascript and the few extra snippets of CSS is write some preg_replace() (or some sort of replace) action to add the URL that causes the expansion.
It was pain, with the stupid event target object models being different for each Javascript model, as well as parentNode and parentElement depending on browser.
http://ovk.actionsketch.com/stuff/verge3/pre.html
(Hey, maybe when you implement this, you could also implement link parsing)
Tell me when you're back from Texas, and I'll detail exactly how it works.
Posted on 2005-05-13 17:30:36
|