Jump to content
Sign in to follow this  
layer

FileOpen support please

Recommended Posts

layer

hey guys... making a text editor and need some help... well, im making my own extension ".tex"... not just for fun but to learn how to use RegWrite.. but here is the code for it and...

RegWrite("HKCR\.tex","","REG_SZ","TexFile")
RegWrite("HKCR\.tex\ShellNew\")
RegWrite("HKCR\TexFile\Shell\Open\Command","","REG_SZ", @DesktopDir & "\Ryans Text Editor\" "%1")

it says there is an error in expression where the Macro is... now can i not use macors? whats the deal...

Secondly...

Using FileOpen like this...

Func Open ()
$open= FileOpenDialog ("Open...", @DesktopDir, "Text (*.tex)")
$readfile= FileOpen ($open, 0)
Return $readfile
EndFunc

when i double click on the .tex files it opens up my text editor but no text comes appears... :idiot: or if i go inside the text editor and open it from there, there is a "0" in the Edit Control... something to do with return maybe?

and one more thing... when using the messgae box (forgot the flag) with Yes, No, and Cancel... i got the numbers of like what happens when you press yes and stuff, but how would i apply that, like lets JUST SAY that

Yes= 1
No= -1
Cancel= 2

So i would go

While 1
lalalal
Case $get= $button
$testing= MsgBox (3 i think?, "Test", "Save?")
If $testing= 1
Save ()
EndIf
If $testing= -1 
Exit
EndIf
If $testing= 2
Return ()
EndIf

lets just say all those funcs and variables are declared... qwould that work (the if's and end if's may not, but im in a rush and i can fix that later and clean it up)

thanks! :D


FootbaG

Share this post


Link to post
Share on other sites
Insolence

First you open the file:

$var = FileOpen (ect.)

$var simply acts as a 'reference' (handle) to the file. The file handle.

You then use the handle to call the file to read it:

$line = FileReadLine($var)

Then if you want to read the whole sucker you use code like this (from the help file)

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($file)

3rd Question about the message boxes:

If it works like this:

OK 1 
CANCEL 2 
ABORT 3 
RETRY 4 
IGNORE 5 
YES 6 
NO 7 
TRY AGAIN ** 10 
CONTINUE ** 11

Then you can only use one at a time, right? Because OK + Cancle = Abort, right?

So just use one of them at a time.

As for your first question, I have no idea what's wrong with that.

Edited by Insolence

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Insolence

Answered message box question also :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
layer

hey hey hey! thanks again! lol


FootbaG

Share this post


Link to post
Share on other sites
Insolence

My pleasure :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
CyberSlug

Problem region highlighted in red:

RegWrite("HKCR\TexFile\Shell\Open\Command","","REG_SZ", @DesktopDir & "\Ryans Text Editor\" "%1")

Proposed fix:

RegWrite("HKCR\TexFile\Shell\Open\Command","","REG_SZ", "C:\pathToYourProg\Editor.exe" & ' "%1"')


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites
layer

thanks cyberslug!!!! although im afraid i won't be using .tex extensions... after i found out another program uses them,,, now i really screwed it up :idiot: please go to the chat section and youll see my post, "serious reg issues!!!" so please could you help me?!?!?!


FootbaG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.