 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Mon Feb 27, 2012 8:24 pm
script eating strings |
i have an alias that probes mysql DB and returns information
| Code: |
#wait 0
#VARIABLE interconn %comcreate( "ADODB.Connection")
#CALL @interconn.open("mobvuln")
#IF (@interconn.ConnectionString ="") {
#SHOW "could not open connection to database"
#ABORT
}
#VARIABLE interrs @interconn.Execute("SELECT * FROM mobs WHERE mob_short_name LIKE '%"%1"%' ORDER BY id ASC")
#SAY @white("Showing file for:") @cyan(%proper( %1))
#SAY @white("----------------------------------------------------------------")
#IF (not @interrs.BOF or not @interrs.EOF) {
#CALL @interrs.MoveFirst
#WHILE (not @interrs.eof) {
$format = %concat("ID : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(@interrs("id")))),"room num : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("id"),@interrs("roomnum"))
$format = %concat("Mob Name : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(@interrs("mob_short_name")))),"Area : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("mob_short_name"),@interrs("area"))
$format = %concat("Mob Base Level :",@white("["),"&s",@white("]"),%repeat(" ",(25 - %len(@interrs("mob_base_level")))),"Identical Mobs :",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("mob_base_level"),@interrs("identical_mobs"))
#print @interrs("mob_base_level")
#CALL @interrs.MoveNext
}
} {
#PRINT %repeat(" ",20)%ansi( white)No Matches%ansi( default)
}
#CALL @interrs.Close
#CALL @interconn.Close
interconn = ""
interrs = "" |
it seems to me that for some reason the second to last print, the mob level is being eaten its not showing up but the last print shows it prefectly here is an example
| Code: |
ID : [27] room num : [30684]
Mob Name : [Lizardman child] Area : [verume]
Mob Base Level :[] Identical Mobs :[4]
36
|
i cant figure out why its not showing in the spot its susposta show in though=/ any thoughts |
|
_________________ if you build it they will come, assuming that they have not already come to build it
Aardwolf Bootcamp
My youtube channel
Last edited by hadar on Mon Feb 27, 2012 10:55 pm; edited 1 time in total |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Feb 27, 2012 9:19 pm |
Odd. Nothing obvious jumps out at me. I note that this is the only &s which is not enclosed in one of your color functions, but I don't see why that should make a difference. Out of curiosity, what happens if you put that &s in a color function? Does it work then?
|
|
|
|
 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Mon Feb 27, 2012 9:33 pm |
no i took it out to make sure it was not the color function that seemed to be screwing with this, futher testing, adding another format line it seems the first field in there is also blank
| Code: |
----------------------------------------------------------------
ID : [28] room num : [30681]
Mob Name : [Lizardman Chief] Area : [verume]
Mob Level : [] Identical : [1]
40
Guild : [] Subclass : [Ninja]
---------------------------------------------------------------- |
i added the next line hoping that it would fix the first one and it did not, im sure the coding is 100% im just not sure at what is eating the items now because the guild should be a word
Edit:
here is the updated code
| Code: |
#wait 0
#VARIABLE interconn %comcreate( "ADODB.Connection")
#CALL @interconn.open("mobvuln")
#IF (@interconn.ConnectionString ="") {
#SHOW "could not open connection to database"
#ABORT
}
#VARIABLE interrs @interconn.Execute("SELECT * FROM mobs WHERE mob_short_name LIKE '%"%1"%' ORDER BY id ASC")
#SAY @white("Showing file for:") @cyan(%proper( %1))
#SAY @white("----------------------------------------------------------------")
#IF (not @interrs.BOF or not @interrs.EOF) {
#CALL @interrs.MoveFirst
#WHILE (not @interrs.eof) {
$format = %concat("ID : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(@interrs("id")))),"room num : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("id"),@interrs("roomnum"))
$format = %concat("Mob Name : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(@interrs("mob_short_name")))),"Area : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("mob_short_name"),@interrs("area"))
$format = %concat("Mob Level : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(@interrs("mob_base_level")))),"Identical : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("mob_base_level"),@interrs("identical_mobs"))
#print @interrs("mob_base_level")
$format = %concat("Guild : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(@interrs("guild")))),"Subclass : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("guild"),@interrs("subclass"))
#print @interrs("guild")
#print @white("----------------------------------------------------------------")
#CALL @interrs.MoveNext
}
} {
#PRINT %repeat(" ",20)%ansi( white)No Matches%ansi( default)
}
#CALL @interrs.Close
#CALL @interconn.Close
interconn = ""
interrs = ""
|
|
|
|
|
 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Mon Feb 27, 2012 11:38 pm |
