[Gambas-user] For Each Line in String

paulwheeler paulwheeler at ...546...
Sat Aug 17 20:41:43 CEST 2013


   Not sure what you wanted to do with the information, but this code will get
   the directory info, output it to a file, print it to the console, and put it
   into an array.
   NOTE: This is an excerpt from the gambas-diskinfo (Version 1.0.33) code
   written by Demosthenes Koptsis. Sometimes it is just easier to borrow than
   to re-create.
   Hope this helps.
   paul
   ' Gambas class file
   ' Excerpt from gambas-diskinfo  Version 1.0.33
   ' Written by: Demosthenes Koptsis
   '
   ' Run this and look at Console output
   '
   Public Sub _new()
       Dim hfile As File
       Dim strLine As String
       Dim strFilePath As String
       Dim strDirPath As String
       Dim strLineArray As String[] = ["initializing"]
       Dim strElement As String
       Dim sPics As String
       'empty sLineArray
       strLineArray.Clear
       strDirPath = "/home/paul/Desktop"
       strFilePath = "/home/paul/Desktop/sPics.txt"
       Shell ("ls /home/paul/Desktop > /home/paul/Desktop/sPics.txt")
       Wait
       ''   Shell ("ls " & strDirPath & " > " & strFilePath)Wait()
       If Exist(strFilePath) Then 'if file exists
           hFile = Open strFilePath For Input   'open file for input
           While Not Eof(hFile) 'until the end
               Line Input #hFile, strLine 'read a line
               Print strLine ' & "\n"    ' print to console so you can see what
   is happening
               strLineArray.Add(strLine) 'add line to array
           Wend
       Endif
       'print each element for check
       For Each strElement In strLineArray
           Print strElement
       Next
   End
   Public Sub btnQuit_Click()
       Me.Close
   End

   On 08/17/2013 10:20 AM, Jussi Lahtinen wrote:

[1]http://gambasdoc.org/help/lang/split
Maybe by using gb.newline as separator.

Jussi


On Sat, Aug 17, 2013 at 6:54 PM, abbat81 [2]<abbat.81 at ...787...> wrote:

Dim sPics as astring

Shell "ls ~/Pictures/" to sPics

For Each Line in sPics
Print Line
Next


Fow can I do it?
Thanks



--
View this message in context:
[3]http://gambas.8142.n7.nabble.com/For-Each-Line-in-String-tp42889.html
Sent from the gambas-user mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
[4]http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[5]Gambas-user at lists.sourceforge.net
[6]https://lists.sourceforge.net/lists/listinfo/gambas-user

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
[7]http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
[8]Gambas-user at lists.sourceforge.net
[9]https://lists.sourceforge.net/lists/listinfo/gambas-user

References

   1. http://gambasdoc.org/help/lang/split
   2. mailto:abbat.81 at ...787...
   3. http://gambas.8142.n7.nabble.com/For-Each-Line-in-String-tp42889.html
   4. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
   5. mailto:Gambas-user at lists.sourceforge.net
   6. https://lists.sourceforge.net/lists/listinfo/gambas-user
   7. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
   8. mailto:Gambas-user at lists.sourceforge.net
   9. https://lists.sourceforge.net/lists/listinfo/gambas-user



More information about the User mailing list