Login
Register
Menu
Home
Forum
JassDoc
Types
Functions
Variables
Help
Chat
Media
Search
Search posts
WC3 JASS.com
"The Jass Vault" plus vJASS and Zinc
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
Rejected Codes & Snippets
(Moderator:
Magtheridon96
)
.txtFile
Warcraft III:
Maps
Models
Skins
Icons
Spells / Systems
Tools
Tutorials
Snippets
JASS vJASS Spells and Systems
Tutorials
Chat @Discord
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation
-
Zinc documentation
-
WC3 Optimizer documentation
.txtFile
Rejected Codes & Snippets
Started by
nel
Views
4144
Replies
2
Users
2
1
2
Pages:
1
Go Down
0 Members and 1 Guest are viewing this topic.
nel
nelmvn
Newbie - level 1
Posts:
10
WC3 Models: 0
WC3 Tutorials: 0
WC3 Tools: 0
WC3 Maps: 0
WC3 Skins: 0
WC3 Icons: 0
WC3 Spells: 1
Reputation:
1
Pink is the new Blvck
.txtFile
on:
October 06, 2017, 01:15:39 AM
.txtFile
Allows you to generate an empty text file by using Preload functions and Batch Script.
Open the created .bat file to download a text file.
How to install
Go to the Preferences menu and make sure "Automatically create unknown variables while pasting trigger data" is checked
Copy and Paste the txtFile trigger to your map.
Code
txtFile
Events
Conditions
Actions
-------- v3.4 --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
--------
[ CONFIGURATION ] --------
-------- --------------------------------------------------------------------------------------------------------- --------
--------
> Add Margin --------
Set txtFile_Margin = True
-------- --------------------------------------------------------------------------------------------------------- --------
-------- > Add Date Created --------
Set txtFile_DateCreated = True
-------- --------------------------------------------------------------------------------------------------------- --------
-------- > Error Message --------
--------
Allows you to display an error. --------
Set txtFile_ErrorMessage = True
--------
[ End Configuration ] --------
-------- --------------------------------------------------------------------------------------------------------- --------
--------
[ END CONFIGURATION ] --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
Custom script:
call ExecuteFunc( "txtFile" )
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Constant Functions --------
--------
Preload Function can only handle up to 259 characters (Excluding the batch script codes). --------
Custom script:
constant function txtFile_maxChar takes nothing returns integer
Custom script:
return 259
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Create a .txt file --------
Custom script:
function txtFile_Create takes integer lineCount, string folder, string filename, player pl returns nothing
Custom script:
local integer Index = 1
Custom script:
local integer cutIndex = 238
Custom script:
local integer cutCount = 0
Custom script:
local string array cutString
Custom script:
local integer tempInt = 0
Custom script:
local string tempString
--------
--------------------------------------------------------------------------------------------------------- --------
--------
GetLocalPlayer() is for specific player when the pl has null value is for all players. --------
Custom script:
if( GetLocalPlayer() == pl or pl == null ) then
Custom script:
call PreloadGenClear()
Custom script:
call PreloadGenStart()
Custom script:
call Preload("\r\nEcho Off & cls\r\n::")
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Length of Filename --------
Custom script:
if( StringLength( filename ) + StringLength( "\r\nset filename=\".txt\"\r\n::" ) > txtFile_maxChar() ) then
--------
Remove the excess chars --------
Custom script:
set tempString = SubString( filename, 0, txtFile_maxChar() )
Custom script:
call Preload("\r\nset filename=\"" + tempString + ".txt\"\r\n::")
Custom script:
call Preload("\r\nset xls=\"~temp" + tempString + ".txt\"\r\n::")
--------
Batch script has no String Length Func --------
Custom script:
call Preload("\r\nset i=" + I2S( StringLength( tempString ) + 1) + "\r\n::")
Custom script:
else
Custom script:
call Preload("\r\nset filename=\"" + filename + ".txt\"\r\n::")
Custom script:
call Preload("\r\nset xls=\"~temp" + filename + ".txt\"\r\n::")
--------
Batch script has no String Length Func --------
Custom script:
call Preload("\r\nset i=" + I2S( StringLength( filename ) + 1 ) + "\r\n::")
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Remove X.txt and filename.txt if exist --------
Custom script:
call Preload("\r\ndel %filename%\r\nGOTO jumpA\r\n")
Custom script:
call Preload("\r\ngoto:eof\r\n:jumpA\r\ndel %xls%\r\nGOTO jumpB\r\n")
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Add Margin --------
Custom script:
if( udg_txtFile_Margin ) then
Custom script:
call Preload("\r\n:jumpB\r\necho. >> %xls%\r\necho. >> %xls%\r\necho. >> %xls%\r\n::")
Custom script:
else
Custom script:
call Preload("\r\n:jumpB\r\n::")
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
Custom script:
loop
Custom script:
exitwhen Index > lineCount
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Only 259 characters can handle the single Preload() --------
--------
When had extra characters in one line. --------
--------
Divided it and put it in the variable. --------
Custom script:
if( StringLength( udg_txtFile_Line[ Index]) + 21 > txtFile_maxChar() ) then
Custom script:
set cutString[1] = ""
Custom script:
set cutCount = 1
Custom script:
loop
Custom script:
exitwhen cutIndex > StringLength( udg_txtFile_Line[ Index])
Custom script:
if( StringLength( cutString[ cutCount]) < 238 ) then
Custom script:
set cutString[ cutCount] = cutString[ cutCount] + SubString( udg_txtFile_Line[ Index], cutIndex - 1, cutIndex)
Custom script:
else
Custom script:
set cutCount = cutCount + 1
Custom script:
set cutString[ cutCount] = SubString( udg_txtFile_Line[ Index], cutIndex - 1, cutIndex)
Custom script:
endif
Custom script:
set cutIndex = cutIndex + 1
Custom script:
endloop
Custom script:
set udg_txtFile_Line[ Index] = SubString( udg_txtFile_Line[ Index], 0, 238)
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Print --------
Custom script:
if( not udg_txtFile_Margin and udg_txtFile_Line[ Index] != "") then
Custom script:
call Preload( "\r\necho " + udg_txtFile_Line[ Index] + " >> %xls%\r\n" )
Custom script:
elseif( udg_txtFile_Line[ Index] != "" ) then
Custom script:
call Preload( "\r\necho " + udg_txtFile_Line[ Index] + " >> %xls%\r\n" )
Custom script:
else
Custom script:
call Preload( "\r\necho. >> %xls%\r\n::" )
Custom script:
endif
--------
It will display those extra lines. --------
Custom script:
if( cutCount > 0 ) then
Custom script:
set cutIndex = 1
Custom script:
loop
Custom script:
exitwhen cutIndex > cutCount
Custom script:
if( not udg_txtFile_Margin ) then
Custom script:
call Preload( "\r\necho " + cutString[ cutIndex] + " >> %xls%\r\n" )
Custom script:
else
Custom script:
call Preload( "\r\necho " + cutString[ cutIndex] + " >> %xls%\r\n" )
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Clean --------
Custom script:
set cutString[ cutIndex] = null
Custom script:
set cutIndex = cutIndex + 1
Custom script:
endloop
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Clean --------
Custom script:
set udg_txtFile_Line[ Index] = null
Custom script:
set cutCount = 0
Custom script:
set Index = Index + 1
Custom script:
endloop
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Add Margin --------
Custom script:
if( udg_txtFile_Margin ) then
Custom script:
call Preload("\r\necho. >> %xls%\r\necho. >> %xls%\r\necho. >> %xls%\r\n::")
Custom script:
if( udg_txtFile_DateCreated ) then
Custom script:
call Preload("\r\necho --------------------------------------------- >> %xls%\r\n::")
Custom script:
call Preload("\r\necho. >> %xls%\r\n::")
Custom script:
call Preload("\r\necho Date Created: %DATE% >> %xls%\r\n::")
Custom script:
call Preload("\r\necho %TIME% >> %xls%\r\n::")
Custom script:
endif
Custom script:
else
Custom script:
if( udg_txtFile_DateCreated ) then
Custom script:
call Preload("\r\necho. >> %xls%\r\n::")
Custom script:
call Preload("\r\necho --------------------------------------------- >> %xls%\r\n::")
Custom script:
call Preload("\r\necho Date Created: %DATE% >> %xls%\r\n::")
Custom script:
call Preload("\r\necho %TIME% >> %xls%\r\n::")
Custom script:
endif
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Batch Script: Rename X.txt to correct filename --------
Custom script:
call Preload("\r\nrename %xls% %filename%\r\n::")
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Batch Script: Open notepad --------
Custom script:
call Preload("\r\nstart notepad.exe %filename%\r\n::")
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Batch Script: Delete .bat file --------
Custom script:
call Preload("\r\ncall set subString=%%filename:~0,%i%%%\r\n::")
Custom script:
call Preload("\r\ndel %subString%.bat\r\n::")
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Create .bat file --------
Custom script:
call PreloadGenEnd( folder + "\\" + filename + ".bat" )
Custom script:
endif
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Check if the line has a special characters --------
Custom script:
function txtFile_enchanceLine takes integer curr returns string
Custom script:
local integer Index = 1
Custom script:
local string Char
Custom script:
local string tempString = ""
Custom script:
loop
Custom script:
exitwhen Index > StringLength( udg_txtFile_Line[curr] )
--------
check bit by bit --------
Custom script:
set Char = SubString( udg_txtFile_Line[curr], Index - 1, Index)
Custom script:
if( Char == "%" ) then
Custom script:
set tempString = tempString + "^%"
Custom script:
elseif( Char == "^" ) then
Custom script:
set tempString = tempString + "^^"
Custom script:
elseif( Char == "&" ) then
Custom script:
set tempString = tempString + "^&"
Custom script:
elseif( Char == "<" ) then
Custom script:
set tempString = tempString + "^<"
Custom script:
elseif( Char == ">" ) then
Custom script:
set tempString = tempString + "^>"
Custom script:
elseif( Char == "|" ) then
Custom script:
set tempString = tempString + "^|"
Custom script:
elseif( Char == "`" ) then
Custom script:
set tempString = tempString + "^`"
Custom script:
elseif( Char == "," ) then
Custom script:
set tempString = tempString + "^,"
Custom script:
elseif( Char == "." ) then
Custom script:
set tempString = tempString + "^."
Custom script:
elseif( Char == ";" ) then
Custom script:
set tempString = tempString + "^;"
Custom script:
elseif( Char == "=" ) then
Custom script:
set tempString = tempString + "^="
Custom script:
elseif( Char == "(" ) then
Custom script:
set tempString = tempString + "^("
Custom script:
elseif( Char == ")" ) then
Custom script:
set tempString = tempString + "^)"
Custom script:
elseif( Char == "!" ) then
Custom script:
set tempString = tempString + "^!"
Custom script:
elseif( Char == "\"" ) then
Custom script:
set tempString = tempString + "^\""
Custom script:
else
Custom script:
set tempString = tempString + Char
Custom script:
endif
Custom script:
set Index = Index + 1
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Clean --------
Custom script:
set Char = null
Custom script:
endloop
Custom script:
return tempString
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Check the name of the folder and file. --------
Custom script:
function txtFile_checkString takes string str, boolean isFolder returns boolean
Custom script:
local integer Index = 1
Custom script:
local boolean error = false
Custom script:
local string Char
--------
--------------------------------------------------------------------------------------------------------- --------
--------
String Length & Null Value --------
Custom script:
if( StringLength( str ) == 0 or str == null ) then
Custom script:
set error = true
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Subfolder --------
Custom script:
elseif( SubString( str, 0, 1 ) == "\\" and isFolder ) then
Custom script:
set error = true
Custom script:
elseif( SubString( str, StringLength( str) - 1, StringLength( str)) == "\\" and isFolder ) then
Custom script:
set error = true
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
These \, /, :, *, ?, ", <, >, and | are forbidden characters in Windows OS --------
Custom script:
loop
Custom script:
exitwhen Index > StringLength( str) or error
--------
check bit by bit --------
Custom script:
set Char = SubString( str, Index - 1, Index)
Custom script:
if( Char == "\\" and not isFolder ) then
Custom script:
set error = true
Custom script:
elseif( Char == "/") then
Custom script:
set error = true
Custom script:
elseif( Char == ":") then
Custom script:
set error = true
Custom script:
elseif( Char == "*") then
Custom script:
set error = true
Custom script:
elseif( Char == "?") then
Custom script:
set error = true
Custom script:
elseif( Char == "\"") then
Custom script:
set error = true
Custom script:
elseif( Char == "<") then
Custom script:
set error = true
Custom script:
elseif( Char == ">") then
Custom script:
set error = true
Custom script:
elseif( Char == "|") then
Custom script:
set error = true
Custom script:
endif
Custom script:
set Index = Index + 1
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Clean --------
Custom script:
set Char = null
Custom script:
endloop
Custom script:
return error
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Compile --------
Custom script:
function txtFile_Compile takes nothing returns boolean
Custom script:
local integer Index = 1
Custom script:
local boolean good = true
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Folder Name --------
Custom script:
if ( txtFile_checkString( udg_txtFile_FolderName, true ) ) then
Custom script:
set good = false
Custom script:
if( udg_txtFile_ErrorMessage ) then
Custom script:
call DisplayTextToPlayer( GetLocalPlayer(), 0, 0, "Error: Invalid Foldername")
--------
Clean --------
Custom script:
set udg_txtFile_FolderName = null
Custom script:
endif
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
File Name --------
Custom script:
if ( txtFile_checkString( udg_txtFile_FileName, true ) ) then
Custom script:
set good = false
Custom script:
if( udg_txtFile_ErrorMessage ) then
Custom script:
call DisplayTextToPlayer( GetLocalPlayer(), 0, 0, "Error: Invalid Filename")
--------
Clean --------
Custom script:
set udg_txtFile_FileName = null
Custom script:
endif
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Player --------
Custom script:
if( GetPlayerId( udg_txtFile_Player) > 23 or not good ) then
Custom script:
set udg_txtFile_Player = null
Custom script:
endif
--------
--------------------------------------------------------------------------------------------------------- --------
--------
Line/s --------
Custom script:
if( udg_txtFile_LineCount > 0 ) then
Custom script:
loop
Custom script:
exitwhen Index > udg_txtFile_LineCount
Custom script:
if( udg_txtFile_Line[ Index] == null and good ) then
Custom script:
set udg_txtFile_Line[ Index] = ""
Custom script:
elseif( udg_txtFile_Line[ Index] != null and not good ) then
Custom script:
set udg_txtFile_Line[ Index] = null
Custom script:
endif
Custom script:
set udg_txtFile_Line[Index] = txtFile_enchanceLine( Index )
Custom script:
set Index = Index + 1
Custom script:
endloop
Custom script:
endif
Custom script:
return good
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Before creating a .bat file, this system checks all the txtFile variables. --------
Custom script:
function txtFile takes nothing returns nothing
Custom script:
if( txtFile_Compile() ) then
Custom script:
call txtFile_Create( udg_txtFile_LineCount, udg_txtFile_FolderName, udg_txtFile_FileName, udg_txtFile_Player )
Custom script:
endif
Custom script:
endfunction
-------- --------------------------------------------------------------------------------------------------------- --------
-------- --------------------------------------------------------------------------------------------------------- --------
-------- Variable Creator --------
-------- Variable Creator --------
Custom script:
function txtFile_VariableCreator takes nothing returns nothing
Set txtFile_Line[0] = <Empty String>
Set txtFile_LineCount = 0
Set txtFile_Player = Player 1 (Red)
Set txtFile_FileName = <Empty String>
Set txtFile_FolderName = <Empty String>
Changelog
Changelog
[ v3.4 ]
- Fixed _Compile Function.
- Changed the value of GetPlayerId( udg_txtFile_Player) 11 to 23.
- You can now able to use Special Characters.
- Fixed Batch Script Codes.
[ v3.3 ]
- Fixed _Compile Function.
- Error Message?
- Fixed _Create Function. No longer displaying "o" bug in txt file.
[ v3.2 ]
- Fixed _Compile Function.
- Fixed _checkString Function.
- Fixed _Create Function.
- Each lines has a maximum of 238 characters.
- Batch Script: Download a text is much faster than before.?
- No longer to add ":" each lines.
- Batch Script: Using "echo." to avoid displaying "ECHO is on." without using ":".
[ v3.1 ]
- Less code.
- Fixed _checkString Function. Now you can able to add subfolder in txtFile_FolderName using "\" with no error.
- Fixed _Compile Function.
- Fixed _Create Function.
- Fixed the Documentation.
- Added Auto-Open Notepad.
[ v3.0 ]
- Code Reworked
[ v2.0 ]
- Removed txtFile_ChangeLine
- Added GetLocalPlayer()
- Trying to avoid reaching more than 259 characters each Preload()
[ v1.0 ]
- Release
[/size]
«
Last Edit: September 03, 2018, 12:02:18 AM by moyack
»
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
Re: .txtFile v3.3
Reply #1 on:
October 06, 2017, 07:28:13 PM
Hi nel and Welcome to WC3modding.info.
I've set the trigger tag so it can look better. Im working in the code to show triggers properly
WC3 Modding Information Center
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
Re: .txtFile
Reply #2 on:
March 20, 2019, 11:30:42 AM
Removed by request.
WC3 Modding Information Center
Print
Pages:
1
Go Up
« previous
next »
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
Rejected Codes & Snippets
(Moderator:
Magtheridon96
)
.txtFile
PortaMx-SEF 1.54
|
PortaMx © 2008-2015
,
PortaMx corp.
Search
Username
Password
Always stay logged in
Forgot your password?