i dont know if this is related but another of my scripts just broke it uses the same formatting script as above and it seems that the %repeat line breaks it, exmple
works
| Code: |
$format=%concat(@gray("|"),@white("("),@red(%repeat(" ",(4 - %len(@interrs("id"))))"&s"),@white(")")," Name",@white("("),@red(%repeat(" ",(30 - %len(@interrs("mob_short_name"))))"&s"),@white(")")," level",@white("("),@red("&s"),@white(")")," Room:",@red("&s")@gray("|"))
#print %format($format,@interrs("id"),@interrs("mob_short_name"),@interrs("mob_base_level"),@interrs("roomnum")) |
works
| Code: |
$format=%concat(@gray("|"),@white("("),@red(%repeat(" ",(4 - %len(@interrs("id"))))"&s"),@white(")")," Name",@white("("),@red(%repeat(" ",(30 - %len(@interrs("mob_short_name"))))"&s"),@white(")")," level",@white("("),@red(%repeat(" ",(3 - %len(@interrs("id"))))"&s"),@white(")")," Room:",@red("&s")@gray("|"))
#print %format($format,@interrs("id"),@interrs("mob_short_name"),@interrs("mob_base_level"),@interrs("roomnum")) |
does not work
| Code: |
$format=%concat(@gray("|"),@white("("),@red(%repeat(" ",(4 - %len(@interrs("id"))))"&s"),@white(")")," Name",@white("("),@red(%repeat(" ",(30 - %len(@interrs("mob_short_name"))))"&s"),@white(")")," level",@white("("),@red(%repeat(" ",(3 - %len(@interrs("mob_base_level"))))"&s"),@white(")")," Room:",@red("&s")@gray("|"))
#print %format($format,@interrs("id"),@interrs("mob_short_name"),@interrs("mob_base_level"),@interrs("roomnum")) |
|
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Feb 28, 2012 12:05 am |
Oh, wait. Is mob_base_level an integer? If so, the %len won't work right. That might be causing problems. Try replacing %len(@interrs("mob_base_level")) with %string(%len(@interrs("mob_base_level")))
|
|
|
|
 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Tue Feb 28, 2012 12:30 am |
does nothing to help the script it seems like while %repeat(" ",(30 - %len(@interrs("mob_base_level")))) is correct it breaks everything else, i even tried changing the name of the value in mysql table and nothing, so i blame the above script lol
|
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Feb 28, 2012 2:02 pm |
Ack...I messed up. I meant to say: change %len(@interrs("mob_base_level")) into %len(%string(@interrs("mob_base_level")))
|
|
|
|
 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Wed Feb 29, 2012 2:41 am |
its not just that something is breaking the format completely because i just did this
does not work
| Code: |
$format = %concat("Mob Level : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(%string(@interrs("mob_base_level"))))),"Identical : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("mob_base_level"),@interrs("identical_mobs")) |
worked
| Code: |
$format = %concat("Mob Level : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(%string(@interrs("mob_base_level"))))),"Identical : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("identical_mobs"),@interrs("mob_base_level")) |
did not work
| Code: |
$format = %concat("Mob Level : ",@white("["),@red("&s"),@white("]"),%repeat(" ",(25 - %len(%string(@interrs("identical_mobs"))))),"Identical : ",@white("["),@red("&s"),@white("]"))
#print %format($format,@interrs("identical_mobs"),@interrs("mob_base_level")) |
so it looks like something wonky is going on with the %format function unless something else is throwing it off |
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4777 Location: Pensacola, FL, USA
|
Posted: Wed Feb 29, 2012 3:33 am |
Your $format variable is not a valid formatting string as far as I can tell.
And if you are going to format it... why are you padding your string with %repeat? You can use a negative number to left justify.
Try something like...
$mob=@interrs("identical_mobs"
$level=@interrs("mob_base_level")
#PRINT {%concat("Level: ", @white("["), @red(%format("&3.0d", $level)), @white("]"), "Identicle: ", @white("["), @red(%format("&-25s", $mob)), @white("]"))} |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Wed Feb 29, 2012 4:43 am |
i use the repeat to keep things in alignment, so when there is only like 3 chars in a mobname it will make 22 spaces to keep the alignment of the thing on the same line after it
|
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4777 Location: Pensacola, FL, USA
|
Posted: Wed Feb 29, 2012 5:00 am |
"&25s" or "&-25s" is what you want as the %format string for that particular block, depending on how you want it justified.
there is no need to use %repeat (in this manner) when using %format, both accomplish the same thing: nice neat tidy columns and rows |
|
_________________ Discord: Shalimarwildcat |
|
|
 |
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Wed Feb 29, 2012 5:53 am |
using &-25s i end up getting
which i do not want i want
|
|
|
|
 |
shalimar GURU

Joined: 04 Aug 2002 Posts: 4777 Location: Pensacola, FL, USA
|
Posted: Wed Feb 29, 2012 11:27 am |
we were talking about the mob name not the ID at the time, but either way.... you get the idea, play around with it
|
|
_________________ Discord: Shalimarwildcat |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Feb 29, 2012 2:04 pm |
Format invalid...oh, duh! <smacks head>
Your format is using &s in the place you want to put the mob level, but the mob level is an integer. Use &d instead. |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Feb 29, 2012 9:47 pm |
Actually, %format() is going to count color codes towards the specified width, and if you exceed that number as a result of the combined length of visible text and color codes then any of the internal padding from the format string is ignored:
#print %format("There are &10s mobs here.",%e"[1;32mfifteen"%e"[0m")
What the above prints is (since the code tags don't allow other tags inside, you'll have to imagine the word "fifteen" as blue)
| Code: |
| There are fifteen mobs here. |
when you might expect it to print
| Code: |
| There are fifteen mobs here. |
This issue applies to any type of formatting code contained in the values portions of the %format() function--mxp, ansi, xml/mxp, etc.
That said, you can get around this limitation by removing the width specifier and adding another &s for your padding:
#print %format("name: &s&s level: &d",@colorizedmobname,%repeat(" ",(name column width - %len(%stripansi(@colorizedmobname)),@moblevel) |
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
nateygable Newbie
Joined: 02 Mar 2012 Posts: 1
|
Posted: Fri Mar 02, 2012 12:44 am |
Thanks for the codes.
|
|
|
|
 |
|
|
|
|
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
|
|