Italian Circa i progetti B4XPages

XorAndOr

Active Member
Licensed User
Longtime User
Buongiorno. Qualcuno mi potrebbe dire perchè quando lo avvio mi esce la schermata di errore?
Grazie
se ti riferisci all'esempio di giannimaione:
commenta questa riga in alto in b4xmainpage
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
oppure crea la cartella shared file
 

LucaMs

Expert
Licensed User
Longtime User
Hai ragione (come sempre)
era riferito all'esempio di erel in b4j
mio caso è B4A
B4X:
StartActivity(StartPage)
Non serve avviare Activity.
Fai come suggerito da @udg, usa un panel (pnlSplash) nel layout della B4XMainPage (coi miei suggerimenti preDecenti 😊) e magari usa quest'ultima per registrazione/login. Una seconda pagina come menu principale, che aprirai con B4XPages.ShowPageAndRemovePreviousPages (o B4XPages.ShowPage)
 

XorAndOr

Active Member
Licensed User
Longtime User
Non serve avviare Activity.
Fai come suggerito da @udg, usa un panel (pnlSplash) nel layout della B4XMainPage (coi miei suggerimenti preDecenti 😊) e magari usa quest'ultima per registrazione/login. Una seconda pagina come menu principale, che aprirai con B4XPages.ShowPageAndRemovePreviousPages (o B4XPages.ShowPage)
Provo-lo :) ty
 

XorAndOr

