最新消息:

stack是NSIS栈操作增改删和排序的插件

nsis 永恒心锁 2022浏览 0评论
/*
stack是NSIS栈操作增改删和排序的插件
stack提供了许多关于栈操作的方法,添加栈元素,删除栈元素,获取栈元素,交换,排序,清空等操作.
*/
!AddIncludeDir "../Include"
!AddPluginDir "../Plugins"
Name "StackTest"
OutFile "StackTest.exe"
!include "Stack.nsh"
!include "Sections.nsh"
Var RADIOBUTTON
Page components
Page instfiles
Section "Basic stack functions" Basic
### NSIS stack operations test ###
${stack::ns_push_front} "1a" ;// 1a
${stack::ns_push_front} "2a" ;// 2a 1a
${stack::ns_push_back} "3a" ;// 2a 1a 3a
${stack::ns_insert} "4a" "1" $R0 ;// 4a 2a 1a 3a
${stack::ns_insert} "5a" "5" $R0 ;// 4a 2a 1a 3a 5a
${stack::ns_pop_front} $R1 $R0 ;// [4a] 2a 1a 3a 5a
${stack::ns_pop_back} $R1 $R0 ;// 2a 1a 3a [5a]
${stack::ns_read} "3" $R1 $R0 ;// 2a 1a (3a)
${stack::ns_write} "2b" "2" $R0 ;// 2a (2b) 3a
${stack::ns_size} $R0 ;// 3
${stack::Debug} "0"
${stack::ns_delete} "2" $R1 $R0 ;// 2a [2b] 3a
${stack::ns_pop_front} $R1 $R0 ;// [2a] 3a
${stack::ns_pop_front} $R1 $R0 ;// [3a]
${stack::ns_pop_front} $R1 $R0 ;// []
### Private stack operations test ###
${stack::dll_create} $0
${stack::dll_insert} "$0" "1a" "-1" $R0 ;// 1a
${stack::dll_insert} "$0" "2a" "-1" $R0 ;// 1a 2a
${stack::dll_insert} "$0" "3a" "1" $R0 ;// 3a 1a 2a
${stack::dll_insert} "$0" "4a" "-1" $R0 ;// 3a 1a 2a 4a
${stack::dll_insert} "$0" "5a" "1" $R0 ;// 5a 3a 1a 2a 4a
${stack::dll_read} "$0" "2" $R1 $R0 ;// 5a (3a) 1a 2a 4a
${stack::dll_read} "$0" "-2" $R1 $R0 ;// 5a 3a 1a (2a) 4a
${stack::dll_delete} "$0" "2" $R1 $R0 ;// 5a [3a] 1a 2a 4a
${stack::dll_insert} "$0" "1b" "3" $R0 ;// 5a 1a 1b 2a 4a
${stack::dll_write} "$0" "2b" "-1" $R0 ;// 5a 1a 1b 2a (2b)
${stack::dll_exchange} "$0" "-2" "1" $R0 ;// 2a 1a 1b 5a 2b
${stack::dll_reverse_range} "$0" "1" "-1" $R0 ;// 2b 5a 1b 1a 2a
${stack::dll_move} "$0" "4" "2" $R0 ;// 2b 1a 5a 1b 2a
${stack::dll_move_range} "$0" "-1" "2" "1" $R0 ;// 1a 5a 1b 2a 2b
${stack::dll_push_sort} "$0" "3a" "1" ;// 1a 3a 5a 1b 2a 2b
${stack::dll_delete_range} "$0" "-1" "-3" $R0 ;// 1a 3a 5a [1b 2a 2b]
${stack::dll_sort_all} "$0" "-1" ;// 5a 3a 1a
${stack::dll_size} "$0" $R0 ;// 3
${stack::Debug} "$0"
${stack::dll_delete} "$0" "1" $R1 $R0 ;// 1a 3a (5a)
${stack::dll_delete} "$0" "-1" $R1 $R0 ;// 3a (1a)
${stack::dll_delete} "$0" "1" $R1 $R0 ;// (3a)
${stack::dll_delete} "$0" "1" $R1 $R0 ;// ()
${stack::dll_destroy} "$0"
${stack::Unload}
SectionEnd
Section /o "Sort integers" SortInt
${stack::dll_create} $0
${stack::dll_insert} "$0" "2" "-1" $R0
${stack::dll_insert} "$0" "1" "-1" $R0
${stack::dll_insert} "$0" "111" "-1" $R0
${stack::dll_insert} "$0" "222" "-1" $R0
${stack::dll_insert} "$0" "22" "-1" $R0
${stack::dll_insert} "$0" "11" "-1" $R0
${stack::dll_sort_all_int} "$0" "1"
${stack::Debug} "$0"
${stack::dll_clear} "$0"
${stack::dll_push_sort_int} "$0" "2" "-1"
${stack::dll_push_sort_int} "$0" "1" "-1"
${stack::dll_push_sort_int} "$0" "111" "-1"
${stack::dll_push_sort_int} "$0" "222" "-1"
${stack::dll_push_sort_int} "$0" "22" "-1"
${stack::dll_push_sort_int} "$0" "11" "-1"
${stack::Debug} "$0"
${stack::dll_clear} "$0"
${stack::dll_destroy} "$0"
${stack::Unload}
SectionEnd
Section /o "Sort lines in text file" SortLines
StrCpy $R0 "$WINDIRSYSTEM.INI" #Text file with unsorted lines
StrCpy $R1 "$TEMPSYSTEM_SORTED.INI" #Result text file with sorted lines
#Read lines to stack
${stack::dll_create} $0
FileOpen $R2 $R0 r
read:
FileRead $R2 $R3
IfErrors closeread
${stack::dll_push_sort} "$0" "$R3" "1"
goto read
closeread:
FileClose $R2
#Write lines to file
FileOpen $R2 $R1 w
write:
${stack::dll_delete} "$0" "1" $R3 $R4
StrCmp $R4 1 closewrite
FileWrite $R2 "$R3"
goto write
closewrite:
FileClose $R2
${stack::dll_destroy} "$0"
${stack::Unload}
#Open file
Exec '"notepad.exe" "$R1"'
SectionEnd
Function .onInit
StrCpy $RADIOBUTTON ${Basic}
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $RADIOBUTTON
!insertmacro RadioButton ${Basic}
!insertmacro RadioButton ${SortInt}
!insertmacro RadioButton ${SortLines}
!insertmacro EndRadioButtons
FunctionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » stack是NSIS栈操作增改删和排序的插件

您必须 登录 才能发表评论!