ScriptSpot

Forum topic · General Scripting

Help with Script Task List

By zad53 · 2010-07-01

Downloads
Description

Someone could help me with this script i try to open a exist file text a display text in my rollup. this script i trying to create for a made a tasklist for management all work to do in any proyect please help

this code that i have right now

rollout edittext "Notas de Proyecto"

(
edittext txt "Notas :" fieldWidth:280 Height: 120 labelOnTop:true

button B " Abrir " pos:[190,150]

on B pressed do
(
file = getOpenFileName types:"Text File (*.txt)|*.txt|All Files (*.*)|*.*|"
if file != undefined then (
openFile file
format "%\n" txt.text to:file)
)

)

createDialog edittext 300 180

Comments (4)

zad53 · 2010-07-02

Thanks a lot both...hey le1setreter thanks man...is really usefull in a cupple days i post the final script...for someone who wants to...but if someone want now ...well this the final code:
thanks...again

rollout edittext "Notas de Proyecto"
(
edittext txt "Notas :" fieldWidth:280 Height: 120 labelOnTop:true

button A "Guardar" pos:[190,150]
on A pressed do
(
if txt.text == "" then MessageBox "Ingresar Notas" title:"Error"

else
file_out = GetSaveFileName types:"Text File (*.txt)|*.txt|All Files (*.*)|*.*|"

if file_out != undefined then
(file_out = createfile file_out
(format " %\n" txt.text to:file_out))

)

button B "Abrir" pos:[250,150]
on B pressed do(

local fileName = getOpenFileName types:"Text File (*.txt)|*.txt|All Files (*.*)|*.*|"
if fileName != undefined AND doesFileExist fileName do
(
local File = openfile fileName mode:"r+"

seek File #eof
local maxlen=filepos File
seek File 0

local loadedTxt = readChars File maxlen errorAtEOF:false -- changed local var to "loadedTxt " to not conflict with name of textbox name

txt.text = loadedTxt -- display loaded text into textbox
)
)

)

createDialog edittext 300 180 \
style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox)

le1setreter · 2010-07-01

you have to display the parsed text into the textbox:


rollout edittext "Notas de Proyecto" (
	
	edittext txt "Notas :" fieldWidth:280 Height: 120 labelOnTop:true

	button B " Abrir " pos:[190,150]

	on B pressed do(
		
		local fileName = getOpenFileName types:"Text File (*.txt)|*.txt|All Files (*.*)|*.*|"
		  if fileName != undefined AND doesFileExist fileName do
		  (
		    local File = openfile fileName mode:"rt"
		 
		    seek File #eof
		    local maxlen=filepos File
		    seek File 0
		 
		    local loadedTxt = readChars File maxlen errorAtEOF:false -- changed local var to "loadedTxt " to not conflict with name of textbox name
			
			txt.text = loadedTxt -- display loaded text into textbox
		 )
	)

)

createDialog edittext 300 180

zad53 · 2010-07-01

thanks...Insanto but i still dont see text in my rollup, try to open the text file and nothings happen...what is the problem? i dont understand what happend...

Graph · 2010-07-01

readOnly:


(
  local fileName = getOpenFileName types:"Text File (*.txt)|*.txt|All Files (*.*)|*.*|"
  if fileName != undefined AND doesFileExist fileName do
  (
    local File = openfile fileName mode:"rt"

    seek File #eof
    local maxlen=filepos File
    seek File 0

    local txt = readChars File maxlen errorAtEOF:false
  )
)

if you wanna format stuff to the file use mode "r+"