maybe a stupid question,but...

Discussion in 'Questions (Windows Mobile)' started by Cableguy, Jun 15, 2007.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi,

    Maybe is because I haven't been using b4ppc for the past 2 weeks or so but, how do I reference a string variable in this case?

    file1="myfile.txt"
    file2="second.png"
    file.........
    file20="lastfile.doc"
    for x = 1 to 20
    if file exist(???)=false then message the user......
    Next x

    How do I reference the file & x in this case?

    I've tryed If fileexist(file & x) but it doesn't compute....
     
  2. Cableguy

    Cableguy Expert Licensed User

    OK I've got it to work..using an array, as I problably should have done to start of..But at the end of the for next loop i keep getting a " out of boudaries" error...

    Here's the entire code...

    Code:
    Sub Globals
    dim file(6)
    End Sub

    Sub App_Start
       Main.Show
       CheckFiles
       
    SIP(False)
    End Sub

    Sub CheckFiles
    File(0)="Pairs v2.ini"
    File(1)="1.png"
    File(2)="2.png"
    File(3)="3.png"
    File(4)="4.png"
    File(5)="5.png"
    For x = 0 to arraylen(File())
       
    If FileExist(File(x))= true Then
          
    MsgBox(File(x))
       
    else
          
    Msgbox(file(x) & " is missing")
       
    end if
    Next x 
    End sub

    EDIT:

    I found my error...forgot to ad the "-1" in the "for x = 0 to arraylen(file())" line...

    As i said, This could and was a "stupid" question....:sign0013::sign0137:

    BTW: I plan to use these subs to check the integrety of my app, so that if some file is missing, the app will not run at all...Not a piracy protection but more of a "error free" thing...I also plan to generate a log if the app does not start to list the missing file... this way will be easyer to debug.
     
    Last edited: Jun 15, 2007
  3. specci48

    specci48 Well-Known Member Licensed User

    Hi Cableguy,

    the length of the file array is 6 because there are 6 entries.
    To access all of them your loop should go form zero to 5

    Code:
    For x = 0 to arraylen(File()) - 1

    specci48


    Sorry but I just missed your own correction...
     
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Sorry mate but I wasn't around earlier other wise I would have said that you probably needed to enclose the word file with quotation marks.

    If fileexist("file" & x)

    But I see that you and Specci48 have sorted it now ;)

    Regards,
    RandomCoder
     
  5. Rioven

    Rioven Active Member Licensed User

    Hi Guys! since I'm still learning...can we use imagelist.Item(i)="1.jpg" ?
     
  6. Rioven

    Rioven Active Member Licensed User

    sorry guys, i'm off topic here, this is can only be use for images...
     
  7. RandomCoder

    RandomCoder Well-Known Member Licensed User

    You can indeed use the above statement.

    Regards,
    RandomCoder
     
  8. Peter

    Peter Member Licensed User

    There are no stupid questions, CableGuy, only stupid persons :D (who fail to ask questions)
     
Loading...