Qustion about dilog lib

volvomann

Active Member
Licensed User
Longtime User
Hallo
I use this code to save and open files. how can i sort the data so they came out at the list in same order that they where saved?

Code



Dim btmp As Bitmap
Dim Id As InputDialog
Dim ct1 As CustomToast
btmp.Initialize(File.DirAssets,"android48.png")
ct1.Initialize
'Id.PasswordMode = True
'Id.InputType =Id.INPUT_TYPE_DECIMAL_NUMBERS
'Id.InputType = Id.INPUT_TYPE_NUMBERS
'Id.InputType = Id.INPUT_TYPE_PHONE
Id.InputType = Id.INPUT_TYPE_text
Id.Input = ""
Id.Hint = "Skriv inn filnamnet!"
Id.HintColor = Colors.ARGB(196, 255, 140, 0)
ret = DialogResponse.CANCEL
ret = Id.Show("Skriv inn filnamnet", "Pulsdialog", "Ok", "Angre", "", bmp)
If ret = -1 Then
lagre = Id.Input
Dim Map1 As Map
Map1.Initialize
For i = 1 To 7
Map1.Put("Makspuls" &"", Round( svar1) & "")
Map1.Put("Bmi" &"",Round(bmi) & "")
Map1.Put("Fitnes kat" &"", EditText11ukk.Text& "")
Map1.Put("Pulsone lett" &"", Round(lett1)& " " & Round(lett2) &"")
Map1.Put("Pulsone At" &"", Round(at1)& " " & Round(at2) &"")
Map1.Put("Pulsone Vo2max" &"", Round(vo1)& " " & Round(vo2) &"")
Map1.Put("Fitnes id" &"",Round(svar)& "")
Next
File.WriteMap(File.DirRootExternal & "/pulsdata", lagre & ".txt", Map1)
ct1.ShowBitmap(" Filen er lagra som " & lagre & ".txt",2000,Gravity.top,20,20,btmp)
End If

End Sub
 

volvomann

Active Member
Licensed User
Longtime User
Ok tank you. If i done somting wrong with opploading the code i fix it next time but can you explain what you mean i am not so good in Inglish "(Please use [ code ] tags (without spaces) when posting code.)"
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Ok tank you. If i done somting wrong with opploading the code i fix it next time but can you explain what you mean i am not so good in Inglish "(Please use [ code ] tags (without spaces) when posting code.)"
This post by Mahares sums up how to use the [ code ] tags: Using Code Tags
 
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
Now i have tried this code for sorting but no it dont work Please tel me what i done wrong


B4X:
Sub mnuPagel_Click    
   Dim Map1 As Map
    Map1.Initialize
   Dim btmp As Bitmap
   Dim Id As InputDialog    
   Dim ct1 As CustomToast
   btmp.Initialize(File.DirAssets,"android48.png")
   ct1.Initialize
      'Id.PasswordMode = True
   'Id.InputType =Id.INPUT_TYPE_DECIMAL_NUMBERS
   'Id.InputType = Id.INPUT_TYPE_NUMBERS
   'Id.InputType = Id.INPUT_TYPE_PHONE
   Id.InputType = Id.INPUT_TYPE_text   
   Id.Input = ""
   Id.Hint = "Skriv inn filnamnet!"
   Id.HintColor = Colors.ARGB(196, 255, 140, 0)
   ret = DialogResponse.CANCEL
   ret = Id.Show("Skriv inn filnamnet", "Pulsdialog", "Ok", "Angre", "", bmp)
   If ret = -1 Then
   lagre = Id.Input   
    
      For i = 1 To 7
          Map1.Put("Item #1","Makspuls" )
        Map1.Put("Item #2","Bmi ")
           
           Map1.Put("Item #3","Fitnesid")      
            Map1.Put("Item #4","Fitneskat")
             Map1.Put("Item #5","pulssone lett")
             Map1.Put("Item #6" ,"Pulsone At" , Round(at1)& " " & Round(at2) &"")
             Map1.Put("item #7","Pulsone Vo2max" , Round(vo1)& " " & Round(vo2) &"")              
   Next
    File.WriteMap(File.DirRootExternal & "/pulsdata", lagre & ".txt", Map1)
      ct1.ShowBitmap(" Filen er lagra som " & lagre & ".txt",2000,Gravity.top,20,20,btmp)   
 End If
 
End Sub

