Previous Thread
Next Thread
Print Thread
Rate Thread
#101390 10/03/2000 5:51 PM
Joined: Aug 2000
Posts: 12
Member
Member
Offline
Joined: Aug 2000
Posts: 12
Is there a way to make to variables, and when they are defined, they can be used in a formula.

EX: I'm running an RPG UBB. I want to take the user's post count and rank (if I make their rank definable in the profile screen via drop-down list) and want to use the formula:
Code
code:
(where $HitP is Hit Points (I want to make a variable for that) $Posts is there post count (DUH) and $HitPRank is the value for the rank they chose.

So if my total posts equaled 2 and the rank I chose had a HitPoint value of 3, the formula would be (with the numbers plugged in)
Code
code:
My hit points would be 34 (I'd like it to round off, if possible.

Is math like this doable in PERL, and if so, what are the commands. Thanks for listening to my ramble and I hope for good answers.

Sponsored Links
#101391 10/03/2000 7:12 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
If over means devided by, then here is your answer:

Code
code:

I believe...probably something wrong -- always is >:0)

------------------
Da Wannabe Cannuck

#101392 10/03/2000 7:27 PM
Joined: Aug 2000
Posts: 12
Member
Member
Offline
Joined: Aug 2000
Posts: 12
Thanks a lot. Can you just give me a list of all the symbols for math functions? I really need these and it would be greatly be appreciated.

#101393 10/03/2000 7:32 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
He wants rounding, so:

$HitP = sprintf("%.0f", $Posts * 50 / $HitPRank);

parenthesis are not needed on the math since it's just multiplication and division, both which have the same precedence.

--mark


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#101394 10/03/2000 7:46 PM
Joined: Aug 2000
Posts: 12
Member
Member
Offline
Joined: Aug 2000
Posts: 12
This was just a random formula, not the one I was gonna use. I just want the fomula and symbols to use.

Sponsored Links
#101395 10/05/2000 9:00 AM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
Here's documentation of the Perl operators:
http://www.perldoc.com/perl5.6/pod/perlop.html

#101396 10/05/2000 3:37 PM
Joined: Aug 2000
Posts: 12
Member
Member
Offline
Joined: Aug 2000
Posts: 12
I am so MUCH more confused than I was before. Thanks anyway though.

#101397 10/05/2000 5:52 PM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
I'm working my way through Programming Perl (having already read Learning Perl and CGI Programming with Perl).

I thought C++ was complicated, but after finishing the chapter on regular expressions, my reaction was Are these guys nuts? [Linked Image]

#101398 10/05/2000 8:59 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
Quote
quote:
Of course, but I always find it simpler to read when using paren's...



------------------
Da Wannabe Cannuck


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)