NetLogo/Files

Материал из Поле цифровой дидактики


File-Open

file-open - открыть файл
file-open "task_7.txt"
while [ not file-at-end? ] [ set wikihistory lput read-from-string (word "[" file-read-line "]") wikihistory]
file-close

Открыли файл и считали все его содержимое построчно в список с именем wikihistory

Read-from-string

Пример - file-exists? file-open file-at-end? file-read-line
   ifelse ( file-exists? "profile.txt" )
  [     file-open "profile.txt"
       while [ not file-at-end? ]     [ 
         let author read-from-string (word "[" file-read-line "]")  
         ask one-of users with [agentname = item 0 author]
         [
           set FullName item 1 author
           set TB item 2 author
           set OSB item 3 author
           set Block item 4 author
         ] 
         ]
   file-close
   user-message "Готово!"
    ]
    [ user-message "profile.txt нет такого файла!" ]


File-Print

 file-open "losted_sch.txt"
 foreach reverse sort-on [norm-betweenness] users [file-print (se ? [norm-betweenness] of ? [agentname] of ?)]
file-close

user-new-file

file-open user-new-file

= Export-view

to clustC
let Centr max-one-of users [nw:betweenness-centrality]
layout-radial turtles links Centr
export-view (word "../sber_results/u325/clusters/" [who] of Centr ".png" )
ask Centr [die]
ask users with [count my-links = 0] [die] 
end