Jump to content
Sign in to follow this  
Patskie

Script Suggestion

Recommended Posts

Hello i just want to request if this is possible. Why not implement a script command wherein it will get all results from a query_sql command. For example if a script do a query_command like the following : 

query_sql "SELECT `name` FROM `char` WHERE `online` = '1'", .@name$;

From the query given above i must implement a for loop statement to go over with all the data. 

for( set .@a,0; .@a < getarraysize(.@name$); set .@a,.@a + 1)					mes "- " +.@name$[.@a];

My suggestions is this : 

 

1. Implement a script command like ResultSet in java or DataReader on C#?

 

so if this will happen. It would look like these when i use the query given above : ( i would give ResultSet as an example ) 

ResultSet rs = query.getResultSet(); //Get the result from the query_sql commandwhile (rs.next()) {	set .@names$ = rs.getString("name");	mes "Online Users : " +.@names$;} }

Or it may be :

ResultSet rs = query_sql("SELECT `name` FROM `char` WHERE `online` = '1'") // Direct Querywhile (rs.next()) {	set .@names$ = rs.getString("name");	mes "Online Users : " +.@names$;} }

 

While the statement has next line get those and when they are in the name column then print them. Well for me it will be quite easy to make scripts :D Anyway this is just a suggestion.

Edited by Patskie

Share this post


Link to post
Share on other sites

query_sql and loop is good for everyone i guess,

well anyways, in both the cases there is a loop, just difference is the format.

Share this post


Link to post
Share on other sites

query_sql and loop is good for everyone i guess,

well anyways, in both the cases there is a loop, just difference is the format.

But for a newbie scripter. It will be more easy to learn and remember this suggestion. But like you've said. Either will do a loop

Share this post


Link to post
Share on other sites

Well, it may be easier for newbies, but I'd still go for the loop. Reason is simple: there's lot of documentation already and almost any scripting guide (not script_commands.txt which is a reference but an actual guide) also shows how to loop through the result set. And well, I may not be used to Java structure, but your example makes me think classic loop can be easier too - no need of invoking any artificial method of advancing through the resultset.

Share this post


Link to post
Share on other sites

Being on others point of view .next() command is more readable than a for loop statement. I know there is an existing script for dealing over all the data which is for loop. But there is a saying that the more simpler and easier the code is, the better, as long as they provide the accurate result. Another thing i want to consider in this suggestion, Can anyone (developer) here create a script command wherein it will get the item script of an item and put it in npc script? This suggestion is like this post on rAthena. Well correct me if this command is already existing. Thanks :D

Share this post


Link to post
Share on other sites

Well the suggestion is good, bcoz it do not have array, that means no limit to 128.

I suggest to have both, the current one and the one that is suggested.

Edited by dastgirpojee

Share this post


Link to post
Share on other sites

Well the suggestion is good, bcoz it do not have array, that means no limit to 128.

I suggest to have both, the current one and the one that is suggested.

Exactly! Some scripts might have been limited to 128 because of array limit. But with these suggestion it will read all the data until the very end

Share this post


Link to post
Share on other sites

This syntax is completely different from our syntax... and since you can use LIMIT in MySQL it is simple to loop through more than 128 entries.

If we would create something like this we had to build a new variable typ which is exclusive because it would ignore the 128 entries limit. In my opinion this is too much effort for such little benefit.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.