TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Function arguments

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Wed Aug 02, 2017 5:36 pm    Post subject: Function arguments Reply with quote

Hi, the functions seems to remember the arguments passed from a previous run, when you not provide them:

Code:

#function {rnd} {#math {result} {1 d (%2 - %1 + 1) + %1 - 1}}
#OK. FUNCTION {rnd} HAS BEEN SET TO {#math {result} {1 d (%2 - %1 + 1) + %1 - 1}}.
#show {@rnd{100}}
99
#show {@rnd{100}}
99
#show {@rnd{100}}
99
#show {@rnd{100;120}}    <-- Second parameter
110
#show {@rnd{100}}           <-- it remembers !!
116
#show {@rnd{100}}
103


Could be useful to have a way to check if a parameter was passed or not, so to use some default values... by now it's impossible, because them contains always the values from the last run.

Also the #HELP FUNCTION here should be corrected:
Code:

Example: #function {rnd} {#math {result} {1 d (%2 - %1 + 1) + %1 - 1}}
         #showme A random number between 100 and 200: @rnd{100 200}


missing semicolon
Code:

@rnd{100;200}
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Wed Aug 02, 2017 6:33 pm    Post subject: Reply with quote

Thanks, fixed the help file.

I'm not sure if I should fix this, it's not a real bug, more of a quirk, so it would just add more complexity without any real benefits.
Back to top
View user's profile Send private message Send e-mail
balthus



Joined: 07 Jul 2009
Posts: 39

PostPosted: Sun Nov 12, 2017 6:47 pm    Post subject: Reply with quote

In which case, how would I go about forcing the clearing of old arguments?

For example:

Code:

#FUNCTION {fFileGetPath}
{
  #UNVAR result;
  #REGEXP {%1} {{^\\*(.+\\)*}}
  {
    #VAR result {&2};
    #RETURN {$result};
  }
  {
    #RETURN {};
  };
};


Code:
#ECHO {@fFileGetPath{path\path2\file.ext}};
pathpath2


(the slashes are removed by echo, they are returned in a variable)

Code:
#ECHO {@fFileGetPath{file2.ext}};
pathpath2


The previous match is returned, which is completely wrong, rather than a blank.

Code:

#DEBUG FUNCTION {fFileGetPath}
[02] unvariable result
#OK. {result} IS NO LONGER A VARIABLE.
[15] regexp {file2.ext} {{^\\*(.+\\)*}}
[16] return path\path2\


The path\path2\ is reappearing from thin air because it has been retained by regexp.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Wed Nov 15, 2017 9:21 pm    Post subject: Reply with quote

Obviously you have to use the right number of arguments. Coffee

I'll see what I can do though. Smile
Back to top
View user's profile Send private message Send e-mail
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Thu Nov 16, 2017 7:24 am    Post subject: Reply with quote

Thumbs Up
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Bug Reports All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group