Page 1 of 1

Catalog Problems

Posted: Tue Aug 20, 2024 7:28 pm
by SpawnPPC
Hi to all !

I just done a little program that recognize the system language and try to select and open the correct catalog, in this case italian.

I think that there is some problems with the file becouse the program give the correct results in debug shell.

The error is:

Cannot open the catalog file

The directory tree is this one:

AmiWORP-Gate/Catalogs/italian/AmiWORP-Gate.catalog

This is the catalog content (Hollywood version, normal text UTF-8 format) without minus ofc:
----------------------------
Errore: l'eseguibile deve essere nella cartella AmiWORP-Gate !!!

Il programma si chiuderà in:

secondi

secondo

Abbiamo rilevato che la lingua di sistema è impostata su:

Confermi l'uso di questa lingua?

Vuoi cambiare la lingua?
----------------------------



The editor's text is this:
----------------------------
Function LinguaDefault()
; Rileva la lingua di sistema
SystemLang = GetSystemLanguage()
SystemLangInfo = GetLanguageInfo(SystemLang)
DebugPrint("Lingua di sistema rilevata: " .. SystemLangInfo.Name .. " (" .. SystemLangInfo.Code .. ")")

; Costruisci il percorso del catalogo in base alla lingua di sistema
catalogPath$ = "Catalogs/" .. SystemLangInfo.Name .. "/AmiWORP-Gate.catalog"
DebugPrint("Percorso del catalogo: " .. catalogPath$)

; Verifica se il catalogo esiste
If Exists(catalogPath$)
DebugPrint("Catalogo trovato. Provo ad aprirlo...")

; Tenta di aprire il catalogo
If OpenCatalog("AmiWORP-Gate.catalog") = True
DebugPrint("Catalogo aperto con successo.")
Else
DebugPrint("Impossibile aprire il catalogo.")
EndIf
Else
DebugPrint("Catalogo non trovato.")
EndIf
EndFunction

Function Main()
DebugPrint("Avvio del programma...")

; Esegui la funzione per selezionare la lingua
LinguaDefault()

; Ottieni la directory corrente
RootDir$ = GetCurrentDirectory()
DebugPrint("Directory corrente: " .. RootDir$)

; Verifica se la directory corrente termina con "AmiWORP-Gate"
ExpectedDir$ = "AmiWORP-Gate"
ActualDirEnd$ = RightStr(RootDir$, StrLen(ExpectedDir$))

If ActualDirEnd$ = ExpectedDir$
DebugPrint("La directory corrente è corretta.")
RootDirEsito = True
Else
DebugPrint("La directory corrente NON è corretta.")
RootDirEsito = False
EndIf

; Se la directory non è corretta, mostra un messaggio di errore
If Not RootDirEsito
; Creazione del display per il messaggio di errore
CreateDisplay(2, {Width = 640, Height = 480, Title = "Errore di Directory"})
DebugPrint("Display creato per il messaggio di errore.")

; Mostra il messaggio di errore all'utente
TextOut(#CENTER, #CENTER - 20, "Errore: l'eseguibile deve essere nella cartella AmiWORP-Gate.")
TextOut(#CENTER, #CENTER, "Il programma si chiuderà in:")
DebugPrint("Messaggio di errore mostrato.")

; Avvia un conto alla rovescia
For i = 5 To 1 Step -1
; Cancella l'intera area del testo precedente
SetFillStyle(#FILLCOLOR)
Box(#CENTER, #CENTER + 30, 100, 40, #BLACK)

; Scrivi il countdown
TextOut(#CENTER, #CENTER + 20, i)

; Modifica la scritta "secondi" o "secondo" in base al valore di i
If i = 1
TextOut(#CENTER, #CENTER + 40, "secondo")
Else
TextOut(#CENTER, #CENTER + 40, "secondi")
EndIf

Wait(50)
Next

; Chiudi il display e termina il programma
FreeDisplay(2)
End
EndIf

DebugPrint("Fine del controllo della cartella di root.")
EndFunction

; Avvio del programma principale
Main()
----------------------------

Any idea ?

Thanx to all !

bySpawnPPC

Re: Catalog Problems

Posted: Tue Aug 20, 2024 7:52 pm
by plouf
i guess wrong in your code :)
provide at LEAST SOME code
Also have you try with .exe ? final exe and compile-run may have difirent paths
Also what os ? shall i guess Morphos?

in my understang your OpenCatalog()
is like this ??

Code: Select all

OpenCatalog("PROGDIR:Catalogs/italian/AmiWORP-Gate.catalog")

Re: Catalog Problems

Posted: Wed Aug 21, 2024 12:02 am
by SpawnPPC
Sorry, but do you read my message ? PLS, ready my message. And OS actually is Windows 11.

Thanx !

bySpawnPPC

Re: Catalog Problems

Posted: Wed Aug 21, 2024 6:28 am
by plouf
ok i apologize for this, these italian text make me thouht that was all the catalog from there to bottom :)

you problem is that OpenCatalog() do NOT return nothing so

Code: Select all

If OpenCatalog("AmiWORP-Gate.catalog") = True
never get true even if the catalog is already opened :)

Re: Catalog Problems

Posted: Wed Aug 21, 2024 8:02 am
by SpawnPPC
Ok, I understand, thanks, but then I wonder how can I check that the catalog has actually been opened? Is there a way to check if the catalog has been opened correctly? Thanks!!!

Re: Catalog Problems

Posted: Wed Aug 21, 2024 8:04 am
by plouf
What if the first line in every catalog is the word "yes"
So check against firat line?

Re: Catalog Problems

Posted: Wed Aug 21, 2024 7:04 pm
by SpawnPPC
Good idea ! I Will try ! Thanx !

Re: Catalog Problems

Posted: Thu Aug 22, 2024 2:11 am
by SpawnPPC
It works !!! It works !!!

Thanx my friend !!!

:D

bySpawnPPC