请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6829|回复: 0

[其他] gen_editor_utils.ncl获取全部函数

[复制链接]

新浪微博达人勋

发表于 2015-4-8 10:41:35 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 lleoiu 于 2015-4-8 10:44 编辑

在NCL的官网上提供了编辑器的着色文件,并且提供了自动从NCL官网获取全部keywords, function, resources
的子程序gen_editor_utils.ncl。

在使用这个函数时,发现一个问题,get_ncl_resources(),get_ncl_keywords() ,get_ncl_operators()这几个函数都可以正常工作,但是 get_ncl_procs_and_funcs(), get_ncl_procs_and_funcs_by_cat()运行得到的结果会出现如下的情况:
cfftf_frq_reorder                 
cfftf                             
Functions                        
Functions                        
charactertodouble                 
Built-in                          
charactertofloat                  
Built-in                          
charactertointeger               
Built-in                          
charactertolong                  
Built-in                          
charactertoshort                  
Built-in                          
charactertostring                 
Built-in                          
chartodouble                     
Built-in                          
chartofloat                       
Built-in                          
chartoint                        
Built-in                          
chartointeger                     
Built-in                          
chartolong                        
Built-in                          
chartoshort                       
Built-in                          
chartostring                     
Built-in                          
chiinv                           

就是在部分函数下,会出现Built-in, 或者Functions这样的字符,但这肯定不是NCL的函数名。

看了原代码,在line_search = "<a href=" + dq + names(icat,2)这里折腾了很久也没有搞定。
请教各位,如何在页面上挑选函数时把筛选的条件定的更严格一些?

;----------------------------------------------------------------------         
; This function reads the alphabetical web page for the given category         
; type of NCL functions and procedures and produces a list of the               
; names. Use "get_ncl_procs_and_funcs" if you just want one giant               
; list of function/procedure names, regardless of category.                     
;----------------------------------------------------------------------         
undef("get_ncl_procs_and_funcs_by_cat")                                         
function get_ncl_procs_and_funcs_by_cat(cat_name)                              
local url, fname, lines, dq, line_search, new_lines, delim, ii                  
begin                                                                           
  fname = "list_alpha_browse.shtml"                                             
  if(GET_FROM_WEB)  then                                                        
;---Remove local file first.                                                   
    system("/bin/rm " + fname)                                                  
    url = "http://www.ncl.ucar.edu/Document/Functions/"                        
    system("wget " + (url+fname))                                               
  end if                                                                        
  names = get_valid_cat_names()                                                
  lines = asciiread(fname,-1,"string")                                          
;                                                                              
; Get just the strings that contain the func/proc names for                     
; the given category.                                                           
;                                                                              
;   The line we want contains:                                                  
;                                                                              
;      <a href="/Document/XXXXX/YYYY/funcproc_name.shtml"...                    
;                                                                              
  icat = ind(cat_name.eq.names(:,0))                                            
  if(ismissing(icat)) then                                                      
    print("get_ncl_procs_and_funcs_by_cat: invalid category")                  
    return(new(1,string))                                                      
  end if                                                                        
                                                                                
;;;;This part still needs work!!                                                
  dq          = str_get_dq()                                                   
  line_search = "<a href=" + dq + names(icat,2)                                                                        
  ii          = str_match_ind(lines,line_search)                                
  new_lines   = lines(ii)                                                                                                           
;---Split out the function/procedure names                                      
  delim = "/."                                                                  
  fnames = str_get_field(new_lines,5,delim)                                                                                               
  return(fnames)                                                               
end                                                                             
                                                                                

密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表