o_O 3 Bugs...

Just starting out? Need help? Post your questions and find answers here.
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

o_O 3 Bugs...

Post by DarthPuff »

OK I'm having trouble with getpathpart() and getfilepart().... and is there any code for seeing if a file exists?

Heres the bug with getpathpart() and getfilepart():

The code!

path.s=GetPathPart(File2.s)
WriteStringN(path.s)
part.s=GetFilePart(File2.s)
WriteStringN(part.s)

What it stores!
--------start
D:\Stuff\MySoftware\DarkHalf\Particles\v0.0.2\System\
example.bmp[][][]
p[][][]

p
--------end

o_O those squares are really newlines that notepad doesnt understand... whats wrong?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: o_O 3 Bugs...

Post by PB »

> is there any code for seeing if a file exists?

Code: Select all

If FileSize(file$)=-1
  Debug file$+" does not exist"
EndIf
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

I tried that except it was <> instead of = because I want to know when its there....
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

Ehm, maybe I got you wrong, but how about this extension of PB's code :?:

Code: Select all

If FileSize(file$)=-1 
  Debug file$+" does not exist" 
Else
  Debug file$+" does exist"
EndIf 
Regards, benny!
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

About GetPathPart():

What does the 'File2.s' String look like? Maybe this one contains any
special characters (such as CR or LF for example) and that causes the
problem?

This code works fine here:

Code: Select all

File2.s = "D:\Stuff\MySoftware\DarkHalf\Particles\v0.0.2\System\example.bmp"

If CreateFile(0, "C:\Temp\Test.txt")

  path.s=GetPathPart(File2.s) 
  WriteStringN(path.s) 
  part.s=GetFilePart(File2.s) 
  WriteStringN(part.s) 
  
  CloseFile(0)
EndIf
Or maybe something else is wrong in your code, that causes the problem?

Please check again, and maybe post a code snippet that can actually show
the error. Maybe we can help you a bit more then...

Timo
quidquid Latine dictum sit altum videtur
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

Heres the code... o_O it should run by itself... all you need is a 32x32 image and a /system/ directory... -_-

Code: Select all

;#STANDARD_RIGHTS_REQUIRED = $000F0000
;#SYNCHRONIZE = $00100000
;#PROCESS_ALL_ACCESS = #STANDARD_RIGHTS_REQUIRED+#SYNCHRONIZE+$0FFF
;ProgramName.s = "System/Particles.exe"
;WindowTitle.s = "Particles v0.0.2 Alpha Runtime Window - Puff Inter@ctive"
;RunProgram(ProgramName.s)

