Jump to content
Sign in to follow this  
russell

FileOpen remote file

Recommended Posts

russell

I recently wrote a large program the reference variables from a txt file. It works fine but was want to have the txt file instead of being the the same dir as the script, instead me on mysite and reference it from there. Before i used

$color = FileOpen("color.txt", 0)

I thought this might work

$color = FileOpen("http://mysite.com/color.txt", 0)

Since anyone could see it and it worked in my web-browser. However non of the variables now work and im thinking its not actually opening the file because the location. Is there another command i use before FileOpen, like a HTTP base one or something? Help didn't seem to help too much, i assume its because i don't know where to look


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
russell

ooop Inetget, lol i think i found it


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
russell

oo wow this proves to be a bit more than i thought. I ended up switching to InetRead instead but still cant seem to get any information from the file


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
russell

$color1 = InetRead ("http://mywebsite/color.txt", 1)

$color= BinaryToString($color1)


$test = FileReadLine ($color, 3)
$test = StringTrimLeft($test,13)

MsgBox (1,"title", $test)

That works if i tell the msgbox to give $color but not if i use the line read and trim. Any suggestions?


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
Exit

use _inetgetsource()

#include <INet.au3>

ConsoleWrite(_INetGetSource('http://mywebsite/color.txt'))


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
russell

thanks ill try that


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
russell

well that successfully writes it to the console but i have around 300 line in the script that look like this

$test = FileReadLine ($color, 3)
$test = StringTrimLeft($test,13)

Is there a way to convert it to a temp file so all the trims and read line matchup?

Edited by russell

muppet hands are so soft :)

Share this post


Link to post
Share on other sites
russell

perfect! thanks forumer100


muppet hands are so soft :)

Share this post


Link to post
Share on other sites
LurchMan

You could also use:

$sFileRead = BinaryToString(InetRead ($sURL))

This would avoid the temp file.


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

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.