Bugs on StringField (PB 5.40 LTS) (solved) --> my mistake

Just starting out? Need help? Post your questions and find answers here.
steelx7000
New User
New User
Posts: 4
Joined: Wed Jan 20, 2016 4:10 pm

Bugs on StringField (PB 5.40 LTS) (solved) --> my mistake

Post by steelx7000 »

I don't know can this consider as bug or not, but my code at 'hasilBaris' variable don't refresh in the next loop. Is the problem with the StringField ?
At addGadgetItem(barisFile) is okay in reading a List, but not for the result from StringField
My problem is that the value in ListIcon_0 from the first row to end of row is always same

Compiler: PureBasic 5.40 LTS
OS: Windows 7(32bit)
Computer: Lenovo G405s

Code: Select all

Procedure ListBaris_ke_ListIconValue(no_halaman.i)
  Define.i no_awal, no_akhir
  
  no_awal = ( ( no_halaman * 200 ) - 200 ) + 1
  no_akhir = ( no_awal + 200 ) - 1
  
  For hitBaris = no_awal To no_akhir
    SelectElement(ListBaris(), hitBaris)
    Define.s BarisFile, hasilBaris
    Define.i CountKoma
    
    BarisFile = ListBaris()
    CountKoma = CountString(BarisFile, ",")
    
    ;Something wrong at the result from this code
    For koma = 1 To CountKoma + 1
      ;;kode
      Define.s hasilKoma = StringField(BarisFile, koma, ",")
      hasilBaris + hasilKoma 
      If Not koma = (CountKoma + 1)
        hasilBaris + Chr(10)
      EndIf
      
    Next
    
    ;......................
    ;End here (the strange result in hasilBaris)
    
    
    
    ;AddGadgetItem(ListIcon_0, hitBaris, BarisFile + Chr(10) + Str(hitBaris)) ;This is ok
    AddGadgetItem(ListIcon_0, hitBaris, hasilBaris) ;This not ok
    
  Next
  
    
    
EndProcedure
Last edited by steelx7000 on Thu Jan 21, 2016 2:44 pm, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 7699
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Bugs on StringField (PB 5.40 LTS)

Post by infratec »

Hi,

please provide a small working program which shows the error.
Only than I can investigate it.

Bernd
infratec
Always Here
Always Here
Posts: 7699
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Bugs on StringField (PB 5.40 LTS)

Post by infratec »

Hi,

wrote it on my own.

You simply not clear the variable hasilBaris in the outer loop.
So it grows the whole time.

Code: Select all

    hasilBaris = ""
    For koma = 1 To CountKoma + 1
resolves your bug.

If not, see my post before.

Bernd
steelx7000
New User
New User
Posts: 4
Joined: Wed Jan 20, 2016 4:10 pm

Re: Bugs on StringField (PB 5.40 LTS)

Post by steelx7000 »

infratec wrote:Hi,

wrote it on my own.

You simply not clear the variable hasilBaris in the outer loop.
So it grows the whole time.

Code: Select all

    hasilBaris = ""
    For koma = 1 To CountKoma + 1
resolves your bug.

If not, see my post before.

Bernd
Thank you. Your code working.... just because hasilBaris = ""
Yesterday i thought that PB like any other programming language, define will automatic reset the value for me....
infratec
Always Here
Always Here
Posts: 7699
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Bugs on StringField (PB 5.40 LTS) (solved) --> my mistak

Post by infratec »

Hi,

I don't know any programming language which resets a variable during a normal program loop.
This would it make impossible to write any kind of (working) program :wink:
Post Reply