Set an undefined Loaded variable's alpha to 0
Hi, I'm trying creating a flash navigation bar that can be edited via a simple text file. I'm able to load my different variables properly but i also want to give the user the ability to remove links. I can simply leave the variable from the text file blank and and have the text in the swf disappear but i also want to be able to set the alpha of the movieclip behind the text to zero when the variable is left blank. Alternatively, even if the user could simply set the variable to the string "Blank" and both the alpha of the dynamic text and movieclip would change to zero that would be functional as well. Here is the code i have so far.
NavLoadVar = new LoadVars();
NavLoadVar.load("navigation.txt");
NavLoadVar.onLoad = function() {
b1.text = NavLoadVar.b1text;
b2.text = NavLoadVar.b2text;
b3.text = NavLoadVar.b3text;
b4.text = NavLoadVar.b4text;
b5.text = NavLoadVar.b5text;
b6.text = NavLoadVar.b6text;
b7.text = NavLoadVar.b7text;
b8.text = NavLoadVar.b8text;
if (NavLoadVar.b1text == "Blank") {
divider1._alpha = 0;
Something like the following should work...
NavLoadVar.onLoad = function() {
for(i=1; i<9; i++){
if (NavLoadVar["b"+i+"text"] == "Blank") {
this["divider"+i]._alpha = 0;
} else {
this["b"+i].text = NavLoadVar["b"+i+"text"] ;
Similar Messages
-
Loading Variables in a Class Function
I am having problems loading variables from an external text
file inside of a class function. The text file has been created
properly, and the code that I use in the class is as follows:
_root.createEmptyMovieClip("texRules", -100);
loadVariables("texRules.txt", _root.texRules);
m_Rules = _root.texRules.rules;
I create an empty movie clip on the root frame named
texRules, load the variables into that movie clip with the next
line and then set my member string value equal to the text file
variable named rules. When I run the program, I get an undefined
for my m_Rules.
Here is my texRules.txt:
rules=THESE ARE THE TEXAS HOLD'EM RULES.
Any ideas as to what I am doing incorrectly?I've opted to use the LoadVars instead of creating an empty
movie clip and loading the variables there. Here is my new code.
public function setRules():Void
var rulesLoader:LoadVars = new LoadVars();
rulesLoader.onLoad = function (success:Boolean):Void
if (success)
trace(rulesLoader.rules);
this.m_Rules = rulesLoader.rules;
else
trace( "Unable to load external file.");
rulesLoader.load("texRules.txt");
Here is where I define my properties of my class:
class TexHoldem extends Game
//Class member properties
//Private Properties
private var m_Rules:String;
private var m_Target:MovieClip;
Here is my constructor:
public function TexHoldem(target)
this.m_Target = target;
super("Texas No Limit Hold'Em", 0, 1);
setRules();
The setRules function works fine, the only problem now is
that I can't save the variables once the onLoad function goes out
of scope. I've thought of modifying it so that it returns a type,
but that seems difficult. The two easiest solutions I see is to
create an empty text field that holds the string or find a way to
get the rulesLoader.rules outside of the onLoad scope. Any
suggestions now? Sorry to change the problem on you. -
Please help me understand making and loading variable classes
Hi guys ,
I know that I am stupid but I just can't get this! AS3 says you need to load variables into a class? Please please give me a simple example
my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them...
but now I realse that I can't access or call them outside the movie clip they are in:(
please hlep me!
var ans1="";
var ans2="";
var w1="ABN";
var def1="An ABN (Australian Business Number), is a personal number for your business that makes it easier and quicker to deal with government and other businesses.";
var w2="ACN";
var def2="An ACN is an Australian Company Number, which is a special number that each company gets to identify it. No two companies can have the same ACN";
var w3="Action Plan";
var def3="A business Action Plan will show What needs to be done and When it needs to be done by."
var w4="Advertising";
var def4="Advertising is producing information to let people know about your business and try to increase sales."
var w5="Promotions";
var def5="Promotions are where your business tries to increase the sales of a particular item through offering a good deal, advertising or a special display.";
var w6="Benefit";
var def6="A benefit is something good that you get. One benefit of doing exercise is getting fit, another benefit is losing weight.";
var w7="Business Mentor";
var def7="A business mentor is a trusted guide. Someone who has experience and has been successful in business and can help and advise you.";
var w8="Business Name";
var def8="A Business name is the name a business uses to do its work. It lets customers know who you are.";
var w9="Business Registration";
var def9="When you start a business you need to register your ABN, you may need to register your business name.";
var w10="Cash flow";
var def10="Cash Flow for a business is having enough cash saved to be able to pay your bills when they are due.";
var w11="Characteristic";
var def11="The characteristics of something are describing words about that thing.";
var w12="Charges";
var def12="A charge is something you have to pay, an expense.";
var w13="Company";
var def13="Is the same as a corporation. A company is a type of business that needs to be registered (either State or Federal) and has special legal status. A company can put Pty. Ltd after it’s business name.";
var w14="Competitor";
var def14="A competitor is another business that is challenging you for customers.";
var w15="Constitution";
var def15="A constitution in business is a list of rules and principles that a company has agreed to follow.";
var w16="Corporations Aboriginal and Torres Strait Islander Act";
var def16="In the 1960s and 1970s, various reviews advised the Australian Government of the need for legislation to make it easier for Indigenous communities and organisations to form corporations. As a result, the ACA Act was passed, allowing Aboriginal and Torres Strait Islander groups to form corporations for any social or economic purpose.";
var w17="Corporations Act";
var def17="The Australian Securities and Investments Commission (ASIC) have laws that apply to corporations and these are found in the Corporations Act.";
var w18="Cultural knowledge";
var def18="Cultural knowledge is special information that is held by a particular cultural group, this could include technologies (e.g. special ways of using materials, making and using tools), stories, language and song, cultural rules, taboos, regulations and oral history.";
var w19="Customer";
var def19="The customer is someone who is buying something from a business.";
var w20="Debt";
var def20="Is something that you have to pay back. If you borrow 20 dollars you have a $20 debt.";
var w21="Direct competitor";
var def21="Is selling exactly the same thing as your business and competing for your customers.";
var w22="Dividend";
var def22="A dividend is money that is paid to shareholders regularly out of the company’s profits.";
var w23="(Microsoft) Excel";
var def23="Microsoft Excel is a computer program that lets you keep lists of numbers and also add up totals and do other sums to those numbers.";
var w24="Fees";
var def24="A fee is something that you have to pay, an expense.";
var w25="Financial Management";
var def25="Financial Management is the planning, organising, checking and controlling of the income, expenses and Tax for a business.";
var w26="Franchise";
var def26="A franchise is a type of business you can buy. When you buy a franchise you set up the same type of business that has been successful somewhere else.";
var w27="General ledger";
var def27="A general ledger for a business is where all of the income and expenses for that business are kept in a document.";
var w28="Goal";
var def28="A goal is a target that you set yourself or your business. Something that you want to achieve.";
var w29="Growth opportunity";
var def29="A growth opportunity is a chance for a business to get bigger.";
var w30="GST";
var def30="The Goods and Services Tax is paid when you buy things. Some items like food and medicine do not have the Goods and Services tax charged to them.";
var w31="ICN";
var def31="Indigenous Corporations Number is a special number given each indigenous corporation to identify it. No two indigenous corporations can have the same ICN.";
var w32="Incorporate";
var def32="Incorporate is what people do when they create a company or corporation.";
var w33="Indirect competitor";
var def33="An indirect competitor is selling a similar product or service to your business. E.g. If you had a pizza shop, a fried chicken shop is an indirect competitor because it sells food and your customers might want to eat chicken instead of pizza.";
var w34="Labour";
var def34="Labour is all the work done by people (including you) in your business.";
var w35="Legal name";
var def35="Your Legal Name is the name that is on your Birth Certificate.";
var w36="Legal protection";
var def36="Legal protection means you are protected under the law from certain things happening.";
var w37="Legal structure (business)";
var def37="Legal structure is the type of business, sole trader, company, partnership.";
var w38="Liability";
var def38="A liability is something you are responsible for.";
var w39="Licence";
var def39="A license is proof that you have permission to do something. For example, if you have a driving license you can drive a car.";
var w40="Lodge";
var def40="To lodge a form means to send it to where it has to go.";
var w41="Manufacturing";
var def41="A manufacturing business makes things.";
var w42="Marketing budget";
var def42="A marketing budget is the amount of money you have set aside for advertising and promotion for your business.";
var w43="Minor criminal convictions";
var def43="A minor criminal conviction is something small you have been in trouble over with the police. Shop lifting is an example of a minor criminal conviction. ";
var w44="MYOB";
var def44="MYOB is financial management software for business.";
var w45="Networks";
var def45="A network for business is all of your contacts, customers and the people you know through doing business. ";
var w46="Obligations";
var def46="Obligations are things you are responsible for.";
var w47="One off";
var def47="A “one off” cost is something that only needs to be paid for once.";
var w48="Operating budget";
var def48="The Operating Budget is a record of the income and expenses of a business.";
var w49="Overheads";
var def49="Overheads are the expenses or costs in running your business, the things you have to pay for.";
var w50="Partnership";
var def50="A partnership is where two or more people own and run a business.";
var w51="Permission";
var def51="Permission is where you ask if you can do something. If you ask and the person, group or council and they say yes, you have permission.";
var w52="Permit";
var def52="A permit is a special license or permission to do something";
var w53="Personal assets";
var def53="Personal assets are things that you own, like your car, house and furniture.";
var w54="Personal protection";
var def54="Being part of a company offers the shareholders some personal protection from legal and debt liabilities. This means that they have less responsibility than a Sole trader.";
var w55="Photo identification";
var def55="Photo Identification is a document that shows who you are and has your photo on it, like a Driver’s License, 18+ card or a passport.";
var w56="Postal address";
var def56="Your postal address is the address where you get your mail sent. It might be different to the address where you live.";
var w57="Pricing structure";
var def57="Pricing structure is where prices for something can change depending on how much the customer orders. The bigger the order the cheaper the price becomes.";
var w58="Private";
var def58="Private means not part of government.";
var w59="Profitable";
var def59="Profitable means that there is money left over after a business pays for all of its expenses out of the money it has made.";
var w60="Promote";
var def60="When you promote something you try to advertise or increase the amount of people who know about it.";
var w61="Public liability insurance";
var def61="Public Liability Insurance gives legal protection to the business owner against getting sued by a member of the public for things like injury or property damage. ";
var w62="Quickbooks";
var def62="Quickbooks is financial management software for business. ";
var w63="Registered";
var def63="Registered means that you have recorded your information on an official list. You register your car to be able to drive it on the road.";
var w64="Regulations";
var def64="Regulations are rules or laws that control what you can and can’t do.";
var w65="Retail";
var def65="Retail is where things get sold in small amounts to customers. Retail usually happens in a shop and the prices are higher.";
var w66="Service";
var def66="A Service business provides a service, like lawn mowing or accounting services.";
var w67="Shareholders";
var def67="Shareholders are people that own part of a company.";
var w68="Sole trader";
var def68="A sole trader is where one person owns and runs a business.";
var w69="Start up budget";
var def69="A Start Up Budget is the first Budget that gets done for a starting business and includes all of the costs involved in setting up the business.";
var w70="strategy";
var def70="A strategy in business is a plan of attack, or a plan of how to get something done.";
var w71="system";
var def71="A system is business is a set of detailed plans and rules for how to do something in your business.";
var w72="Vision";
var def72="Vision in business is being able to imagine and see something in the future. To set up a new business you need to be able to see something new that wasn’t there before.";
var w73="Wholesale";
var def73="Wholesale is where things get sold in large amounts, usually for a cheaper price. The Wholesale price. A wholesaler is usually a big shed where goods are stored. Wholesale is not usually available to just anyone.";no, that's not a reason you would use a class file.
anyway, your document class variables are defined on the main timeline so to reference them from any timeline you can use:
MovieClip(root).w36; // for example (but it's really undesirable to have coding in more than one timeline) -
How to load variables from a .txt file
Hi.
I usually make a flash aplication in colaboration with a php
programmer. But i want to test my swfs without having to wait for
him. So i want to do that through a text file. I know that flash
can load variables from text files. The problem is i don't know how
to format the text file ( example.txt).
Thank youHere's a couple of ideas.
First you probably want to change what you have...and put
your 'if (pVar==1' etc inside a separate function and call it from
the onLoad handler after you have assigned the value to pVar...
because the onLoad will run at some unknown point in time after
loading has finished (actually in the test environment this might
work... but that wouldn't be the same as what happens in a
production setting).
To create test files for loadvars... simply create a new as2
file and put this code on the first frame and test movie: -
Spry XML data set and dynamic post variables
Hi,
I am trying to create an XML data set that has dynamic post
variables.
Everytime something is pressed on the page a variable changes
and I then want to reload the XML data set using the new variable.
I know I can just pull in an XML with all possible variables
and filter client side but this would make it way too large.
Does anyone know what I may need to do.
I tried this:
var myVar = 0;
var dss = new Spry.Data.XMLDataSet (
'../../cgi-bin/server_details.pl' , 'top' , { method: 'POST' ,
postData: sid=ajaja21&ip=127.0.0.1&cid=' . myVar ,
subPaths: [ "auth" , "plugins" , "plugins/plugin" ] , keepSorted:
"true", sortOnLoad: "plugins/plugin/order", sortOrderOnLoad:
"descending", useCache: false, loadInterval: 10000 } );
onclick="myVar=1";
But the script doesn't understand the post variables sent (it
does when I remove the . myVar part and put in a static value). I
think it isn't sending that dynamic variable with the post
variables.
Any ideas anyone?
ThanksWell I had it working when I stripped back everything and
just had the dss data set and a single onclick function, but now
that I put it back together it hash foobared again.
Here are the relevant bits of code that I've changed.
The function to change server id:
//function to run when changing the server id
function changeServer ( sid ) {
//set the url to use the current server id
dss.setURL = ( '../../cgi-bin/server_details.pl' , { method:
'POST' , postData:
'sid=7gv1m3vjvagfl7h7qeefb8iodj8evhmb&ip=127.0.0.1&cid='+sid
//force a reload of the server data
dss.loadData();
The inital load of the data set
var dss = new Spry.Data.XMLDataSet (
'../../cgi-bin/server_details.pl' , 'yams' , { method: 'POST' ,
postData:
'sid=7gv1m3vjvagfl7h7qeefb8iodj8evhmb&ip=127.0.0.1&cid=0' ,
subPaths: [ "auth" , "plugins" , "plugins/plugin" ] , keepSorted:
"true", sortOnLoad: "plugins/plugin/order", sortOrderOnLoad:
"descending", useCache: false, loadInterval: 10000 } );
And the part that changes the server id
<td align="left" style="cursor:default; width:174px;"
onclick="changeServer({dsv::servers/server/@id})">{dsv::servers/server/name}</td>
I checked that the function is receiving the correct server
id and I even tried hard coding the cid variable to 2 in the change
function but it still wasn't changing on the server side.
Any ideas?
Thanks -
Best practices for setting environment based static variables?
I have a set of static string variables that hold the url location of modules in a project. These locations change depending on whether I'm building for development, staging or production.
What's the best way to set static variables in this way?I don't know if this is best practice, but here's the solution I've come up with.
The root domain is accessible within the swf via a node on a loaded xml file. So I created a simple method that sets a url variable based on that domain node.
The domain-based url variable is then used within the static string variables that define the location of the modules.
Simplified like so:
var domain:String = xml.node.value;
static var bucketLocation:String = getLocation()
static var moduleLocation:String = bucketLocation + "modulename.swf";
function getLocation():String
var loc:String
switch (domain) {
case stagingUrl:
loc = "pathToAmazonStagingBucket";
break;
case productionUrl:
loc = "pathToAmazonProductionBucket";
break; -
Load variables externally?
I am fairly new to flash.
Can anybody give me any advice on how to load variables from
an external file on my website that I can edit with a text editor.
I am making a flash intro to a website that has a pull-down panel
that displays information on new content on the website. It has two
variables in the main actionscript 3 code:
var gotoUrl:URLRequest = new URLRequest("
http://www.website.tld/newcontenturl")
var whatsnewText:String = "There is something new on this
website!"
The first one defines the url that a Go To button will link
to to allow the user to visit new content directly.
The second one defines the message displayed on the panel.
I am looking for a way to load these from a file I can edit
with a text editor like Notepad++ so I don't have to open flash to
update the content.
Can anyone give me any advice on how to do this?I changed something related to what that variable is used
for.
I replaced whatever with
"Text". This is used in an action that changes a dynamic
text field to say what is in the variable. So it would make a text
field say
Text. This part does work because before I tried your code I
had just set the variable in the actionscript with the var action.
instead of whatever I used
"Text" -
Please help with Load Variables / ASP
Hello,
I am using Load Variables to retreive a variable from an ASP
page, (which uses a response.write) to output the variable
getfile.onRelease = function()
myData = new LoadVars();
myData.onLoad = function(success){
if(success) {
getfile_txt.text = this.strString;
} else {
getfile_txt.text = "error";
myData.load("sendFile.asp");
stop();
the problem is that the output says "undefined", but when I
access the .asp page through my web browser I get the expected
result of the variable which is "Test1.Doc"
if any1 can help with this, i would be massivley thankful,
thanks.p.s strString is the variable that I am trying to pass from
the ASP page. -
Failed to start up. Please set proper ESSBASEPATH environment variable.
Hi,
Recently we have upgraded the 7x to 11x version, Installation looks fine and were able to migrate the zero level data as well. But when i trying to run the Load scripts i am getting the below error
**Failed to start up. Please set proper ESSBASEPATH environment variable.**
Below is my environment details
Setting Server specific environment Variables
PATH=/usr/local/bin:/bin:/usr/bin:/apps/hyperion/products/Essbase/EssbaseServer/bin:/apps/hyperion/products/Essbase/EssbaseServer:.:/apps/hyperion/products/Essbase/EssbaseServer/bin:/apps/hyperion/products/Essbase/EssbaseServer:.
ARBORPATH=/apps/hyperion/products/Essbase/EssbaseServer
LD_LIBRARY_PATH=:/apps/hyperion/products/Essbase/EssbaseServer/bin:/apps/hyperion/products/Essbase/EssbaseServer/dlls:/apps/hyperion/products/Essbase/EssbaseServer/odbc/merant41/lib:/apps/hyperion/products/Essbase/EssbaseServer/bin:/apps/hyperion/products/Essbase/EssbaseServer/dlls:/apps/hyperion/products/Essbase/EssbaseServer/odbc/merant41/lib
Can you please help me resolving this.You will also need an environment variable called ESSBASEPATH
The value will be the same as ARBORPATH
Though if you start essbase by using startEssbase.sh then it should pick up the env variables from /hyperion/products/Essbase/EssbaseServer/hyperionenv.doc
Cheers
John
http://john-goodwin.blogspot.com/ -
Load variables, remembering variables
I am trying to load variables from a text file, and have them
available from then onwards in the movie, globally so to speak.
While I can read the variable values in a loader function
which executes when the text file is loaded, I don't seem to be
able to keep those variables available afterwards.
How do I that? Isn't AS3 wonderful? :(
JohnI think you are missing the fact that things don't happen in
a sequence you write the code. The very core of events model is to
allow dealing with things happening asynchronous and at
unpredictable times while proceeding with the code.
In your example I suspect you envision that when Flash hits
the line "function urlLoader_complete(evt:Event) {" it waits until
text is loaded. This is not correct. The fact (and the beauty) of
it is that Flash goes right pass this line to the line
"trace("After: " + sspColourBG);" Naturally, sspColorBG variable is
not defined by that point.
urlLoader_complete is executed ONLY after index.as3.txt is
loaded which happens some time after.
I suggest to time your code to grasp the sequence of events.
In the example below you will observe that trace 2 comes after
trace 4:
trace("1: " + getTimer());
var sspColourBG;
function urlLoader_complete(evt:Event) {
trace("2: " + getTimer());
trace("During: " + urlLoader.data.extColourBG); // returns
correct value
trace("3: " + getTimer());
trace("After: " + sspColourBG); // returns undefined
trace("4: " + getTimer()); -
How do I set a CGI environmental variable?
Gettin the following when I try to run a CGI:
trying to POST /securecontrol-cgis/change-password.cgi, cgieng_scan_headers reports: the CGI program /usr/local/securant/securecontrol-cgis/change-password.cgi did not produce a valid header (name without value: got line "ct_cgi_propfile undefined. exiting.")
How do I set up the ct_cgi_propfile variable?Hi Bill,
There are plenty of threads on here about scope, but here's one way to create a global variable:
// code on Stage.compositionReady
sym.myGlobalVar = 1;
Then, anywhere in your project, you can check/set that var like so:
sym.getComposition().getStage().myGlobalVar = 2;
And here's one way to create a global function:
// code on Stage.compositionReady
sym.myGlobalFunction = function(){
console.log('myGlobalFunction');
Then, anywhere in your project, you can call that function like so:
sym.getComposition().getStage().myGlobalFunction(); -
Accesing externally loaded variables
i would greatly appreciate a pointer or two as i am having a
painful transition to AS2.0
an 8k zip test is at: www.cyan-animatica.com/v2/exttest.zip
//(wasn`t there an option back in macromedia days to attach a
file?)
i am having a poblem accesing externally loaded variables :
A.--------------------------------------------------------------------
the external .txt has folowing content:
&a1_0=hello&a1_1=bye&a1_2=whatever
B.--------------------------------------------------------------------
loaded on the first frame thus:
var thumbs:LoadVars = new LoadVars();
thumbs.onLoad = function(success:Boolean):Void {
if (success) {
trace("LoadVars loaded successfully: "+this.loaded);
} else {
trace("Error");
thumbs.load("my_externals.txt");
C.--------------------------------------------------------------------
if want to access one of 3 loaded variable hardcoding, this
works just fine:
trace(_root.thumbs.a1_1) //bye
BUT i need to do this based on the mc/buton name that calls
it:
on (press) {
var kk:String = _name;
trace(_root.thumbs.kk);
i get UNDEFINED...obviously i am mixing datatypes if not
worse
pc win 2000
flash prof for flash8 player[thanks for a prompt reply, blemmo.
you write:<<to ADD vars to the LoadVars object, it has
to be referenced correctly
what i want to do is READ vars from LoadVars object and
referencing is exactly what is killing me
sorry bout the lack of clarity. the zip would help
(www.cyan-animatica.com/v2/exttest.zip)
i am loading 3 variables into an object var thumbs:LoadVars
from one external .txt file:
a1_0=hello
a1_1=bye
a1_2=whatever
i want to see the contens of let us say the second variable
trace(_root.thumbs.a1_1);
produces bye , perfectly - this is exactly what i want, but i
want it based on a constructed reference
so, i have button in an mc named "a1_1", the button script
is:
on (press) {
var kk:String = _name;
trace(kk); // produces a1_1
trace(_root.thumbs.kk); //this should be same as
_root.thumbs.a1_1 and produce the same result, but does not
i suspect that the problem is that kk is declared as string
datatype, but no matter what i do i cannot get a result
thanks for your help -
Need help with Loading Variables. My old Flash MX
actionscript does not work on Flash 8... anybody know why?
HERE IS WHAT DID WORK ON FLASH MX (loads data from text file,
flashdata.txt):
loadVarsText = new loadVars();
loadVarsText.load("flashdata.txt");
// assign a function which fires when the data is loaded:
loadVarsText.onLoad = function(success) {
if (success) {
// Now that we know the data is loaded,
// set the text content of the Text Field
// with the instance name "scroller" equal to the
// contents of the variable
agent1.text = this.agent1;
agent2.text = this.agent2;
agent3.text = this.agent3;
agentemail1.text = this.agentemail1;
agentemail2.text = this.agentemail2;
agentemail3.text = this.agentemail3;
phone.text = this.phone;
} else {
trace("not loaded");I've no idea what problem you are facing,
may be you can contact Adobe for Flash support
http://www.adobe.com/support/programs/flash/?tab:contact=1 -
Hello I have a problem with my ipod touch 1G the problem is that see me key to the floor! And when recogi not prendia after 5 minutes prendio but it gave to me the surprise of which the battery had finished completely! What I did was to set it to load with the USB but do not load the battery me the icon of the battery appear and below of her the beam that indicates that this being loaded but this way I have left it the whole yesterday and what goes of today and continues without loading anything! They can help me porfavor I am grateful for them to him very much! And my PC does not detect it not itunes
Try the not-charging topic of:
iPod touch: Hardware troubleshooting
It could be that the battery is dead. -
Find text from a file and set it as a variable in applescript?
I am trying to build a script that sends me updates and notifications from cex.io. Please keep on reading below, so I may guide you until the point I have trouble with.
The first simple script in this operation goes to cex.io's trading page for BTC/GHS. It records ands saves the text to a file every 4 seconds. It works great. It doesn't need to have safari refresh because the site pushes info to the browser live.
repeat
set the webpage_content to ""
tell application "Safari" to set the webpage_content to the text of document 1
set theText to webpage_content
set a to "Macintosh HD:Users:PRIVATE:Desktop:CEX:"
set theFile to (open for access file ((a) & "CEXRaw") with write permission)
write theText to theFile
close access theFile
delay 4
end repeat
And it returns this from the site to this main file every 4 seconds: (note I cut off a chunk from the bottom and the top of the file, because they are unimportant)
GHS:
0.05233439
BTC:
0.00000223
NMC:
0.00002939
LTC:
0.00000000
GHS/BTC
0.02362958 LTC/BTC
0.02438131 NMC/BTC
0.00597565 GHS/NMC
3.96951800 BF1/BTC
1.67000000 Fund Account
GHS/BTC
Last price:
0.02362958
Daily change:
-0.00018042
Today's open:
0.02381000
24h volume:
73812.35539255
I now need an applescript to read that file, and return wanted values. But I'm lost on how to write it.
It needs to find the number under BTC, and set it as a variable.
It needs to find the number under GHS, and set it as a variable.
It needs to find the number under Last Price, and set it as a variable.
If anyone could script that really quick for me, or tell me how to do it, that would be amazing. Thank you so much!Couldn't tell if you had any whitespace in the lines (i.e. is there a space before or after GHS:), so I used contains, not is. Also, if you have a line such as GHS/BTC with a colon GHS/BTC: then it will also fail (as contains "BTC:" would be true for BTC: and GHS/BTC:)
However, this will give you some guidance:
set a to "Macintosh HD:Users:PRIVATE:Desktop:CEX:CEXRaw"
set x to 0
set Names to paragraphs of (read file a)
repeat with nextLine in Names
set x to x + 1
if nextLine contains "BTC:" then
set BTC to item (x + 1) of Names
else if nextLine contains "GHS:" then
set GHS to item (x + 1) of Names
else if nextLine contains "Last Price:" then
set lastPrice to item (x + 1) of Names
end if
end repeat
Maybe you are looking for
-
Why do fonts look different in PDFs?
When I save a Microsoft office document (Word, PowerPoint, Excel), one font does not appear correctly in the PDF. What do I do?
-
Iphoto still grayed out after iphoto upgrade after mavericks install, what should I do?
After upgrading to mavericks Iphoto was Grayed out. The computer Notified me that I would have to upgrade iphoto from 9.2.1 to to latest version. went to the mac app store, the upgrade page showed the iphoto upgrade, it downloaded and installed the u
-
Hierarchies and conditional formatting
Hi all I have a specific requirement that, based on a values of one column (let's assume 'day'), the fact data based on another column (let's assume, fact is the sales, and dim hierarcy is time), shall be displayed or not. Being more clear, an exampl
-
Zen micro Freezes at startup screen.... not go
well here is the story, i got my zen micro in feburary, and it worked good for about 3 weeks then i got that headphone jack problem, RMA'd it and got a new one This new ZM wroks awesome, or it did until about 3 days ago, i tryed starting it up and it
-
I have an Adobe loging and password from 2 yrs ago I am trying to download Adobe Reader and Adobe Flash Player. Nothing downloads so do I also need a Adobe ID? Which would be created when/how/where?