If OpenWindow(0,0,0,215,375, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_MinimizeGadget,"Particles v0.0.2 Alpha")

  If CreateToolBar(0, WindowID())
  
    ToolBarStandardButton(0, #PB_ToolBarIcon_New)
    ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
    ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
    ToolBarSeparator() 
    ToolBarStandardButton(6, #PB_ToolBarIcon_Print)
    ToolBarSeparator()
    ToolBarStandardButton(4, #PB_ToolBarIcon_Help)
    
  EndIf

  If CreateMenu(0, WindowID())
  
    MenuTitle("File")
      MenuItem( 0, "New")
      MenuBar()
      MenuItem( 1, "Open")
      MenuItem( 2, "Save")
      MenuBar()
      OpenSubMenu("Recent") 
      CloseSubMenu()  
      MenuBar()
      MenuItem( 3, "Exit")
      
    MenuTitle("Help")
      MenuItem(4, "Help")
      MenuBar()
      MenuItem(5, "About")
         
  EndIf
  
  If CreateGadgetList(WindowID())
  
    PanelGadget(0,0,30,215,325)
    
      AddGadgetItem(0,0,"Variables")
        TextGadget(1, 0, 0, 75, 25, "Radius", #PB_Text_Center) 
        ButtonGadget(2, 75, 0, 15, 25, "<=")
        ButtonGadget(3, 90, 0, 15, 25, "<")
        StringGadget(4, 105, 0, 75, 25, Radius$ , #PB_String_Numeric)
        ButtonGadget(5, 180, 0, 15, 25, ">")
        ButtonGadget(6, 195, 0, 15, 25, "=>")
         
        TextGadget(7, 0, 25, 75, 25, "Speed" , #PB_Text_Center)
        ButtonGadget(8, 75, 25, 15, 25, "<=")
        ButtonGadget(9, 90, 25, 15, 25, "<")
        StringGadget(10, 105, 25, 75, 25, Speed$, #PB_String_Numeric)
        ButtonGadget(11, 180, 25, 15, 25, ">")
        ButtonGadget(12, 195, 25, 15, 25, "=>")
        
        TextGadget(13, 0, 50, 75, 25, "Gravity" , #PB_Text_Center)
        ButtonGadget(14, 75, 50, 15, 25, "<=")
        ButtonGadget(15, 90, 50, 15, 25, "<")
        StringGadget(16, 105, 50, 75, 25, Gravity$ , #PB_String_Numeric)
        ButtonGadget(17, 180, 50, 15, 25, ">")
        ButtonGadget(18, 195, 50, 15, 25, "=>")
        
        TextGadget(19, 0, 75, 75, 25, "Velocity" , #PB_Text_Center)
        ButtonGadget(20, 75, 75, 15, 25, "<=")
        ButtonGadget(21, 90, 75, 15, 25, "<")
        StringGadget(22, 105, 75, 75, 25, Velocity$ , #PB_String_Numeric)
        ButtonGadget(23, 180, 75, 15, 25, ">")
        ButtonGadget(24, 195, 75, 15, 25, "=>")
         
        TextGadget(25, 0, 100, 75, 25, "Chaos" , #PB_Text_Center)
        ButtonGadget(26, 75, 100, 15, 25, "<=")
        ButtonGadget(27, 90, 100, 15, 25, "<")
        StringGadget(28, 105, 100, 75, 25, Chaos$ , #PB_String_Numeric)
        ButtonGadget(29, 180, 100, 15, 25, ">")
        ButtonGadget(30, 195, 100, 15, 25, "=>")
        
        TextGadget(31, 0, 125, 75, 25, "Life" , #PB_Text_Center)
        ButtonGadget(32, 75, 125, 15, 25, "<=")
        ButtonGadget(33, 90, 125, 15, 25, "<")
        StringGadget(34, 105, 125, 75, 25, Life$ , #PB_String_Numeric)
        ButtonGadget(35, 180, 125, 15, 25, ">")
        ButtonGadget(36, 195, 125, 15, 25, "=>")
        
        TextGadget(37, 0, 150, 75, 25, "Emissions" , #PB_Text_Center)
        ButtonGadget(38, 75, 150, 15, 25, "<=")
        ButtonGadget(39, 90, 150, 15, 25, "<")
        StringGadget(40, 105, 150, 75, 25, Emissions$ , #PB_String_Numeric)
        ButtonGadget(41, 180, 150, 15, 25, ">")
        ButtonGadget(42, 195, 150, 15, 25, "=>")
        
        TextGadget(43, 0, 175, 75, 25, "Frequency" , #PB_Text_Center)
        ButtonGadget(44, 75, 175, 15, 25, "<=")
        ButtonGadget(45, 90, 175, 15, 25, "<")
        StringGadget(46, 105, 175, 75, 25, Frequency$ , #PB_String_Numeric)
        ButtonGadget(47, 180, 175, 15, 25, ">")
        ButtonGadget(48, 195, 175, 15, 25, "=>")
        
        TextGadget(49, 0, 200, 75, 25, "Depth" , #PB_Text_Center)
        ButtonGadget(50, 75, 200, 15, 25, "<=")
        ButtonGadget(51, 90, 200, 15, 25, "<")
        StringGadget(52, 105, 200, 75, 25, Depth$, #PB_String_Numeric)
        ButtonGadget(53, 180, 200, 15, 25, ">")
        ButtonGadget(54, 195, 200, 15, 25, "=>")
        
        TextGadget(55, 0, 225, 75, 25, "Height" , #PB_Text_Center)
        ButtonGadget(56, 75, 225, 15, 25, "<=")
        ButtonGadget(57, 90, 225, 15, 25, "<")
        StringGadget(58, 105, 225, 75, 25, Height$, #PB_String_Numeric)
        ButtonGadget(59, 180, 225, 15, 25, ">")
        ButtonGadget(60, 195, 225, 15, 25, "=>")
        
        TextGadget(61, 0, 250, 75, 25, "Width" , #PB_Text_Center)
        ButtonGadget(62, 75, 250, 15, 25, "<=")
        ButtonGadget(63, 90, 250, 15, 25, "<")
        StringGadget(64, 105, 250, 75, 25, Width$, #PB_String_Numeric)
        ButtonGadget(65, 180, 250, 15, 25, ">")
        ButtonGadget(66, 195, 250, 15, 25, "=>")
        
        CheckBoxGadget(67, 0, 275, 215, 25, "Floor   |  Key: [>] +/- Less [=>] +/- More") 
    
      AddGadgetItem(0,0,"Image")
        ButtonGadget(68, 0, 0, 75, 25, "Open Image")
        ButtonGadget(69, 0, 25, 75, 25, "Pick Color")
        OptionGadget(70, 100, 0, 125, 25, "Use Image [32x32]")
        OptionGadget(71, 100, 25, 75, 25, "Use Color")
        TextGadget(72, 0, 75, 150, 25, "Current Image:")
        ImageGadget(77, 75, 70, 32, 32, UseImage(0), #PB_Image_Border)
        TextGadget(73, 0, 175, 150, 25, "Current Color:")
                   
      AddGadgetItem(0,0,"Effect")
        ButtonGadget(74, 0, 0, 210, 100, "Fountain")
        ButtonGadget(75, 0, 100, 210, 100, "Fire")
        ButtonGadget(76, 0, 200, 210, 100, "Snow")
      
      AddGadgetItem(0,0,"Rotation")
     
    ClosePanelGadget()
    
  EndIf
  
  Radius.l
  Radius=20
  Radius$=Str(Radius)
  SetGadgetText(4, Radius$)
  
  Speed.f
  Speed=0.01
  Speed$=StrF(Speed)
  SetGadgetText(10, Speed$)
  
  Gravity.l
  Gravity=2
  Gravity$=Str(Gravity)
  SetGadgetText(16, Gravity$)
  
  Velocity.l
  Velocity=5
  Velocity$=Str(Velocity)
  SetGadgetText(22, Velocity$)
  
  Chaos.l
  Chaos=0
  Chaos$=Str(Chaos)
  SetGadgetText(28, Chaos$)
  
  Life.l
  Life=100
  Life$=Str(Life)
  SetGadgetText(34, Life$)
  
  Emissions.l
  Emissions=10
  Emissions$=Str(Emissions)
  SetGadgetText(40, Emissions$)
  
  Frequency.l
  Frequency=100
  Frequency$=Str(Frequency)
  SetGadgetText(46, Frequency$)
  
  Depth.f
  Depth=5
  Depth$=StrF(Depth)
  SetGadgetText(52, Depth$)
  
  Height.f
  Height=5
  Height$=StrF(Height)
  SetGadgetText(58, Height$)
  
  Width.f
  Width=5
  Width$=StrF(Width)
  SetGadgetText(64, Width$)
  
  Floor.b
  SetGadgetState(67, 1)
  Floor=GetGadgetState(67)
  
  Image.b
  SetGadgetState(71, 1)
  Image=GetGadgetState(70)
  
  small.b
  big.b
  
  InitKeyboard()
  
  Repeat
  
    ExamineKeyboard()
    If KeyboardPushed(#PB_Key_All)
        file.s="System/refresh.dat"
        If CreateFile(0,file.s)
          CloseFile(0)
        EndIf
    EndIf
    
    file.s = "System/Update.dat"
    OpenFile(0,file.s)
      WriteStringN(GetGadgetText(4))
      WriteStringN(GetGadgetText(10))
      WriteStringN(GetGadgetText(16))
      WriteStringN(GetGadgetText(22))
      WriteStringN(GetGadgetText(28))
      WriteStringN(GetGadgetText(34))
      WriteStringN(GetGadgetText(40))
      WriteStringN(GetGadgetText(46))
      WriteStringN(GetGadgetText(52))
      WriteStringN(GetGadgetText(58))
      WriteStringN(GetGadgetText(64))
      WriteStringN(Str(GetGadgetState(67)))
      WriteStringN(Str(GetGadgetState(70)))
      WriteStringN(Str(GetGadgetState(71)))
      path.s=GetPathPart(File2.s)
      WriteStringN(path.s)
      part.s=GetFilePart(File2.s)
      WriteStringN(part.s)
    CloseFile(0) 
    
    nop.s="/stuff/nop.dat"
    If FileSize(nop.s)=-1
    Else
      DeleteFile(nop.s)
      MessageRequester("Particles - Error!", "The specified path does not exist!", #PB_MessageRequester_Ok)
    EndIf
    
    noi.s="/stuff/noi.dat"
    If FileSize(noi.s)=-1
    Else
      DeleteFile(noi.s)
      MessageRequester("Particles - Error!", "The specified image does not exist!", #PB_MessageRequester_Ok)
    EndIf
  
    EventID.l = WaitWindowEvent()

    If EventID = #PB_EventMenu   
        Select EventMenuID()
        
          Case 0      
            Radius=20
            Radius$=Str(Radius)
            SetGadgetText(4, Radius$)

            Speed=0.01
            Speed$=StrF(Speed)
            SetGadgetText(10, Speed$)
  
            Gravity=2
            Gravity$=Str(Gravity)
            SetGadgetText(16, Gravity$)

            Velocity=5
            Velocity$=Str(Velocity)
            SetGadgetText(22, Velocity$)
  
            Chaos=0
            Chaos$=Str(Chaos)
            SetGadgetText(28, Chaos$)
  
            Life=100
            Life$=Str(Life)
            SetGadgetText(34, Life$)
  
            Emissions=10
            Emissions$=Str(Emissions)
            SetGadgetText(40, Emissions$)
  
            Frequency=100
            Frequency$=Str(Frequency)
            SetGadgetText(46, Frequency$)
  
            Depth=5
            Depth$=StrF(Depth)
            SetGadgetText(52, Depth$)
 
            Height=5
            Height$=StrF(Height)
            SetGadgetText(58, Height$)
  
            Width=5
            Width$=StrF(Width)
            SetGadgetText(64, Width$)
  
            SetGadgetState(67, 1)
            Floor=GetGadgetState(67)
            
            SetGadgetState(70, 0)           
            SetGadgetState(71, 1)
            Image=GetGadgetState(70)
            
            file.s="System/refresh.dat"
            If CreateFile(0,file.s)
              CloseFile(0)
            EndIf
                            
          Case 1
            File$ = OpenFileRequester("Particles - Open", "C:\", "Particle (*.part)|*.part", 0)
            If File$+File$
              MessageRequester("Information", "Selected File: "+File$, 0)
            EndIf
            
          Case 2
            File$ = SaveFileRequester("Particles - Save", "C:\", "Particle (*.part)|*.part", 1)
            If File$
              MessageRequester("Information", "Selected File: "+File$, 0)
            EndIf
                       
          Case 3
;            ProcessId.l
;            ExitCode.l
;            hWindow = FindWindow_(0, WindowTitle)
;            GetWindowThreadProcessId_(hWindow, @ProcessId)
;            hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #TRUE, ProcessId)
;            GetExitCodeProcess_(hProcess, @ExitCode)
;            TerminateProcess_(hProcess, ExitCode)
             End
             
        EndSelect
    EndIf
    
    If EventID = #PB_EventGadget
      Select EventGadgetID()
      
        Case 2
          Radius$=GetGadgetText(4)
          Radius=Val(Radius$)
          Radius=Radius-5
          Radius$=Str(Radius)
          SetGadgetText(4, Radius$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 3
          Radius$=GetGadgetText(4)
          Radius=Val(Radius$)
          Radius=Radius-1
          Radius$=Str(Radius)
          SetGadgetText(4, Radius$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
      
        Case 5
          Radius$=GetGadgetText(4)
          Radius=Val(Radius$)
          Radius=Radius+1
          Radius$=Str(Radius)
          SetGadgetText(4, Radius$)
   
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 6
          Radius$=GetGadgetText(4)
          Radius=Val(Radius$)
          Radius=Radius+5
          Radius$=StrF(Radius)
          SetGadgetText(4, Radius$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 8
          Speed$=GetGadgetText(10)
          Speed=ValF(Speed$)
          Speed=Speed-0.000005
          Speed$=StrF(Speed)
          SetGadgetText(10, Speed$) 
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 9
          Speed$=GetGadgetText(10)
          Speed=ValF(Speed$)
          Speed=Speed-0.000001
          Speed$=StrF(Speed)
          SetGadgetText(10, Speed$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 11
          Speed$=GetGadgetText(10)
          Speed=ValF(Speed$)
          Speed=Speed+0.000001
          Speed$=StrF(Speed)
          SetGadgetText(10, Speed$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 12
          Speed$=GetGadgetText(10)
          Speed=ValF(Speed$)
          Speed=Speed+0.000005
          Speed$=StrF(Speed)
          SetGadgetText(10, Speed$)

          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf

        Case 14
          Gravity$=GetGadgetText(16)
          Gravity=Val(Gravity$)
          Gravity=Gravity-5
          Gravity$=Str(Gravity)
          SetGadgetText(16, Gravity$)

          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
         
        Case 15
          Gravity$=GetGadgetText(16)
          Gravity=Val(Gravity$)
          Gravity=Gravity-1
          Gravity$=Str(Gravity)
          SetGadgetText(16, Gravity$)        
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 17
          Gravity$=GetGadgetText(16)
          Gravity=Val(Gravity$)
          Gravity=Gravity+1
          Gravity$=Str(Gravity)
          SetGadgetText(16, Gravity$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 18
          Gravity$=GetGadgetText(16)
          Gravity=Val(Gravity$)
          Gravity=Gravity+5
          Gravity$=Str(Gravity)
          SetGadgetText(16, Gravity$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 20
          Velocity$=GetGadgetText(22)
          Velocity=Val(Velocity$)
          Velocity=Velocity-5
          Velocity$=Str(Velocity)
          SetGadgetText(22, Velocity$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 21
          Velocity$=GetGadgetText(22)
          Velocity=Val(Velocity$)
          Velocity=Velocity-1
          Velocity$=Str(Velocity)
          SetGadgetText(22, Velocity$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 23
          Velocity$=GetGadgetText(22)
          Velocity=Val(Velocity$)
          Velocity=Velocity+1
          Velocity$=Str(Velocity)
          SetGadgetText(22, Velocity$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 24
          Velocity$=GetGadgetText(22)
          Velocity=Val(Velocity$)
          Velocity=Velocity+5
          Velocity$=Str(Velocity)
          SetGadgetText(22, Velocity$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 26
          Chaos$=GetGadgetText(28)
          Chaos=Val(Chaos$)
          Chaos=Chaos-5
          Chaos$=Str(Chaos)
          SetGadgetText(28, Chaos$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 27
          Chaos$=GetGadgetText(28)
          Chaos=Val(Chaos$)
          Chaos=Chaos-1
          Chaos$=Str(Chaos)
          SetGadgetText(28, Chaos$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 29
          Chaos$=GetGadgetText(28)
          Chaos=Val(Chaos$)
          Chaos=Chaos+1
          Chaos$=Str(Chaos)
          SetGadgetText(28, Chaos$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 30
          Chaos$=GetGadgetText(28)
          Chaos=Val(Chaos$)
          Chaos=Chaos+5
          Chaos$=Str(Chaos)
          SetGadgetText(28, Chaos$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
                           
        Case 32
          Life$=GetGadgetText(34)
          Life=Val(Life$)
          Life=Life-5
          Life$=Str(Life)
          SetGadgetText(34, Life$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf  
        
        Case 33
          Life$=GetGadgetText(34)
          Life=Val(Life$)
          Life=Life-1
          Life$=Str(Life)
          SetGadgetText(34, Life$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 35
          Life$=GetGadgetText(34)
          Life=Val(Life$)
          Life=Life+1
          Life$=Str(Life)
          SetGadgetText(34, Life$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 36
          Life$=GetGadgetText(34)
          Life=Val(Life$)
          Life=Life+5
          Life$=Str(Life)
          SetGadgetText(34, Life$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 38
          Emissions$=GetGadgetText(40)
          Emissions=Val(Emissions$)
          Emissions=Emissions-5
          Emissions$=Str(Emissions)
          SetGadgetText(40, Emissions$) 
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf 
        
        Case 39
          Emissions$=GetGadgetText(40)
          Emissions=Val(Emissions$)
          Emissions=Emissions-1
          Emissions$=Str(Emissions)
          SetGadgetText(40, Emissions$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 41
          Emissions$=GetGadgetText(40)
          Emissions=Val(Emissions$)
          Emissions=Emissions+1
          Emissions$=Str(Emissions)
          SetGadgetText(40, Emissions$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 42
          Emissions$=GetGadgetText(40)
          Emissions=Val(Emissions$)
          Emissions=Emissions+5
          Emissions$=Str(Emissions)
          SetGadgetText(40, Emissions$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 44
          Frequency$=GetGadgetText(46)
          Frequency=Val(Frequency$)
          Frequency=Frequency-5
          Frequency$=Str(Frequency)
          SetGadgetText(46, Frequency$) 
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf 
        
        Case 45
          Frequency$=GetGadgetText(46)
          Frequency=Val(Frequency$)
          Frequency=Frequency-1
          Frequency$=Str(Frequency)
          SetGadgetText(46, Frequency$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 47
          Frequency$=GetGadgetText(46)
          Frequency=Val(Frequency$)
          Frequency=Frequency+1
          Frequency$=Str(Frequency)
          SetGadgetText(46, Frequency$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 48
          Frequency$=GetGadgetText(46)
          Frequency=Val(Frequency$)
          Frequency=Frequency+5
          Frequency$=Str(Frequency)
          SetGadgetText(46, Frequency$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 50
          Depth$=GetGadgetText(52)
          Depth=ValF(Depth$)
          Depth=Depth-0.1
          Depth$=StrF(Depth)
          SetGadgetText(52, Depth$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf  
        
        Case 51
          Depth$=GetGadgetText(52)
          Depth=ValF(Depth$)
          Depth=Depth-0.01
          Depth$=StrF(Depth)
          SetGadgetText(52, Depth$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 53
          Depth$=GetGadgetText(52)
          Depth=ValF(Depth$)
          Depth=Depth+0.01
          Depth$=StrF(Depth)
          SetGadgetText(52, Depth$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 54
          Depth$=GetGadgetText(52)
          Depth=ValF(Depth$)
          Depth=Depth+0.1
          Depth$=StrF(Depth)
          SetGadgetText(52, Depth$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 56
          Height$=GetGadgetText(58)
          Height=ValF(Height$)
          Height=Height-0.1
          Height$=StrF(Height)
          SetGadgetText(58, Height$)  
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 57
          Height$=GetGadgetText(58)
          Height=ValF(Height$)
          Height=Height-0.01
          Height$=StrF(Height)
          SetGadgetText(58, Height$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 59
          Height$=GetGadgetText(58)
          Height=ValF(Height$)
          Height=Height+0.01
          Height$=StrF(Height)
          SetGadgetText(58, Height$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 60
          Height$=GetGadgetText(58)
          Height=ValF(Height$)
          Height=Height+0.1
          Height$=StrF(Height)
          SetGadgetText(58, Height$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
                             
        Case 62
          Width$=GetGadgetText(64)
          Width=ValF(Width$)
          Width=Width-0.1
          Width$=StrF(Width)
          SetGadgetText(64, Width$)  
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 63
          Width$=GetGadgetText(64)
          Width=ValF(Width$)
          Width=Width-0.01
          Width$=StrF(Width)
          SetGadgetText(64, Width$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 65
          Width$=GetGadgetText(64)
          Width=ValF(Width$)
          Width=Width+0.01
          Width$=StrF(Width)
          SetGadgetText(64, Width$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
        
        Case 66
          Width$=GetGadgetText(64)
          Width=ValF(Width$)
          Width=Width+0.1
          Width$=StrF(Width)
          SetGadgetText(64, Width$)
          
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 67        
          file.s="System/refresh.dat"
          If CreateFile(0,file.s)
            CloseFile(0)
          EndIf
          
        Case 68
          File2.s = OpenFileRequester("Particles - Open", "C:\", "Bitmap (*.bmp)|*.bmp", 0)
          If File2.s+File2.s
            LoadImage(0,File2.s)         
            If ImageHeight()<32 Or ImageWidth()<32
              MessageRequester("Particles - Error!", "The Image "+File2.s+" is either not tall or not wide enough!", #PB_MessageRequester_Ok)
              small=1
              FreeImage(UseImage(0))
            EndIf
            If ImageHeight()>32 Or ImageWidth()>32
              MessageRequester("Particles - Error!", "The Image "+File2.s+" is either too wide or too tall!", #PB_MessageRequester_Ok)
              big=1
              FreeImage(UseImage(0))
            EndIf                     
            If small=0 And big=0
              SetGadgetState(77,UseImage(0))

              file.s = "System/Update.dat"
              OpenFile(0,file.s)
                WriteStringN(GetGadgetText(4))
                WriteStringN(GetGadgetText(10))
                WriteStringN(GetGadgetText(16))
                WriteStringN(GetGadgetText(22))
                WriteStringN(GetGadgetText(28))
                WriteStringN(GetGadgetText(34))
                WriteStringN(GetGadgetText(40))
                WriteStringN(GetGadgetText(46))
                WriteStringN(GetGadgetText(52))
                WriteStringN(GetGadgetText(58))
                WriteStringN(GetGadgetText(64))
                WriteStringN(Str(GetGadgetState(67)))
                WriteStringN(Str(GetGadgetState(70)))
                WriteStringN(Str(GetGadgetState(71)))
                path.s=GetPathPart(File2.s)
                WriteStringN(path.s)
                part.s=GetFilePart(File2.s)
                WriteStringN(part.s)
              CloseFile(0)  
                          
              file.s="System/refresh.dat"
              If CreateFile(0,file.s)
                CloseFile(0)
              EndIf
              
            EndIf
            big=0
            small=0           
          EndIf
         
        Case 69
          ColorRequester()
                                                         
      EndSelect   
    EndIf
       
    Floor=GetGadgetState(67)
    Image=GetGadgetState(70)

    Radius$=GetGadgetText(4)
    Radius=Val(Radius$)
  
    Speed$=GetGadgetText(10)
    Speed=ValF(Speed$)
          
    Gravity$=GetGadgetText(16)
    Gravity=Val(Gravity$)
 
    Velocity$=GetGadgetText(22)
    Velocity=Val(Velocity$)

    Chaos$=GetGadgetText(28)
    Chaos=Val(Chaos$)
          
    Life$=GetGadgetText(34)
    Life=Val(Life$)
          
    Emissions$=GetGadgetText(40)
    Emissions=Val(Emissions$)
       
    Frequency$=GetGadgetText(46)
    Frequency=Val(Frequency$)
          
    Depth$=GetGadgetText(52)
    Depth=ValF(Depth$)
          
    Height$=GetGadgetText(58)
    Height=ValF(Height$)

    Width$=GetGadgetText(64)
    Width=ValF(Width$)
       
   Until EventID = #PB_EventCloseWindow
   
;   ProcessId.l
;   ExitCode.l
;   hWindow = FindWindow_(0, WindowTitle)
;   GetWindowThreadProcessId_(hWindow, @ProcessId)
;   hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #TRUE, ProcessId)
;   GetExitCodeProcess_(hProcess, @ExitCode)
;   TerminateProcess_(hProcess, ExitCode)

EndIf
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

OH! and I can't start another program from the outside with that code that will allow the opened program to react normally (read/write to .dat files)... I didn't want to make a parser so I'm using .dat files to talk between PB and DBPro...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> ProgramName.s = "System/Particles.exe"

Windows uses backslashes, not forward slashes, for paths. Observe:

Code: Select all

Debug GetPathPart("c:/winnt/calc.exe") ; Fails.
Debug GetPathPart("c:\winnt\calc.exe") ; Succeeds.
Maybe that's the cause of your problem?

Also, what does o_O mean?
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

o=small eye... _=mouth... O=big eye... O_O its a face... ^_^ get it?
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

=P well that didnt really fix anything... still same bugs... but at least I now have correct syntax ;)...
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

I fixed the ones with noi.s and nop.s o_O but I'm still having problems with the string saving...
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

$ and .s ...

Post by WolfgangS »

I saw you mix up ".s" and $. ".s" and $ is NOT the same.

Code: Select all

a.s="sepp"
debug a$
MFG
WolfgangS
Last edited by WolfgangS on Tue Apr 29, 2003 4:17 am, edited 1 time in total.
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

WOLFGANG!!!... o_O I did... eck... Ill do a replace thingy real quick and test...
DarthPuff
User
User
Posts: 47
Joined: Sat Apr 26, 2003 2:51 am
Location: USA
Contact:

Post by DarthPuff »

Nope... still has the bug...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> still has the bug...

What does File2.s hold just before you use GetPathPart and GetFilePart?

The thing is, the following code works 100% correctly so this proves that
the GetPathPart and GetFilePart commands are NOT to blame, leading me
to believe that File2.s holds some weird string, or perhaps WriteStringN is
causing the problem.

Code: Select all

file$="c:\winnt\calc.exe" 
Debug GetPathPart(file$) ; Returns c:\winnt\
Debug GetFilePart(file$) ; Returns calc.exe
Post Reply