'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Meny hente """""""""""""""""""""""""""""""""""""""""""""""""""
Sub mnuPage3_Click
   
   Dim Map1 As Map
    Dim sb As StringBuilder
   Dim ret As Float
    Dim fd As FileDialog
   'Map1.Put("Item #1", "")
    'Map1.Put("Item #2", "")
   
   fd.FastScroll = True
   'fd.ShowOnlyFolders = True
   fd.FilePath = (File.DirRootExternal & "/pulsdata") ' also sets ChosenName to an emtpy string
   'fd.ShowOnlyFolders = true
   'fd.FileFilter = ".txt" ' for example or ".jpg,.png" for multiple file types
   ret = fd.Show("Pulsdialog", "Ok", "", "", bmp)   
   opne= fd.ChosenName   
   If File.Exists(File.DirRootExternal & "/pulsdata", opne) = True Then
    Map1 = File.ReadMap2(File.DirRootExternal & "/pulsdata", opne,Map1)   
    sb.Initialize
    sb.Append("Dine verdier er:").Append(CRLF).Append(CRLF)
    For i = 0 To Map1.Size - 1
    sb.Append("").Append(Map1.GetKeyAt(i)).Append(" = ")
    sb.Append(Map1.GetValueAt(i)).Append(CRLF)
Next
    Msgbox(sb.ToString,"")   
 End If
   If ret = -2 Then 
   ToastMessageShow(" Helge T", False)
End If
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
In order for the map to be sorted, you need to create an empty map with the key values in your order.

Here:


B4X:
Sub mnuPagel_Click    
   Dim Map1 As Map
    Map1.Initialize
   Dim btmp As Bitmap
   Dim Id As InputDialog    
   Dim ct1 As CustomToast
   btmp.Initialize(File.DirAssets,"android48.png")
   ct1.Initialize
      'Id.PasswordMode = True
   'Id.InputType =Id.INPUT_TYPE_DECIMAL_NUMBERS
   'Id.InputType = Id.INPUT_TYPE_NUMBERS
   'Id.InputType = Id.INPUT_TYPE_PHONE
   Id.InputType = Id.INPUT_TYPE_text   
   Id.Input = ""
   Id.Hint = "Skriv inn filnamnet!"
   Id.HintColor = Colors.ARGB(196, 255, 140, 0)
   ret = DialogResponse.CANCEL
   ret = Id.Show("Skriv inn filnamnet", "Pulsdialog", "Ok", "Angre", "", bmp)
   If ret = -1 Then
   lagre = Id.Input   
    
      For i = 1 To 7
          Map1.Put("Item #1","Makspuls" )
        Map1.Put("Item #2","Bmi ")
           
           Map1.Put("Item #3","Fitnesid")      
            Map1.Put("Item #4","Fitneskat")
             Map1.Put("Item #5","pulssone lett")
             Map1.Put("Item #6" ,"Pulsone At" , Round(at1)& " " & Round(at2) &"")
             Map1.Put("item #7","Pulsone Vo2max" , Round(vo1)& " " & Round(vo2) &"")              
   Next
    File.WriteMap(File.DirRootExternal & "/pulsdata", lagre & ".txt", Map1)
      ct1.ShowBitmap(" Filen er lagra som " & lagre & ".txt",2000,Gravity.top,20,20,btmp)   
 End If
 
End Sub

'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Meny hente """""""""""""""""""""""""""""""""""""""""""""""""""
Sub mnuPage3_Click
   
   Dim Map1 As Map
    Dim sb As StringBuilder
   Dim ret As Float
    Dim fd As FileDialog
   'Map1.Put("Item #1", "")
    'Map1.Put("Item #2", "")
   
   fd.FastScroll = True
   'fd.ShowOnlyFolders = True
   fd.FilePath = (File.DirRootExternal & "/pulsdata") ' also sets ChosenName to an emtpy string
   'fd.ShowOnlyFolders = true
   'fd.FileFilter = ".txt" ' for example or ".jpg,.png" for multiple file types
   ret = fd.Show("Pulsdialog", "Ok", "", "", bmp)   
   opne= fd.ChosenName   
   If File.Exists(File.DirRootExternal & "/pulsdata", opne) = True Then
   Map1.Put("Item #1","" )
        Map1.Put("Item #2","")
           
           Map1.Put("Item #3","")      
            Map1.Put("Item #4","")
             Map1.Put("Item #5","")
             Map1.Put("Item #6" ,"")
             Map1.Put("item #7","")   
    Map1 = File.ReadMap2(File.DirRootExternal & "/pulsdata", opne,Map1)   
    sb.Initialize
    sb.Append("Dine verdier er:").Append(CRLF).Append(CRLF)
    For i = 0 To Map1.Size - 1
    sb.Append("").Append(Map1.GetKeyAt(i)).Append(" = ")
    sb.Append(Map1.GetValueAt(i)).Append(CRLF)
Next
    Msgbox(sb.ToString,"")   
 End If
   If ret = -2 Then 
   ToastMessageShow(" Helge T", False)
End If
 
Upvote 0

volvomann

Active Member
Licensed User
Longtime User
than you. But there is somting that see me blind off problely a basic thing.

When i use your code i got undefind error at this codeline
is there anything you can thing off what i am doing wrong

B4X:
Map1.Put("Item #1","" )
       Map1.Put("Item #2","")'  
           Map1.Put("Item #3","")        
             Map1.Put("Item #4","")
              Map1.Put("Item #5","")
 
Upvote 0
Top