Probs Clear Gadgetlist

Just starting out? Need help? Post your questions and find answers here.
STU-ASI
User
User
Posts: 24
Joined: Thu Dec 08, 2005 10:56 am

Probs Clear Gadgetlist

Post by STU-ASI »

I have created 3 gadgetlists which all work ok.

Problem is that when i use the cleargadgetlist() function
The list is not clearing on the window.

Am i missing something ?


Code reads....

Code: Select all

ClearGadgetItemList(#List1)
ClearGadgetItemList(#List2)
ClearGadgetItemList(#List3)

t$=""
SetGadgetText(#text1,t$)
SetGadgetText(#text2,t$)
SetGadgetText(#text3,t$)
even the setgadgettext not working in this
Last edited by STU-ASI on Tue Mar 21, 2006 11:38 am, edited 1 time in total.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

It's hard to tell what your problem is if you don't post any code to explain it but as an idea, are you talking about a GadgetList (A list of gadgets on a window which you cannot clear in this fashion) or a ListIconGadget?

if it's a ListIconGadget, you type in

ClearGadgetItemList(#TheNameOfMyListIconGadgetToClear)

#TheNameOfMyListIconGadgetToClear = the constant name of your own gadget.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
STU-ASI
User
User
Posts: 24
Joined: Thu Dec 08, 2005 10:56 am

Post by STU-ASI »

Yeah sorry forgot to include the code first...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Probs Clear Gadgetlist

Post by PB »

> Am i missing something ??

Yes, some example runnable code that demonstrates the problem. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
STU-ASI
User
User
Posts: 24
Joined: Thu Dec 08, 2005 10:56 am

Post by STU-ASI »

ok full procedure reads as follows...

Code: Select all

Procedure cleardata()
t$=" "
gameno=0

Dim ver$(0)
Dim cats$(0)
Dim ver$(#vermax)
Dim cats$(#catmax)
Dim RomInfo.game(0)
Dim rominfo.game(#max)

ClearGadgetItemList(#XMLlist)
ClearGadgetItemList(#CatList)
ClearGadgetItemList(#VerList)
ClearGadgetItemList(#SUB_romlist)
ClearGadgetItemList(#SUB_catlist)
ClearGadgetItemList(#SUB_verlist)

SetGadgetText(#Cat_ID,t$)
SetGadgetText(#Cat_Mame,t$)
SetGadgetText(#Cat_Date,t$)
SetGadgetText(#Mame_Ver,t$)
SetGadgetText(#Mame_Date,t$)
SetGadgetText(#Cat_Count,t$)
SetGadgetText(#Vers_Count,t$)
SetGadgetText(#Rom_Count,t$)

EndProcedure

Code clears the text gadgets but does not update the window.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

You still haven't quite got the hang of actually posting useful code to debug but not to worry, we will teach you (EVIL GRIN).

You have only posted a procedure that illustrates some variables, not a block of code that illustrates what you are doing and what gadgets you are referencing and trust me, this will not help us figure out the [problem.

Please post a usable block of code (window, event handling etc) that you are doing so we can see where the error is.

I don't mean to upset you but that procedure tells us nothing i'm afraid.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Fangs, you're mellowing! :)
@}--`--,-- A rose by any other name ..
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

What shoult SetGadgetText do within a listicon gadget? What is the expected behaviour of this command?
Tranquil
STU-ASI
User
User
Posts: 24
Joined: Thu Dec 08, 2005 10:56 am

Post by STU-ASI »

Ok here is the complete program but there are 800+ lines of code in there

Code: Select all

;
; --------------------------------
;   Parse XML List & Catver.ini
;   
;
; 
; --------------------------
;

IncludeFile "Common.pb"

Structure game
  romname.s
  cloneof.s
  driver.s
  year.s
  maker.s
  width.w
  height.w
  aspectx.w
  aspecty.w
  cat.s
  ver.s
EndStructure

; Max Number Of Games
#max = 10000
; Game Index Number
#GameNo = 0

; Cat & Ver Index Number & Max Entry
#Cat = 0
#CatMax = 200
#Ver = 0
#VerMax = 1000

Global Dim RomInfo.game(#max)
Global Dim Cats$(#CatMax)
Global Dim Ver$(#VerMax)
Global Dim tag$(10)

tag$(1)="<mame build="
tag$(2)="<game name"
tag$(3)="<year>"
tag$(4)="<manufacturer>"
tag$(5)="<video"
tag$(6)="</game>"

;File ID
;File 0 = ListXML File
;File 1 = 
;File 2 = 
; 
#file0=0
#file1=1
#file2=2

mameinfo$=""

cats$(0)=""
ver$(0)=""
;rominfo(0)=""

Global file0,file1,file2,gameno,max,cat,catmax,ver,vermax
Global mameinfo

Procedure.s FileFind(search$,file)
  ;read file until either EOF or search$ is found
  text$=""
  found=0
  search$=LCase(search$)
  tag=0
  For x=1 To 10
    If search$=tag$(x)
      tag=x+1
      x=11
    EndIf
  Next x
 
  While Eof(file)=0 And found=0
        text$=LCase( ReadString(file) )
        found=FindString(text$,search$,1)
        If tag>0 And FindString(text$,tag$(tag),1)
          ProcedureReturn "ENDTAG"
        EndIf
  Wend
  ProcedureReturn text$
EndProcedure

Procedure extract_gameinfo(*info.game)

    line$="" : result = 0
    line$=filefind("<game name=",#file0)
    If line$="" Or line$="ENDTAG"
        ProcedureReturn result
    EndIf
    result=Loc(#file0)
    
; Extract Rom Name
;
    s=FindString(line$,"game name=",1)
    If s<>0
      s=s+11
      z=FindString(line$,Chr(34),s+1)
      *info\romname=Mid(line$,s,z-s)
    EndIf
    
; Extract Clone Info
;
    s=FindString(line$,"cloneof=",1)
    If s<>0
      s=s+9
      z=FindString(line$,Chr(34),s+1)
      *Info\cloneof=Mid(line$,s,z-s)
    EndIf
    
; Extract Driver Name
;
    s=FindString(line$,"sourcefile=",1)
    If s<>0
      s=s+12
      z=FindString(line$,Chr(34),s+1)
      *info\driver=Mid(line$,s,z-s)
    EndIf
    
; Extract Year
;
    line$=filefind("<year>",#file0)
    If line$<>"ENDTAG"
      s=FindString(line$,"<year>",1)
      e=FindString(line$,"</year>",1)
      If s<>0
        s=s+6
        ; e=FindString(line$,Chr(34),s+1)
        *info\year=Mid(line$,s,e-s)
      EndIf
    Else
      FileSeek(#file0,result-1)
    EndIf
      
; Extract Manufacturer
;
    line$=filefind("<manufacturer>",#file0)
    If line$<>"ENDTAG"
      s=FindString(line$,"<manufacturer>",1)
      e=FindString(line$,"</manufacturer>",1)
      If s<>0
        s=s+14
        *info\maker=Mid(line$,s,e-s)
      EndIf
    Else
      FileSeek(#file0,result-1)
    EndIf
    
; Extract Video Info
;
    line$=filefind("<video",#file0)
    If line$<>"ENDTAG" 
  ; Extract Width 
      s=FindString(line$,"width=",1)
      If s<>0
        s=s+7
        e=FindString(line$,Chr(34),s)
        *info\width=Val(Mid(line$,s,e-s))
      EndIf
    
; Extract Height
      s=FindString(line$,"height=",1)
      If s<>0
        s=s+8
        e=FindString(line$,Chr(34),s)
        *info\height=Val(Mid(line$,s,e-s))
      EndIf
    
; Extract Aspect X
      s=FindString(line$,"aspectx=",1)
      If s<>0
        s=s+9
        e=FindString(line$,Chr(34),s)
        *info\aspectx=Val(Mid(line$,s,e-s))
      EndIf
    
; Extract Aspect Y
      s=FindString(line$,"aspecty=",1)
      If s<>0
        s=s+9
        e=FindString(line$,Chr(34),s)
        *info\aspecty=Val(Mid(line$,s,e-s))
      EndIf
    EndIf
    gameno=gameno+1
  ProcedureReturn result    
EndProcedure

Procedure extract_Mame_vers()
    t$="" : result = 0
    t$=filefind("<mame build=",#file0)
    If t$="" 
        MessageRequester("XML File Error","Cant Find Mame Info in the file"+Chr(13)+"Please Check file is valid mame xml file")
    Else
      s=FindString(t$,"mame build=",1)
      s=s+12
      e=FindString(t$," (",s)
      ver$=Mid(t$,s,e-s)
      ;SetGadgetText(#Mame_ver,ver$)
      ; Date
      s=e+2
      e=FindString(t$,")",s)
      date$=Mid(t$,s,e-s)
      ;SetGadgetText(#Mame_Date,date$)
    EndIf

EndProcedure

Procedure parse_xml(file$)
  If ReadFile(#file0,file$)
    extract_Mame_vers()
    
    pg=Lof(#file0)/100
    gameno=0
    While Eof(#file0)=0
      ;gameno=gameno+1
      result = extract_gameinfo(@RomInfo(gameno)) 
      If result<>0
        pgpos=Loc(#file0)/pg 
        SetGadgetState(#progressbar_0,pgpos)
      EndIf
    Wend
    CloseFile(#file0)
    SetGadgetState(#progressbar_0,0) 
    gameno=gameno-2
    SetGadgetText(#Rom_Count,Str(gameno))  
  Else
    MessageRequester("XML Parse", "Error: Can't read the file", 0)
  EndIf

EndProcedure

Procedure FindRom(rom$)
c=0
exit=0
Repeat 
  If rom$=Rominfo(c)\romname
    exit=1
  Else
    c=c+1
  EndIf
Until exit=1 Or c>#max Or rominfo(c)\romname=""
If exit=0 
  c=0
EndIf
ProcedureReturn c

EndProcedure

Procedure IDString()
  ; Search For Initial ID String
  text$=filefind(";;",#file1)
  If text$=""
      t$=""
      t$=t$+"You require the original catver.ini file"+Chr(13)
      t$=t$+"for this program to work with."+Chr(13)
      MessageRequester("ERROR",t$)
    ProcedureReturn
  Else
    text$=LCase(text$)
    ; Catver ID
    ; Skip initial ";; "
     s=FindString(text$,";;",1)+3
     e=FindString(text$,"/",s)
     id$=Mid(text$,s,e-s)
     SetGadgetText(#Cat_ID,id$)
    ; Date
     s=FindString(text$,"/",1)+2
     e=FindString(text$,"/",s)
     date$=Mid(text$,s,e-s)
     SetGadgetText(#Cat_Date,date$)
    ; Mame ID
     s=FindString(text$,"mame ",1)
     e=FindString(text$,"/",s)
     mame$=Mid(text$,s,e-s)
     SetGadgetText(#Cat_Mame,mame$)
   EndIf
EndProcedure

Procedure extract_catinfo(text$)
  ; Split String Into RomName + Category
  ; 
  s=1
  m=FindString(text$,"=",1)
  e=Len(text$)-m
  rom$=Trim(Mid(text$,s,m-1))
  cat$=Trim(Mid(text$,m+1,e))
  c=Findrom(rom$)
  If c<>0
    RomInfo(c)\cat=cat$
    ;
    ;  Add Category To Cat List If not exist
    ;
    c=0
    found=0
    Repeat
      If Cats$(c)=cat$
        ; Already Exists
        found=1
      Else
        c=c+1
      EndIf
    Until found=1 Or c=#CatMax Or cats$(c)="" 
    If found=0 And c<#CatMax
      ; Catagory(0) = Count Of Categories
      Cats$(0)=Str(c)
      Cats$(c)=cat$
      SetGadgetText(#Cat_Count,Str(c))
      SortArray(cats$(),0,1,Val(cats$(0)))
    EndIf
  EndIf
EndProcedure

Procedure Category()
   ; Extract Category Info For Roms
   pg=Lof(#file1)/100
   text$=filefind("[category]",#file1)
   If text$=""
      ProcedureReturn
   Else
      ;
      ; Read Next Line Of File
      ; Set Counter to 0
      ;
      text$=LCase(ReadString(#file1))
      Cat=-1
      
      ;
      ; Keep Reading File Until Reach [VerAdded] info
      ;
      While FindString(text$,"[veradded]",1)=0
        ;Cat=Cat+1
        extract_catinfo(text$)
        pgpos=Loc(#file1)/pg
        SetGadgetState(#progressbar_0,pgpos)
        ; To get next record
        ; Add 36 Bytes onto rom pointer
        *RomInfo=*RomInfo+36 
        text$=LCase(ReadString(#file1))
      Wend
   EndIf
EndProcedure

Procedure extract_verinfo(text$)
  ; Split String Into RomName + Version Added
  ; 
  s=1
  m=FindString(text$,"=",1)
  e=Len(text$)-m
  t1$=Trim(Mid(text$,s,m-1))
  t2$=Trim(Mid(text$,m+1,e))
  ; Find rom$ in Cat List & Add Version Info
  c=0
  c=findrom(t1$)
  If c<>0
    RomInfo(c)\ver=t2$
    ;
    ;  Add Category To Cat List If not exist
    ;
    exit=0
    c=0
    Repeat
      If Ver$(c)=t2$
        ; Already Exists
        exit=1
      Else
        c=c+1
      EndIf
    Until exit=1 Or c=#VerMax Or Ver$(c)=""
    If exit=0 And c<>#VerMax
      ; Catagory(0) = Count Of Categories
      Ver$(0)=Str(c)
      Ver$(c)=t2$
      SetGadgetText(#Vers_Count,Str(c))
    EndIf
  EndIf
  
EndProcedure

Procedure Version()
  ; Extract Version Info For Roms
  ; 
  ;count=0
  ;
  ; Keep Reading File Until Reach EOF
  ;
  pg=Lof(#file1)/100
  text$=LCase(ReadString(#file1))
  While Eof(#file1)=0
    extract_verinfo(text$)
    pgpos=Loc(#file1)/pg
    SetGadgetState(#progressbar_0,pgpos)

    text$=LCase(ReadString(#file1))
    ;count=count+1
  Wend
  CloseFile(#file1)
  If text$<>""
    extract_verinfo(text$)
  EndIf
  SetGadgetState(#progressbar_0,0) 
EndProcedure

Procedure parse_catver(file$)
If OpenFile(#file1,file$)
    ;
    ; Get ID Info
    ;
    IDString()
     
    ;
    ; Get Category Info
    ;
    Category()
    ;SortArray(cats$(),0,1,Val(cats$(0)))
    ;
    ; Get Version Info
    ;
    Version()
    SortArray(ver$(),0,1,Val(ver$(0)))
 EndIf
EndProcedure

Procedure dolists()
  SortStructuredArray(RomInfo(), 0,OffsetOf(game\romname),#PB_Sort_String,0,gameno)
  ;SortStructuredArray(CatVer(), 0,OffsetOf(gamecat\cat),#PB_Sort_String,0,cat)
  ;Get_sublist()
  For z=0 To gameno
  With rominfo(z)
  r$=\romname+Chr(10)
  r$=r$+\cat+Chr(10)
  r$=r$+\ver
  EndWith
  If rominfo(z)\cat ="" Or rominfo(z)\ver=""
    AddGadgetItem(#SUBlist,-1,r$)
    AddGadgetItem(#SUB_Romlist,-1,rominfo(z)\romname)
    AddGadgetItem(#AutoRomlist,-1,rominfo(z)\romname+Chr(10))
  EndIf
  Next z

  ; Main Rom List
  For z=0 To gameno
  ; chr(10) to go next column
  r$=rominfo(z)\romname+Chr(10)+rominfo(z)\cloneof+Chr(10)
  r$=r$+rominfo(z)\driver+Chr(10)+rominfo(z)\year+Chr(10)
  r$=r$+rominfo(z)\maker+Chr(10)+Str(rominfo(z)\width)+Chr(10)
  r$=r$+Str(rominfo(z)\height)+Chr(10)+Str(rominfo(z)\aspectx)+Chr(10)
  r$=r$+Str(rominfo(z)\aspecty)+Chr(10)
  r$=r$+rominfo(z)\cat+Chr(10)+rominfo(z)\ver
  AddGadgetItem(#XMLlist,-1,r$)
  Next z
  For z=1 To Val(cats$(0))
    AddGadgetItem(#CatList,-1,cats$(z))
    AddGadgetItem(#SUB_CatList,-1,cats$(z))
    AddGadgetItem(#Autocatlist,-1,cats$(z))
  Next z
  For z=1 To Val(ver$(0))
    AddGadgetItem(#VerList,-1,ver$(z))
    AddGadgetItem(#SUB_VerList,-1,ver$(z))
  Next z
EndProcedure

Procedure Mame_EXE()
Dim t$(3)
error=0
file$=GetGadgetText(#Mame_EXE)
If FileSize(file$)=0 Or Right(file$,3)<>"exe"
  error=1
Else
  prog = RunProgram(file$,"-help","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
  x=0
  While ProgramRunning(prog)
    t$(x)=ReadProgramString(prog)
    x=x+1
  Wend
  CloseProgram(prog)
  x$=t$(0)
  If Left(x$,8)="M.A.M.E."
    ; Set Gadget Text
    t1=FindString(x$," v",1)+2
    t2=FindString(x$," (",1)
    SetGadgetText(#mame_ver,Mid(x$,t1,t2-t1))
    t1=FindString(x$," (",1)+2
    t2=FindString(x$,") ",1)
    SetGadgetText(#mame_date,Mid(x$,t1,t2-t1))
  Else
    error=1
  EndIf
EndIf 

If error=1
      t$=""
      t$=t$+"You require a M.A.M.E. executable"+Chr(13)
      t$=t$+"for this program to work with."+Chr(13)
      MessageRequester("ERROR",t$)
    ProcedureReturn
EndIf

prog = RunProgram(file$,"-listxml","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
text$="" : file$="temp-xml.txt"
pg=0 
; Create XML file to extract info
If CreateFile(0,file$)
  While ProgramRunning(prog)
    text$=ReadProgramString(prog)
    WriteString(0,text$)
    SetGadgetState(#progressbar_0,pg)
    pg=pg+1
  Wend
  CloseFile(0)
EndIf
CloseProgram(prog)

parse_xml(file$)
file$=GetGadgetText(#Catver)
parse_catver(file$)    
DoLists()

EndProcedure

Procedure cleardata()
t$="  "
;For x= 1 To Val(ver$(0))
;  ver$(x)=t$
;Next x
;For x= 1 To Val(cats$(0))
;  cats$(x)=t$
;Next x
;ver$(0)=t$
;cats$(0)=t$
gameno=0
; Clear Rom Info
Dim ver$(0)
Dim cats$(0)
Dim ver$(#vermax)
Dim cats$(#catmax)
Dim RomInfo.game(0)
Dim rominfo.game(#max)
;With rominfo(0)
;  \romname=t$
;  \cloneof=t$
;  \driver=t$
;  \year=t$
;  \maker=t$
;  \width=0
;  \height=0
;  \aspectx=0
;  \aspecty=0
;  \cat=t$
;  \ver=t$
;EndWith

ClearGadgetItemList(#XMLlist)
ClearGadgetItemList(#CatList)
ClearGadgetItemList(#VerList)
ClearGadgetItemList(#SUB_romlist)
ClearGadgetItemList(#SUB_catlist)
ClearGadgetItemList(#SUB_verlist)
ClearGadgetItemList(#autocatlist)
ClearGadgetItemList(#autoromlist)

SetGadgetText(#Cat_ID,t$)
Debug GetGadgetText(#cat_id)
SetGadgetText(#Cat_Mame,t$)
SetGadgetText(#Cat_Date,t$)
SetGadgetText(#Mame_Ver,t$)
SetGadgetText(#Mame_Date,t$)
SetGadgetText(#Cat_Count,t$)
SetGadgetText(#Vers_Count,t$)
SetGadgetText(#Rom_Count,t$)

EndProcedure

Procedure findlistitem(list,rom$)
max=CountGadgetItems(list)
t=0:exit=0
Repeat
  t$=GetGadgetItemText(list,t,0)
  ;If rom$=GetGadgetItemText(list,t,1)
  If rom$=t$
    exit=1
  Else
    t=t+1
  EndIf
Until t>max Or exit=1
ProcedureReturn t
EndProcedure

Procedure Save_INI()
If OpenFile(#file2,"TestOut.ini")
   WriteStringN(#file2,";; CatVer (rev. 2) / 11-Sep-05 / MAME .99u2 / http://www.mameworld.net/catlist ;;")
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[Category]")

  ; Save Romname=Category   
  t=0:exit=0
  Repeat
    t$=""
    t$=rominfo(t)\romname + "=" + rominfo(t)\cat
    WriteStringN(#file2,t$)
    t=t+1
  Until rominfo(t)\romname=""
  
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[VerAdded]")
   
  ; Save Romname=Version   
  t=0:exit=0
  Repeat
    t$=""
    t$=rominfo(t)\romname + "=" + rominfo(t)\ver
    WriteStringN(#file2,t$)
    t=t+1
  Until rominfo(t)\romname=""
   CloseFile(#file2)

  EndIf
EndProcedure

Procedure Save_genreV()
If OpenFile(#file2,"GenreV-test.ini")
   WriteStringN(#file2,";; GenRev (rev. 1) / 11-Sep-05 / MAME .99u2 / http://www.mameworld.net/catlist ;;")
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[Category]")

  ; Save Romname=Category   
  t=0:exit=0
  Repeat
    t$=""
    t$=rominfo(t)\romname + "=" + rominfo(t)\cat
    WriteStringN(#file2,t$)
    t=t+1
  Until rominfo(t)\romname=""
  
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[VerAdded]")
   
  ; Save Romname=Version   
  t=0:exit=0
  Repeat
    t$=""
    t$=rominfo(t)\romname + "=" + rominfo(t)\ver
    WriteStringN(#file2,t$)
    t=t+1
  Until rominfo(t)\romname=""
   CloseFile(#file2)

  EndIf
EndProcedure

Procedure Save_gRCatVer()
If OpenFile(#file2,"GenreV-test.ini")
   WriteStringN(#file2,";; GenRev (rev. 1) / 11-Sep-05 / MAME .99u2 / http://www.mameworld.net/catlist ;;")
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[Category]")

  ; Save Romname=Category   
  t=0:exit=0
  Repeat
    t$=""
    t$=rominfo(t)\romname + "=" + rominfo(t)\cat
    WriteStringN(#file2,t$)
    t=t+1
  Until rominfo(t)\romname=""
  
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[VerAdded]")
   
  ; Save Romname=Version   
  t=0:exit=0
  Repeat
    t$=""
    t$=rominfo(t)\romname + "=" + rominfo(t)\ver
    WriteStringN(#file2,t$)
    t=t+1
  Until rominfo(t)\romname=""
   CloseFile(#file2)

  EndIf
EndProcedure

Procedure Save_Cat32()
If OpenFile(#file2,"Cat32-1test.ini")
   WriteStringN(#file2,"[FOLDER_SETTINGS]")
   WriteStringN(#file2,"RootFolderIcon = cust1.ico")
   WriteStringN(#file2,"SubFolderIcon = cust2.ico")
   WriteStringN(#file2,"")
   WriteStringN(#file2,"[ROOT_FOLDER]")
EndIf
EndProcedure

Procedure Save_Deluxe32()
EndProcedure 

Procedure Save_Classics()
EndProcedure

Procedure Save_Mac()
;; uses tab instead of = as separator.

WriteStringN(#file2,"// MacMAME Category Sorting File -- this line must be the first line in the file")
WriteStringN(#file2,"")
WriteStringN(#file2,"// Put this file in your MacMAME "+Chr(34)+"Categories"+Chr(34)+" folder.")
WriteStringN(#file2,"")
WriteStringN(#file2,"// Based on catver.ini For Mame v0.97 Updated 16 June 2005")
WriteStringN(#file2,"// This file is For use With MacMAME www.macmame.org")
WriteStringN(#file2,"// [VerAdded]") 
EndProcedure

Procedure Save_SHACCsort()
EndProcedure
   
Procedure Save_WizSort()
EndProcedure


;
; Main Program Routine
;

#WindowWidth  = 390
#WindowHeight = 350

; Open Main Window
; And SetGadgets
;
Open_window_0()
  

  Repeat
    EventID = WaitWindowEvent()
    If eventid = #PB_Event_ActivateWindow
      InvalidateRgn_(#window_0,#Null,1)
      UpdateWindow_(#window_0)
      SmartWindowRefresh(#window_0,1)
      ;SendMessage_(WindowID(#Window_0),#WM_SETREDRAW,#True,0) 
      ;RedrawWindow_(WindowID(#Window_0),#Null,#Null,#RDW_INVALIDATE)
    EndIf
    
    If EventID = #PB_Event_Gadget
      Select EventGadget()    
        Case #Parse ; Parse File
          cleardata()
          mame_exe()
          
        Case #Cat_File
          f$=OpenFileRequester("Select CatVer.ini File","catver.ini","INI (*.ini)",1)
          SetGadgetText(#Catver,f$)
                    
        Case #Mame_File
          f$=OpenFileRequester("Select Mame.exe","Mame.exe","*.exe",0)
          SetGadgetText(#Mame_exe,f$)
          
        Case #SUBlist
        
        Case #SUB_romlist
          rom$=GetGadgetText(#SUB_romlist)
          SetGadgetText(#text_20,rom$)
            
                
        Case #SUB_Catlist
          cat$=GetGadgetText(#sub_catlist)
          SetGadgetText(#text_21,cat$)
        
        Case #SUB_Verlist
          ver$=GetGadgetText(#SUB_Verlist)
           SetGadgetText(#text_22,ver$)
 
        Case #update
          ; Sets Data But Not Update list gadgets
           rom$=GetGadgetText(#text_20)
           cat$=GetGadgetText(#text_21)
           ver$=GetGadgetText(#text_22)
           t=findrom(rom$)
           If t<>0                
             rominfo(t)\cat=cat$
             rominfo(t)\ver=ver$
             ;Update Main Romlist Info
             SetGadgetItemText(#XMLlist,t,rominfo(t)\cat,9)
             SetGadgetItemText(#XMLlist,t,rominfo(t)\ver,10)
             z=GetGadgetState(#SUB_romlist)
             RemoveGadgetItem(#SUB_romlist,z)
             z=findlistitem(#SUBlist,rom$)
             SetGadgetItemText(#SUBlist,z,rominfo(t)\cat,1)
             SetGadgetItemText(#SUBlist,z,rominfo(t)\ver,2)
           EndIf
           
          Case #AutoEdit
            ;Auto_edit_data()
            
        
          Case  #Save_CatVer
          MessageRequester("Saving","Saving New Catver.ini")
          Save_INI()

          Case  #Save_GenreV
          MessageRequester("Saving","Saving New GenreV.ini")

          Case  #Save_gRCatVer
          MessageRequester("Saving","Saving New gRCatVer.ini")

          Case  #Save_Cat32
          MessageRequester("Saving","Saving New Cat32.ini")

          Case  #Save_Deluxe32
          MessageRequester("Saving","Saving New Deluxe32.ini")

          Case  #Save_Classics
          MessageRequester("Saving","Saving New Classics 32.ini")

          Case  #Save_Mac
          MessageRequester("Saving","Saving New Mac Catver.ini")

          Case  #Save_SHACCsort
          MessageRequester("Saving","Saving New SHACCsort.ini")

          Case  #Save_WizSort
          MessageRequester("Saving","Saving New WizSort.ini")
          
                            
        Case 8 ; Quit...
          EventID = #PB_Event_CloseWindow      
      EndSelect
      
    EndIf
  Until EventID = #PB_Event_CloseWindow

End 

Code: Select all

;
; PureBasic Visual Designer v3.92 build 1460


;- Window Constants
;
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Panel_0
  #Text_0
  #Text_1
  #Text_2
  #Text_3
  #Text_4
  #Text_5
  #Text_6
  #Text_7
  #Text_8
  #Text_9
  #Text_10
  #Text_11
  #Text_12
  #Text_13
  #Text_14
  #Text_15
  #Text_16
  #Frame3D_0
  #Frame3D_1
  #Catver
  #Cat_ID
  #Cat_Date
  #Cat_Mame
  #ListXML
  #Mame_Ver
  #Mame_Date
  #Mame_exe
  #Cat_Count
  #Vers_Count
  #Rom_Count
  #Mame_File
  #Cat_File
  #ProgressBar_0
  #Parse
  #List2
  #CatList
  #VerList
  #XMLlist
  #Sublist
  #Update
  #Text_17
  #Text_18
  #Text_19
  #SUB_CatList
  #SUB_VerList
  #SUB_RomList
  #Text_20
  #Text_21
  #Text_22
  #Save_INI
  
  #Save_CatVer
  #Save_GenreV
  #Save_gRCatVer
  #Save_Cat32
  #Save_Deluxe32
  #Save_Classics
  #Save_Mac
  #Save_SHACCsort
  #Save_WizSort
  
  #AutoRomList
  #AutoCatList
  #AutoVersion
  #AutoEdit
  #Text_23
  #Text_24
  #Text_25
  #Text_26
  #Text_27
  #Text_28
  #Text_29
  #Text_30
    
EndEnumeration

;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Arial", 12)


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 100, 100, 850, 700 , #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered, "Generate Catver.ini" )
    If CreateGadgetList(WindowID(#Window_0))
      PanelGadget(#Panel_0, 2, 2, 800, 650)
      SetGadgetFont(#Panel_0, FontID1)
      x=2 : y=2
      AddGadgetItem(#Panel_0, -1, "Main")

      ; CatVer.Ini  Panel Side
      ;Frame3DGadget(#Frame3D_0, x+10, y+15, 340, 510, "")
      TextGadget(#Text_0, X+70, y+25, 240, 20, "Catver.ini File :", #PB_Text_Center)
      SetGadgetFont(#Text_0, FontID1)
      TextGadget(#Text_2, X+30, Y+145,  90, 30, "Mame Ver : ", #PB_Text_Right)
      SetGadgetFont(#Text_2, FontID1)
      TextGadget(#Text_3, x+30, Y+85,   90, 30, " Version : ", #PB_Text_Right)
      SetGadgetFont(#Text_3, FontID1)
      TextGadget(#Text_4, x+30, Y+55 ,  90, 30, "    File : ", #PB_Text_Right)
      SetGadgetFont(#Text_4, FontID1)
      TextGadget(#Text_5, x+30, Y+115,  90, 30, "    Date : ", #PB_Text_Right)
      SetGadgetFont(#Text_5, FontID1)
      StringGadget(#Catver, x+125, y+50, 170, 30, "catver.ini")
      SetGadgetFont(#Catver, FontID1)
      StringGadget(#Cat_ID, x+125, y+80, 170, 30, "", #PB_String_ReadOnly)
      SetGadgetFont(#Cat_ID, FontID1)
      StringGadget(#Cat_Date, x+125, y+110, 170, 30, "", #PB_String_ReadOnly)
      SetGadgetFont(#Cat_Date, FontID1)
      StringGadget(#Cat_Mame, x+125, y+140, 170, 30, "", #PB_String_ReadOnly)
      SetGadgetFont(#Cat_Mame, FontID1)
      ButtonGadget(#Cat_File, x+310, y+55, 20, 20, "...")
      ;-
      TextGadget(#Text_1, x+30, y+180, 103, 20, "Category List", #PB_Text_Center)
      SetGadgetFont(#Text_1, FontID1)
      TextGadget(#Text_16, x+177, Y+180, 103, 20, "Version List", #PB_Text_Center)
      SetGadgetFont(#Text_16, FontID1)
      ListIconGadget(#CatList, x+30, y+200, 110, 306, "Category", 110, #PB_ListIcon_GridLines)
      ListIconGadget(#VerList, x+175, y+200, 110, 306, "Version Added", 110, #PB_ListIcon_GridLines)
      

      x=400 : y=2
      ; Mame / XML Panel Side
      ;Frame3DGadget(#Frame3D_1, x+10, y+15, 340, 510, "")
      TextGadget(#Text_7, X+70, y+25, 240, 20, "Mame / XML Info", #PB_Text_Center)
      SetGadgetFont(#Text_7, FontID1)
      TextGadget(#Text_9, x+30, Y+55,  90, 30, "Mame Exe : ", #PB_Text_Right)
      SetGadgetFont(#Text_9, FontID1)
      TextGadget(#Text_8, x+30, Y+85, 90, 30, "Version  : ", #PB_Text_Right)
      SetGadgetFont(#Text_8, FontID1)
      TextGadget(#Text_11, x+30, Y+115, 90, 30, "   Date : ", #PB_Text_Right)
      SetGadgetFont(#Text_11, FontID1)
      ;StringGadget(#ListXML,   x+125, y+50, 170, 30, "")
      ;SetGadgetFont(#ListXML, FontID1)
      StringGadget(#Mame_Ver,  x+125, y+80, 170, 30, "", #PB_String_ReadOnly)
      SetGadgetFont(#Mame_Ver, FontID1)
      StringGadget(#Mame_Date, x+125, y+110, 170, 30, "", #PB_String_ReadOnly)
      SetGadgetFont(#Mame_Date, FontID1)
      StringGadget(#Mame_exe,  x+125, y+50, 170, 30, "Mame.exe")
      SetGadgetFont(#Mame_exe, FontID1)
      ButtonGadget(#Mame_File, x+310, y+55, 20, 20, "...")

      ;-
      TextGadget(#Text_10, x+140, Y+180, 90, 30, " Rom Info ", #PB_Text_Center)
      SetGadgetFont(#Text_10, FontID1)
      ListIconGadget(#XMLlist, x+30, y+200, 300, 300, "Rom Name", 60, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
      AddGadgetColumn(#XMLlist, 1, "Clone Of", 60)
      AddGadgetColumn(#XMLlist, 2, "Driver", 80)
      AddGadgetColumn(#XMLlist, 3, "Year", 40)
      AddGadgetColumn(#XMLlist, 4, "Manufacturer", 100)
      AddGadgetColumn(#XMLlist, 5, "Width", 40)
      AddGadgetColumn(#XMLlist, 6, "Height", 40)
      AddGadgetColumn(#XMLlist, 7, "Aspect X", 40)
      AddGadgetColumn(#XMLlist, 8, "Aspect Y", 40)
      AddGadgetColumn(#XMLlist, 9, "Cat.", 100)
      AddGadgetColumn(#XMLlist,10, "Ver Added", 40)
      
      
      x=2 : y=470
      ; Other Gadgets
      TextGadget(#Text_12, x+10, Y+115, 121, 20,"Progress : ", #PB_Text_Center)
      SetGadgetFont(#Text_12, FontID1)
      TextGadget(#Text_14, x+400, Y+65, 76, 21, "No. Roms  ", #PB_Text_Center)
      SetGadgetFont(#Text_14, FontID1)
      TextGadget(#Text_15, x+190, Y+65, 76, 21, "Versions  ", #PB_Text_Center)
      SetGadgetFont(#Text_15, FontID1)
      TextGadget(#Text_13, x+20,  Y+65, 76, 21, "Categories", #PB_Text_Center)
      SetGadgetFont(#Text_13, FontID1)
      StringGadget(#Cat_Count, x+105, y+60, 80, 30, "", #PB_String_ReadOnly | #PB_String_Numeric)
      SetGadgetFont(#Cat_Count, FontID1)
      StringGadget(#Vers_Count,x+265, y+60, 80, 30, "", #PB_String_ReadOnly | #PB_String_Numeric)
      SetGadgetFont(#Vers_Count, FontID1)
      StringGadget(#Rom_Count, x+480, y+60, 80, 30, "", #PB_String_ReadOnly | #PB_String_Numeric)
      SetGadgetFont(#Rom_Count, FontID1)
      ProgressBarGadget(#ProgressBar_0, x+110, y+110, 661, 30, 0, 100)
      
      ButtonGadget(#Parse, x+680, y+60, 100, 30, "Get Data")
      SetGadgetFont(#Parse, FontID1)

      TextGadget(#Text_6, x+330, Y+112,  190, 24, "", #PB_Text_Center)
      SetGadgetFont(#Text_6, FontID1)
      
      
      x=2 : y=2
      ;- Auto Add Rom Page
      AddGadgetItem(#Panel_0, -1, "Auto Add")
      ListIconGadget(#AutoRomList, x+200, y+45, 300, 300, "Rom Name", 60, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
        AddGadgetColumn(#AutoRomList, 9, "Cat.", 100)
        AddGadgetColumn(#AutoRomList,10, "Ver Added", 40)

      ;TextGadget(#Text_23, x+20, Y+30, 100, 20, "CatList", #PB_Text_Center)
      ;SetGadgetFont(#Text_23, FontID1)
      ListIconGadget(#AutoCatList, x+20, y+45, 100, 300, "Cat.", 110, #PB_ListIcon_GridLines)
      
      TextGadget(#Text_24, x+560, Y+30, 100, 20, "Rom Name")
      SetGadgetFont(#Text_24, FontID1)
      TextGadget(#Text_25, x+560, Y+50, 100, 20, "Rom Cat" )
      SetGadgetFont(#Text_25, FontID1)
      TextGadget(#Text_26, x+560, Y+70, 100, 20, "Rom Vers")
      SetGadgetFont(#Text_26, FontID1)
 
      ButtonGadget(#AutoEdit,x+560,y+110,100,20,"Edit Rom Cat.")


      x=2 : y=2
      ;- Manual Add Rom
      AddGadgetItem(#Panel_0, -1, "Manual Add")
      ListIconGadget(#Sublist, x+474, y+295, 294, 195, "Rom Name", 60, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
        AddGadgetColumn(#Sublist, 9, "Cat.", 100)
        AddGadgetColumn(#Sublist,10, "Ver Added", 40)
      TextGadget(#Text_17, x+20, Y+30, 100, 20, "Rom List", #PB_Text_Center)
      SetGadgetFont(#Text_17, FontID1)
      ListIconGadget(#Sub_RomList, x+20, y+45, 100, 306, "Rom", 110, #PB_ListIcon_GridLines)
      TextGadget(#Text_18, x+140, y+30, 100, 20, "Category List", #PB_Text_Center)
      SetGadgetFont(#Text_18, FontID1)
      ListIconGadget(#Sub_CatList, x+140, y+45, 100, 306, "Category", 110, #PB_ListIcon_GridLines)
      TextGadget(#Text_19, x+260, Y+30, 100, 20, "Version List", #PB_Text_Center)
      SetGadgetFont(#Text_19, FontID1)
      ListIconGadget(#Sub_VerList, x+260, y+45, 100, 306, "Version Added", 110, #PB_ListIcon_GridLines)
      
      TextGadget(#Text_20, x+560, Y+30, 100, 20, "Rom Name")
      SetGadgetFont(#Text_20, FontID1)
      TextGadget(#Text_21, x+560, Y+50, 100, 20, "Rom Cat" )
      SetGadgetFont(#Text_21, FontID1)
      TextGadget(#Text_22, x+560, Y+70, 100, 20, "Rom Vers")
      SetGadgetFont(#Text_22, FontID1)
 
      ButtonGadget(#Update,x+10,y+10,100,20,"Update Info")

      x=2 : y=2
      ;- Save Different Catver.ini Files
      AddGadgetItem(#Panel_0, -1, "Save Catver.ini")   
        ButtonGadget(#Save_CatVer     ,x+10,y+10,100,20,"Catver")
        ButtonGadget(#Save_GenreV     ,x+10,y+35,100,20,"GenreV")
        ButtonGadget(#Save_gRCatVer   ,x+10,y+60,100,20,"gRCarVer")
        ButtonGadget(#Save_Cat32      ,x+10,y+85,100,20,"Cat32")
        ButtonGadget(#Save_Deluxe32   ,x+10,y+110,100,20,"Deluxe32")
        ButtonGadget(#Save_Classics   ,x+10,y+135,100,20,"Classics 32")
        ButtonGadget(#Save_Mac        ,x+10,y+160,100,20,"Mac Catver")
        ButtonGadget(#Save_SHACCsort  ,x+10,y+185,100,20,"SHACCsort")
        ButtonGadget(#Save_WizSort    ,x+10,y+210,100,20,"Wizsort")

      CloseGadgetList()
     
      
    EndIf
  EndIf
EndProcedure


Also if it helps i am using PB4 beta 3.
other beta versions not working properly with this code.
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

:shock:
Tranquil
STU-ASI
User
User
Posts: 24
Joined: Thu Dec 08, 2005 10:56 am

Post by STU-ASI »

Thanks fang...

Hope this is enough code for you.. :lol:


The code in question should be just erase data arrays.
Clearing the list gadgets
And also the text gadgets.

The arrays are erased & also the gadgets cleared.
as i have inserted debug between commands & read the gadgets back.

So the info is cleared, but not the window displayed.

As i said its not a mojor problem, just curious as to why the window itself is not getting refreshed when gadgets are cleared.
STU-ASI
User
User
Posts: 24
Joined: Thu Dec 08, 2005 10:56 am

Post by STU-ASI »

ok tranquil
so i may have gone a little overbored with the code posted.

But hey more is better sometimes.

:wink:
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Fangs will be pleased .. :lol:
@}--`--,-- A rose by any other name ..
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

Dare2 wrote:Fangs, you're mellowing! :)
Damn you, how DARE you tell people my secrets!!! Ah, well now. Your name is [/b]Dare2[/b] after all so you do dare. But no more loose women for you damn it!!!

I'll send them to PB now.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

STU-ASI wrote:ok tranquil
so i may have gone a little overbored with the code posted.

But hey more is better sometimes.

:wink:
Not overboard at all. if you get the working code, you can reference what is going on in it. When you posted just a procedure, we had no idea what the program was doing, what the flow was etc.

What you can do in the future though is paste the code at
http://www.rafb.net/paste/

and just give us the URL to the new paste.

I've converted the code (only one line really) to work with PB4 Beta 7 and it's running. Now I just need some data to add to it to see the problem.

From memory, a lot of the refresh problems (gadget and gadget order related) you have described existed in earlier version of PB beta and have been fixed in the current one. You might want to get the latest beta. All I had to change was the OpenWindow statement where the flags are now after the title to get it to run in the latest beta.

Then see if the refresh problems still exist. Had I know you were using an old beta with known problems of that sort, that would have been the first thing I said.

Try that and let us know okay?

**EDIT**

You use "r$=r$+rominfo(z)" In PB you can shorten that to

"r$ + rominfo(z)" which does the same thing.
Last edited by Fangbeast on Tue Mar 21, 2006 1:59 pm, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Post Reply