I am not able to translate a simple program

Discussion in 'Questions (Windows Mobile)' started by laurafelea, Dec 13, 2007.

  1. laurafelea

    laurafelea New Member Licensed User

    :sign0085:

    Can help me to translate this simple program write in qbasic ,to basic4ppc to work in smartphone ?
    There is a big speak of smarthone compatibility of version 5.80 of basic4ppc ,but I have seen
    any simple example of source code . I am in difficulty because as we read in main help of basic4ppc
    "The following controls are not supported for smartphone :
    · Button· Calendar· ImageButton· ListBox· NumUpDown· SaveDialog
    The following external controls (available in the ControlsEx library) are not supported:
    · ContextMenu· TabControl· ToolBar· TrackBar
    · TreeView with checkboxes is not supported (TreeView without checkboxes is supported)."
    The very simple program is:

    --------------------------------------------------------
    DIM A(2,4) // IT CREATES AN ARRAY 2X4
    DIM B(2,4) // THE SAME FOR B()

    DATA 1,2,3,4 // MY DATA IS DIFFERENT ,IS AN EXAMPLE!
    DATA 5,6,7,8 // MY DATA

    FOR K = 1 TO 2 // FILL THE ARRAY "A" WITH 1,2,3,4
    // 5,6,7,8
    FOR J = 1 TO 4

    READ A(K,J)
    NEXT J
    NEXT K

    CONT = 0 // THE COUNTER = 0

    START:
    CONT = CONT +1 // IT INCREASE THE COUNTER
    IF CONT = 5 THEN END // WHEN THE ARRAY IS FULL THE PROGRAM STOP

    INPUT NUMBER // THE USER INSERT A RANDOM NUMBER

    FOR K = 1 TO 2
    B(K,CONT) = NUMBER XOR NOT A(K,CONT) XOR NOT 1

    /* BOLEAN XNOR OF THE RANDOM NUMBER WITH THE FIRST COLUMN OF ARRAY "A" ; "XOR NOT 1 " IS INSERT TO CORRECT THE RESULT ;
    THE RESULT GO TO THE CORRESPONDENT LOCATION OF ARRAY "B" */

    NEXT K



    CLS

    PRINT B(1, CONT) ; B(2,CONT)
    //DISPLAY THE RESULT COLUMN OF "B"

    GOTO START

    /*HERE I WANT A "GOTO START" INSTEAD OF FOR-NEXT LOOP BECAUSE IN THE REAL PROGRAMM THERE IS MORE CODE THAT I HAVE NOT INSERT HERE IN THIS EXAMPLE , ... START AGAIN TO INSERT A NEW RANDOM NUMBER BY THE USER ,UNTIL THE PROGRAM STOP */

    --------------------------------------------------------------
    I ALSO CAN PAY IF SOMEONE CAN HELP ME
    excuse me for the english , I am italian !
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The unsupported controls are not supported by the Smartphone OS (not Basic4ppc).

    I've attached a translation of your code.
    Note that arrays begin from 0 and not 1 in Basic4ppc.
    This is the code:
    Code:
    Sub Globals
        
    'Declare the global variables here.
        Dim a(2,4),b(2,4),data(8)
        cont = -
    1
    End Sub

    Sub App_Start
        Form1.Show
        data() = StrSplit(
    "1,2,3,4,5,6,7,8",",")
        i = 
    0
        
    For k = 0 To 1
            
    For j = 0 To 3
                a(k,j) = data(i)
                i=i+
    1
            
    Next
        
    Next
        
    bit.New1
        txtInput.Focus
    End Sub

    Sub mnuGo_Click
        cont = cont + 
    1
        
    If cont = 4 Then
            txtInput.Enabled = 
    false
            mnuGo.Enabled = 
    false
            
    Return
        
    End If
        
    For k = 0 To 1
            b(k,cont) = 
    bit.XOR(bit.XOR(txtInput.Text,bit.Complement(a(k,cont))),bit.Complement(1))
        
    Next
        txtOutput.Text = b(
    0,cont) & " , " & b(1,cont)
    End Sub

    Sub mnuQuit_Click
        AppClose
    End Sub
     

    Attached Files:

  3. laurafelea

    laurafelea New Member Licensed User

    thank you Erel

    Thanks Erel , Now I Test The Code With My Additions :)
     
Loading...