Here I have a sub that restocks mage reagents from a secure (albeit home or bank) and drops them in the characters backpack.  It first checks to see what mage regs are in the pack and how many of them there are.  Then check against a known list of mage regs and jots them down for retrieval.  Next a few string operations deduce what regs and how many are needed, then the find, drag and drop operations commence.  All is well, until .... the number of reagents is less than ten. The string operations fudge themselves up and all is lost.  So what I'm looking for is, how can I fix the single digit issue without rewriting most of the sub.  I'm aware that it isn't atm picking up the regs that aren't there at all, that'll be soon after I hurdle this.  On to the sub, Warning, not the pretties coding, but just quick and functional, here it is:
gosub Reg_restock_check #backpackid
display ok Location: Backpack$
+Regs found:$
+ %regsfound $
+regs needing stock:$
+ %restockreg $
+regs missing:$
+ %regsmissing $
goSub SS_Stock_Resources
sub Reg_restock_check
  event macro 8 7
  set %maxregsneeded 50
  set %regs _KUF_KZF_JUF_MZF_JZF_WZF_RZF_SZF
  set %regsmissing
  set %regsfound
  set %restockreg
  finditem %regs C_ , %1
  if #findcnt > 0
  {
    set %restockreg
    set %regsfound
    set #findindex 0
    for #findindex 1 #findcnt
    {
      set %regtype #findtype
      set %regamount #findstack
      if %regamount < %maxregsneeded
      {
        set %regsneeded %maxregsneeded - %regamount
        set %restockreg %restockreg , %regtype , #spc , %regsneeded , #spc $
      }
      set %regsfound %regsfound , %regtype , #spc , %regamount , $
    }
  }
  if #findcnt < 8
  {
regs_missing_loop:
    str pos %regs _
    if #strres = 0
      goto regs_missing_end
    set %length #strres - 1
    str left %regs %length
    set %value #strres
    if %value notin %regsfound
      set %regsmissing %regsmissing , #spc , %value
    set %area %length + 1
    str del %regs 1 %area
    set %regs #strres
    goto regs_missing_loop
regs_missing_end:
  }
return
;------------------------------
Sub SS_Stock_Resources
  set %homesecure ; Fill in the blank here for your testing
  if %restockreg <> N/A
  {
    set #strres %restockreg
    set %tempstring #strres
reg_stock_loop:
    str pos %tempstring #spc
    if #strres = 0
      goto reg_stock_end
    set %templength %tempstring + 6
    str left %tempstring %templength
    set %stockregtypeamt #strres
    set %cut %templength + 1
    str del %tempstring 1 %cut
    set %tempstring #strres
    ;--------------------- reg amt nibble -----------
    set #strres %stockregtypeamt
    str pos %stockregtypeamt #spc
    set %finallength %stockregtypeamt + 2
    str right %stockregtypeamt %finallength
    set %finalregamt #strres
    ;--------------------- end reg amt nibble
    ;------------------- reg type nibble --------------
    set #strres %stockregtypeamt
    str pos %stockregtypeamt #spc
    set %finallength %stockregtypeamt + 3
    str left %stockregtypeamt %finallength
    set %finalregtype #strres
    ;----------------------end reg type nibble
    finditem %finalregtype C_ , %homesecure
    set %reg #findid
    exevent drag %reg %finalregamt
    wait 15
    exevent dropc %1
    wait 15
    ignoreitem %reg
    set %tempcut %templength + 1
    str del %restockreg 1 %tempcut
    set %restockreg %tempstring
    goto reg_stock_loop
reg_stock_end:
  }
stopSomething else while I'm at it, why does this part work without the gump?
finditem %finalregtype C_ , %homesecure
    set %reg #findid
    exevent drag %reg %finalregamt
    wait 15
I imagine later down the road it may become problematic and it does work atm, but why?  I kinda don't like that it does, but it does? 
