Author Topic: Strings Drive my Crazy  (Read 2943 times)

0 Members and 1 Guest are viewing this topic.

Offline KhameleonTopic starter

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Strings Drive my Crazy
« on: March 04, 2009, 06:39:47 PM »
0
I think I might have an Idea how to tackle this, but I'm hoping you guys have a better way to do this.


I'm trying to pick apart a string, mainly the price on an Item on a vendor.
what I'm thinking is to split the string up from $, then search for the word Price: and take everything from the right side of that?
is there a simpler form? I can't seem to figure it out :)

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Strings Drive my Crazy
« Reply #1 on: March 04, 2009, 07:15:26 PM »
0
I think I might have an Idea how to tackle this, but I'm hoping you guys have a better way to do this.


I'm trying to pick apart a string, mainly the price on an Item on a vendor.
what I'm thinking is to split the string up from $, then search for the word Price: and take everything from the right side of that?
is there a simpler form? I can't seem to figure it out :)

Here's a couple routines I have that takes a string that's delimited by anything (in this example, it's delimited by "$") and splits it into substrings that can be addressed.

Code: [Select]
event property XXYYZZ
gosub TM_SplitString #PROPERTY $
gosub TM_GetIndex 1 ; 2nd line of text
if #RESULT = Blessed
  display This item is blessed!
stop

sub TM_SplitString
  namespace push
  namespace local PS
  namespace clear
  set !string %1
  set !delimiter %2
  set !cnt 0
  str pos !string !delimiter
  repeat
    if #STRRES = 0
      break
    set !temp #STRRES - 1
    str left !string !temp
    set !array . !cnt #STRRES
    set !cnt !cnt + 1
    set !temp !temp + 1
    str del !string 1 !temp
    set !string #STRRES
    str pos !string !delimiter
  until #STRRES = 0
  set #RESULT !cnt
  namespace pop
return #RESULT

sub TM_GetIndex
  namespace push
  namespace local PS
  set !index %1
  set #RESULT !array . !index
  namespace pop
return #RESULT

For your requirements, you'll want to find "price" on the 3rd line (or index 2).  Just delete the "Price:_" and you'll have the price.
« Last Edit: March 04, 2009, 07:18:07 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KhameleonTopic starter

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Strings Drive my Crazy
« Reply #2 on: March 06, 2009, 05:05:42 AM »
0
Thanks TM, we got that part ironed out.

I'm not sure if I understand this next part correctly.
I've saved a list of Items from a vendor into a listbox, now I would like to save those items to a file to be accessed later.

Code: [Select]
Sub Save
gosub TM_FileSystem_CreateFileHandle NULL Save_VendorInventoryList
  namespace push
  namespace local TM_window_list_InventoryList

for %i 0 !list_ptr
    {
    gosub TM_FileSystem_SaveVariable NULL local std Save_VendorInventoryList list , %i
    }
gosub TM_FileSystem_SaveFile Save_VendorInventoryList c:\ , #CharName , InventoryList , .txt
namespace pop
Return

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Strings Drive my Crazy
« Reply #3 on: March 06, 2009, 07:37:42 AM »
0
Hmm, why aren't you using TM_SaveListToFile?  v1.22(of the list handler) has a method to save/load list items... ;)  No need to do it by hand.  However if you DO want to do it by hand, you can just take a look at both of those subs to see how it's done.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Strings Drive my Crazy
« Reply #4 on: March 06, 2009, 07:52:57 AM »
0
I like string cheese  :D
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Strings Drive my Crazy
« Reply #5 on: March 06, 2009, 08:14:11 AM »
0
I like string cheese  :D

Ohhh, man string cheese!!  That's good eats!
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KhameleonTopic starter

  • Script Tester - Team Leader
  • Elite
  • *
  • *
  • Posts: 2574
  • Activity:
    0%
  • Reputation Power: 30
  • Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!Khameleon is a rising star!
  • Gender: Male
  • Respect: +238
  • Referrals: 0
    • View Profile
Re: Strings Drive my Crazy
« Reply #6 on: March 06, 2009, 09:55:48 AM »
0
man, TM, I totaly forgot there was a listhandler saver. *Slaps Forehead*


I like Melted String Cheese.

Tags: