Why can't I start Purebasic with RunProgram()?

Just starting out? Need help? Post your questions and find answers here.
Micoute
User
User
Posts: 28
Joined: Sat Jun 22, 2013 4:06 pm
Location: La Mézière FRANCE

Why can't I start Purebasic with RunProgram()?

Post by Micoute »

I used to be able to launch Purebasic by clicking on a button, but since version 6.03 this no longer works.
What should I do to get it working again?

Code: Select all

;Mes Applis Btn RBUTTON
;{ Fichiers inclus
XIncludeFile "D:\Programmation\Prg Perso\B\Boutons\RButton\RButton.pb"
XIncludeFile #PB_Compiler_FilePath + "Donnees mes applis.pb"
;}
;{ Enumérations
Enumeration Fenetre
  #Fenetre_principale
EndEnumeration

Enumeration Gadgets
  #Btn_0
EndEnumeration
;}
;{ Structure
Structure  Donnee
  Titre.s
  Adresse.s
  Icone.s
EndStructure 
;}
;{ Variables
Global.s Rep$ = GetPathPart(ProgramFilename()) : SetCurrentDirectory(Rep$)
Global.Donnee NewList Donnee()
Global.i X, Y, i, Quitter, Evenement, Couleur
Global.i LigBtns = 5, ColBtns = 24, HtBtn = 15*2, LgBtn = 150*2
Global.i Nb_par_Colonne = HtBtn * ColBtns, Lfen = LgBtn * LigBtns
Global NomPolice.s = "Calibri", TaillePolice = 10*1.4
;}
Procedure r(i, j)
  ProcedureReturn Random(i, j)
EndProcedure
Procedure ps(f, p)
  SetSoundFrequency(0, f)
  SoundPan(0, p)
  PlaySound(0)
EndProcedure
InitSound()
CatchSound(0, ?Son)
SoundVolume(0, 30)
Procedure Initialisation()
  Protected.s Titre, Adresse, Icone
  Restore Donnees
  i = 0
  While Titre <> "999" And Adresse <> "999"
    Read.s Titre
    Read.s Adresse
    Read.s Icone
    AddElement(Donnee())
    Donnee()\Titre = Titre
    Donnee()\Adresse = Adresse
    i + 1
  Wend
  DeleteElement(Donnee())
  SortStructuredList(Donnee(), #PB_Sort_Ascending, OffsetOf(Donnee\Titre),#PB_String)
  
  i - 1
  Debug i
  
  Global.i NbBtn =  ListSize(Donnee()) - 1
  Global Dim Tableau.s(1, NbBtn)
  
  i = 0
  ForEach Donnee()
    If Left(Donnee()\Titre, 1) = "0" Or Left(Donnee()\Titre, 1) = "1"
      Donnee()\Titre = Right(Donnee()\Titre, Len(Donnee()\Titre) - 3)
    EndIf
    Tableau(0,i) = Donnee()\Titre
    Tableau(1,i) = Donnee()\Adresse
    i+1
  Next
EndProcedure 
Procedure Programme_principal()
  
  If OpenWindow(#Fenetre_principale, 0, 0, Lfen + 20, Nb_par_Colonne + 20, 
                "Mes Applications © Micoute 15/08/2022", 
                #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    SetWindowColor(#Fenetre_principale, $DECFF2)
    SetWindowLong_(WindowID(#Fenetre_principale), #GWL_EXSTYLE, GetWindowLong_(WindowID(#Fenetre_principale), #GWL_EXSTYLE) | $00080000) ; #WS_EX_LAYERED = $00080000
    SetLayeredWindowAttributes_(WindowID(#Fenetre_principale), 0, 250, 2) 
    
    Police = LoadFont(#PB_Any, NomPolice, TaillePolice, #PB_Font_Bold)
    SetGadgetFont(#PB_Default, FontID(Police)) ;Affecter la Police à tous les gadgets
    
    ;Créons nos boutons
    For i = 0 To NbBtn
      Couleur = RGB(Random(255,127),Random(255,127),Random(255,127)) ;Création de la couleur du bouton i
      Y = Mod(i * HtBtn, Nb_par_Colonne)                             ;Position de la ligne du bouton i
      X = (i * HtBtn) / (Nb_par_Colonne)                             ;Position de la colonne du bouton i
      RBUTTON(i, Tableau(0, i), 10+X*LgBtn, 10+Y, LgBtn, HtBtn, FontID(Police), 0, Couleur, HtBtn/2)
    Next    
  EndIf
EndProcedure
Initialisation()
Programme_principal()
;{- Boucle d'évènements
Quitter.i = #False

Repeat
  Evenement = WaitWindowEvent()
  
  If Evenement = #PB_Event_Gadget
    For i = 0 To ListSize(Donnee())
      If EventType() = #PB_EventType_LeftClick
        If EventGadget() = i
          PlaySound(0)
          RunProgram(Tableau(1, i))      
        EndIf
      EndIf
    Next
  EndIf
  
Until Quitter = #True
End
;}
;{ Données
DataSection
  son:
  IncludeBinary "D:\Programmation\Prg Perso\S\Sons\Bruits\Clic.wav"
  FinSon:
EndDataSection
;}
Last edited by Micoute on Mon Sep 18, 2023 12:01 pm, edited 1 time in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1523
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Why can't I start Purebasic with RunProgram()?

Post by NicTheQuick »

What button?
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
BarryG
Addict
Addict
Posts: 4178
Joined: Thu Apr 18, 2019 8:17 am

Re: Why can't I start Purebasic with RunProgram()?

Post by BarryG »

Maybe he means to start compiling? Not sure.
User avatar
Kiffi
Addict
Addict
Posts: 1504
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Why can't I start Purebasic with RunProgram()?

Post by Kiffi »

Micoute wrote: Mon Sep 18, 2023 8:22 amWhat should I do to get it working again?
The very first thing you should do is post your code, because we don't all have a crystal ball.
Hygge
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: Why can't I start Purebasic with RunProgram()?

Post by juergenkulow »

Code: Select all

/VERSION
PureBasic IDE 6.03 beta 8 LTS [devel; 8faab0468c56; 14-09-2023] - (c) 2023 Fantaisie Software
H:\OldPB\PureBasic\603Beta8x86\PureBasic.exe Runtime:44 ms
Please ask your questions, because switch on the cognition apparatus decides on the only known life in the universe.Wersten :DDüsseldorf NRW Germany Europe Earth Solar System Flake Bubble Orionarm
Milky Way Local_Group Virgo Supercluster Laniakea Universe
Micoute
User
User
Posts: 28
Joined: Sat Jun 22, 2013 4:06 pm
Location: La Mézière FRANCE

Re: Why can't I start Purebasic with RunProgram()?

Post by Micoute »

Code sent to first post
User avatar
Kiffi
Addict
Addict
Posts: 1504
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Why can't I start Purebasic with RunProgram()?

Post by Kiffi »

Code: Select all

[...]
        If EventGadget() = i
          PlaySound(0)
          RunProgram(Tableau(1, i))      
        EndIf
[...]

Code: Select all

[...]
        If EventGadget() = i
          PlaySound(0)
          Debug Tableau(1, i) ; <--
          RunProgram(Tableau(1, i))      
        EndIf
[...]
can you post what the debugger prints here?
Hygge
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Why can't I start Purebasic with RunProgram()?

Post by Demivec »

I don't know if this is the source of your error but if it isn't it should still be corrected.

Code: Select all

Procedure Initialisation()
  Protected.s Titre, Adresse, Icone
  Restore Donnees 
  ;----snipped code
EndProcedure 

;--- snipped code

;{ Données
DataSection
  son:
  IncludeBinary "D:\Programmation\Prg Perso\S\Sons\Bruits\Clic.wav"
  FinSon:
EndDataSection
;}
You use Restore Donnees but don't have a label Donnees in your program. It should be placed inside the DataSection before your data.
Olli
Addict
Addict
Posts: 1242
Joined: Wed May 27, 2020 12:26 pm

Re: Why can't I start Purebasic with RunProgram()?

Post by Olli »

Hello micoute !

I hope you are fine !
For your 50 years of coding, I add this suggestion :

I think also you should let between 500 and 1000 ms to the client program in RunProgram() with a Delay().

Code: Select all

RunProgram(myProg$)
Delay(500)
I said the world << also >> because no other advice cannot be excluded.

Here, you request to run a complex program (which opens a piped sub-client program, allocates good part of memory, uses preferences files, etc... ) which need not to be executed 100 times per second, so, you should let a wait duration.

Hoping there is not a collision between the preferences files.
Post Reply