Active Member
Licensed User
Longtime User
Volendo si potrebbe mettere la xivSplash direttamente nel Root, senza il pnlSplash (e quindi senza la routine Touch di quest'ultimo).
Però se l'immagine fosse una png trasparente, si vedrebbe quanto sottostante (a meno che non cambi il background della B4XImageView, che io ho impostato come trasparente nel Designer).
capito
Cmq và bene anche col panel. ty
 

LucaMs

Expert
Licensed User
Longtime User
1700356716294.png



1700356756872.png



Eccetera.

Pigrone d'un ChatGPT 😄

Meglio, va, significa che i programmatori servono ancora; per il momento!
 

LucaMs

Expert
Licensed User
Longtime User
In "compenso", in meno di mezzo secondo ha elaborato e poi scritto quanto segue:

1700357777436.png


(Ogni volta mi spiega cosa siano B4X e Anywhere Software 😄)

1700357905770.png



Sorgente che ancora non ho esaminato:

B4X:
' ** B4XPage - RegistrationPage **

#Region Project Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

'Include B4XEncryption library for encryption functions
#if B4A
    #AdditionalJar: B4XEncryption.jar
#else if B4i
    #AdditionalLib: B4XEncryption
#else if B4J
    #AdditionalJar: B4XEncryption.jar
#end if

'Class module for handling registration logic
Sub Process_Globals
    Private Page As B4XPage
    Private edtUsername, edtPassword, edtConfirmPassword As B4XFloatTextField
    Private btnRegister As B4XButton
End Sub

Public Sub Initialize
    Page.Initialize("Page")
    Page.Title = "Registration"
    Page.RootPanel.LoadLayout("RegistrationLayout")
    'Initialize other components and set event handlers as needed
End Sub

Public Sub Show
    Page.Show
End Sub

'Event handler for the registration button
Sub btnRegister_Click
    Dim username As String = edtUsername.Text.Trim
    Dim password As String = edtPassword.Text
    Dim confirmPassword As String = edtConfirmPassword.Text

    'Perform validation checks
    If username = "" Then
        'Username is required
        ToastMessageShow("Username is required", True)
        Return
    End If

    If password = "" Then
        'Password is required
        ToastMessageShow("Password is required", True)
        Return
    End If

    If confirmPassword = "" Then
        'Confirm password is required
        ToastMessageShow("Confirm password is required", True)
        Return
    End If

    If password <> confirmPassword Then
        'Passwords do not match
        ToastMessageShow("Passwords do not match", True)
        Return
    End If

    'Encrypt sensitive data (e.g., password) before sending to the server
    Dim encryptedPassword As String = EncryptPassword(password)

    'Send data to the server (you need to implement this part)
    'For example, you can use HttpUtils2 to send a POST request to your server
    'Include relevant server URL and parameters
    'Make sure to handle the server response appropriately

End Sub

'Function to encrypt the password before sending it to the server
Private Sub EncryptPassword(password As String) As String
    'Use B4XEncryption library or your preferred encryption method
    'For example, you can use B4XEncryption library like this:
    Dim encryptor As B4XCipher
    encryptor.Initialize("AES")
    encryptor.Password = "YourEncryptionKey" 'Replace with your encryption key
    Return encryptor.EncryptText(password)
End Sub

1700358017506.png



(Si è capito che ho voglia di "giocare" con ChatGPT?)
 

LucaMs

Expert
Licensed User
Longtime User
1700358286214.png



B4X:
' ** B4XPage - RegistrationPage **

#Region Project Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

'Include B4XEncryption library for encryption functions
#if B4A
    #AdditionalJar: B4XEncryption.jar
#else if B4i
    #AdditionalLib: B4XEncryption
#else if B4J
    #AdditionalJar: B4XEncryption.jar
#end if

'Include B4XSerializator for object serialization
#if B4A
    #AdditionalJar: B4XSerializator.jar
#else if B4i
    #AdditionalLib: B4XSerializator
#else if B4J
    #AdditionalJar: B4XSerializator.jar
#end if

'Class module for handling registration logic
Sub Process_Globals
    Private Page As B4XPage
    Private edtUsername, edtPassword, edtConfirmPassword, edtVerificationCode As B4XFloatTextField
    Private btnRegister, btnSendCode As B4XButton
    Private verificationCode As String
End Sub

Public Sub Initialize
    Page.Initialize("Page")
    Page.Title = "Registration"
    Page.RootPanel.LoadLayout("RegistrationLayout")
    'Initialize other components and set event handlers as needed
    verificationCode = GenerateVerificationCode
End Sub

Public Sub Show
    Page.Show
End Sub

'Event handler for the registration button
Sub btnRegister_Click
    Dim username As String = edtUsername.Text.Trim
    Dim password As String = edtPassword.Text
    Dim confirmPassword As String = edtConfirmPassword.Text
    Dim enteredVerificationCode As String = edtVerificationCode.Text

    'Perform validation checks
    If username = "" Or password = "" Or confirmPassword = "" Or enteredVerificationCode = "" Then
        ToastMessageShow("All fields are required", True)
        Return
    End If

    If password <> confirmPassword Then
        ToastMessageShow("Passwords do not match", True)
        Return
    End If

    If enteredVerificationCode <> verificationCode Then
        ToastMessageShow("Invalid verification code", True)
        Return
    End If

    'Encrypt sensitive data (e.g., password) before sending to the server
    Dim encryptedPassword As String = EncryptPassword(password)

    'Send data to the server (you need to implement this part)
    'For example, you can use HttpUtils2 to send a POST request to your server
    'Include relevant server URL and parameters
    'Make sure to handle the server response appropriately
End Sub

'Event handler for the send code button
Sub btnSendCode_Click
    'Generate a new verification code and send it to the user
    verificationCode = GenerateVerificationCode
    'Send the verification code to the user via email, SMS, or other means
    'Implement your code to send the verification code
    ToastMessageShow("Verification code sent", True)
End Sub

'Function to generate a random verification code
Private Sub GenerateVerificationCode As String
    Dim rnd As Random
    rnd.Initialize
    Dim code As Int = rnd.Next(1000, 9999)
    Return code
End Sub

'Function to encrypt the password before sending it to the server
Private Sub EncryptPassword(password As String) As String
    Dim encryptor As B4XCipher
    encryptor.Initialize("AES")
    encryptor.Password = "YourEncryptionKey" 'Replace with your encryption key
    Return encryptor.EncryptText(password)
End Sub

1700358337270.png
 

LucaMs

Expert
Licensed User
Longtime User
Buongiorno
Mi spiace per ChatGPT ma io preferisco l'esempio del post #24 di @LucaMs
almeno quello è chiaro e funzionante ;).
In effetti, basta dare un'occhiata al codice generato da ChatGPT per accorgersi che non funzionerebbe (al solito, metodi/oggetti inesistenti).

Senza contare che ti dice, giustamente, che il server dovrebbe mandare un codice temporaneo al client (secondo sorgente) ma poi lo fa creare al client stesso!
 

shadow

Active Member
Licensed User
Longtime User
Ciao,
Quando leggo le discussioni in questo forum, mi viene voglia di rispolverare B4A, che non uso da molto tempo... :)
Comunque come sempre vi faccio i miei complimenti, questo è uno dei pochi forum che trovo sempre attivo.
 
Top