Var troubles...

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

YKW-28983
a hill giant
a hill giant
Posts: 252
Joined: Sun Dec 01, 2002 11:37 pm

Var troubles...

Post by YKW-28983 » Sun Jul 06, 2003 12:18 am

Code: Select all

#define me1info "1000"
#define me2info "2000"
#define me3info "3000"

#define me4 v1
#define me5 v2

Sub Main
 /varset me4 $p0
 /varset me5 $me4info
/return
Keep in mind this is false code im just using this so I don't have to show what i'm working on...

The basic idea is you run the macro like /macro name me#
And then I want the me#'s info so I try and do $me4info $me4 is me1-3 whichever the macro is ran at. but it doesn't work i've tried doing $abs($me4)info but no luck @ all... Can I get some light on this?

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Re: Var troubles...

Post by wassup » Sun Jul 06, 2003 12:46 am

OK, I'm scratching my head.

No idea whatsoever what you are trying to express.

I can tell you this though, you need to go look at how #define works.

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Sun Jul 06, 2003 3:25 am

The answer is 42.

But I still don't know the question.

GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Sun Jul 06, 2003 4:20 am

Wassup, it seems that you can define integers directly, at least that is what Jay is doing in his [url=http://macroquest2.com/phpBB2/viewtopic ... 4702#14702]rogue macro[url], and it works quite good.

YKW, I have no clue as to what your code is supposed to do, but I think I know what you want it to do..

Code: Select all

|** name.mac
Syntax: /macro name me#
**|
#define infome1 v0
#define infome2 v1
#define infome3 v2

Sub Main
   /varset infome1 1000
   /varset infome2 2000
   /varset infome3 3000
   /if "$p0"=="" {
      /echo Syntax: /macro name me#
      /endmacro
   }
   /echo $info$p0
/return
if you have a dynamic variablename, you have to call it either with 2 variables like:
$var1$var2
Or if it's a string and a variable the string have to come first like:
mystring$var

Reason is that the interpreter seems takes evertyhink from where it encounters a $ to the next $ or a space (probably also other things).
Ie if you make it like:
/varset var 1
$varinfo
Then the interpreter would look var a variable called "varinfo" and not a variable called "1info".

In PHP I know it is done like:
$myvar = "_1";
${$myvar."string"} = "Lala";
echo $_1string;
(If I remember correctly)

Dunno if this was what you were seeking, cause it sounded kinda like gibberish what you were asking :p
Heh, I'm sure this sounds like gibberish too, 25 hours going now, need sleep ;)

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sun Jul 06, 2003 4:31 am

My mistake there, I learn something new every day.

However, even with direct defines I am still confused as to what he wants to do.

YKW-28983
a hill giant
a hill giant
Posts: 252
Joined: Sun Dec 01, 2002 11:37 pm

Post by YKW-28983 » Sun Jul 06, 2003 12:10 pm

Just wanted it to get a string from when the macro was started this being either me1 me2 or me3. set up the vars to whatever me was selected and the info for that me#.

YKW-28983
a hill giant
a hill giant
Posts: 252
Joined: Sun Dec 01, 2002 11:37 pm

Post by YKW-28983 » Sun Jul 06, 2003 12:11 pm

But don't worry I went about it doing /if statements.

compuboy
a ghoul
a ghoul
Posts: 108
Joined: Thu Apr 24, 2003 8:19 am
Location: Good Question, if anyone finds out, let me know

Post by compuboy » Sun Jul 06, 2003 12:36 pm

well if you use #define, you cant change what it is, with #define x y, the parser goes through and changes all of the x's to y's, therefore, you are defeating the purpose of a variable, by making them invariable.

did that make any sence?