Πέμπτη 30 Αυγούστου 2018

Αναθεώρηση 13, Έκδοση 9.4

Επιτέλους σε αυτήν την αναθεώρηση βρήκα τρόπο να παίρνω τον "απαριθμητή" ενός αντικειμένου που φορτώνουμε στη γλώσσα, όπως θα δούμε στα παραδείγματα παρακάτω. Επίσης προστέθηκε και το αντικείμενο Collection της Vb6. Το αντικείμενο Inventory έχει φτιαχτεί για να αντικαταστήσει το Collection,  αλλά τώρα μπήκε περισσότερο για να δούμε τη χρήση  του Enumeratror. (απαριθμητή)


declare fs "Scripting.FileSystemObject"
Method fs, "GetFolder", dir$ as fc
With fc, "files" set files
\\ Produce the TypeLib
mm=param(files)
IF LEN(mm)>1 THEN {
      For i=0 to len(mm)-1
            Report 3, mm$(i!) ' use index, not key
      Next i
}
With files, "count" as count
With files, "item" set myfile ("llist1.gsb")
\\ this is a property -4 which return a IEnumVariant
With files, -4& as EnumFile
Print Type$(EnumFile)
\\ Produce the TypeLib
m=param(EnumFile)
IF LEN(m)>1 THEN {
      For i=0 to len(m)-1
            Report 3, m$(i!) ' use index, not key
      Next i
}
With EnumFile, "Name" as aName$
While EnumFile {
      Print aName$
}
declare fs nothing

:Άλλο ένα που δείχνει φακέλους:
declare fs "Scripting.FileSystemObject"
Method fs, "GetFolder", dir$ as fc
With fc, "SubFolders" set SubFolders
Print type$(SubFolders)
With SubFolders, -4& as Folder
With Folder, "Name" as FolderName$
While Folder {
      Print FolderName$
}

declare fs nothing




Εδώ  κατά την χρηση του Collection,





declare c collection
Print type$(c)
m=param(c)
IF LEN(m)>1 THEN {
For i=0 to len(m)-1
Report 3, m$(i!) ' use index, not key
Next i
}

Method c, "Add", 100, "Hello"
Method c, "Add", 2000, "There"
Method c, "Add", 3000032131231231312312@, "Zero"
Method c, "count" as count
Print count
Method C, "_NewEnum" as Item
Method c, "Item", "Zero" as ZeroItem
Print ZeroItem
Print type$(Item)="Nothing"  ' we have numbers
k=0
While Item {
      k++
      print k, eval(item)
}





declare c collection
Print type$(c)
m=param(c)
IF LEN(m)>1 THEN {
For i=0 to len(m)-1
Report 3, m$(i!) ' use index, not key
Next i
}

Method c, "Add", "100", "Hello"
Method c, "Add", "2000", "There"
Method c, "Add", "30000", "Zero"
Method c, "count" as count
Method c, "Item", "Zero" as ZeroItem$
Print ZeroItem$
Print count
Method C, "_NewEnum" as Item

Print type$(Item)
k=0
While Item {
      k++
      print k, eval$(item)
}





Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.