Assigning a number value to a line from file without array
How do you assign a number value to a line from a file? I want to use the assigned number so that the i can use random number to randomly select a line
Example. i have the lines A,B,C,D,E
A
B
C
D
E
i know that a is line 1 b is line 2 so on so on
(1) A
(2)B
(3)C
(4)D
(5)E
so from here i would use the random number generator so that i could randomly select one of these. I already know how to code for the number generator but how would i make it so that i can access each individual line as a number?
ya that's what im using but reguarding the code i dont think it does what im looking for. yes it does provide a random line but wen i run it multiple times it gives me the same line repeatedly. also i need to be able to refer to that line in the future so in the code the String line gets replaced each time
BufferedReader bF = new BufferedReader(new FileReader("someFilePath"));
String line;
int someRandomNumber = 9;
int counter = 0;
while ((line = bF.readLine()) != null){
if (counter == someRandomNumber){
break;
counter++;
System.out.println(line); //line at #someRandomNumber in the file
Similar Messages
-
Assign a number value to an mc
hi everyone,
so a while back I asked if it was possible to assign a number value to an mc. So I'm done my early work on it and am ready to try and integrate this function. I'll explain what I'm trying to do and I hope someone can point me in the right direction.
I'm making a small change game. So game is split into five scenes, each scene the person will receive a receipt. The person will have change in their hand (all canadian denominations). They have to look at the receipt and the change in their hand (both mcs), and figure out if its correct. If not they drag change from another pile and place it in the hand. So here's what I'm looking at trying to accomplish. I'd like to have a check change button (simple mc). I'm guessing that each coin needs a numeric value associated with it (no clue on if or how you could do this). If the numbers add up to the predetermined bill value (so I'm guessing I'd give that a numeric value as well), i hit the check button and it'll see if the change in the hand adds up to match what the bill should. So here's where my code sits currently, still tweaking as we speak. I'm still new so be gentle on my code I know its long. If anyone knows any house keeping tips that'd be great!
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import com.greensock.*;
import com.greensock.easing.*;
import flash.media.Sound;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.StageDisplayState;
// listeners
sc1.beginbutton1.addEventListener(MouseEvent.CLICK, beginbutton1buttonclick);
bill1.addEventListener(MouseEvent.CLICK, bill1click);
sc1.checkout1.addEventListener(MouseEvent.CLICK, checkout1click);
bill2.addEventListener(MouseEvent.CLICK, bill2click);
bill3.addEventListener(MouseEvent.CLICK, bill3click);
bill4.addEventListener(MouseEvent.CLICK, bill4click);
bill5.addEventListener(MouseEvent.CLICK, bill5click);
sc1.repeatbutton1.addEventListener(MouseEvent.CLICK, repeatbutton1buttonclick);
helpmenu.xbutton.addEventListener(MouseEvent.CLICK, xbuttonclick);
bill1.billx.addEventListener(MouseEvent.CLICK, bill1billxclick);
answermenu.xanswerbutton.addEventListener(MouseEvent.CLICK, xanswerbuttonclick);
backbutton.addEventListener(MouseEvent.CLICK, backclick);
helpbutton.addEventListener(MouseEvent.CLICK, helpclick);
answerbutton.addEventListener(MouseEvent.CLICK, answerclick);
penny1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny5.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny6.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny7.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
helpmenu.visible=false;
answermenu.visible=false;
bill1.visible=false;
bill2.visible=false;
bill3.visible=false;
bill4.visible=false;
bill5.visible=false;
TweenMax.to(penny, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie4, 0.1, {scaleX:0.1, scaleY:0.1});
//variable declarations
var myTween:Tween;
var me:Object;
function grabMe(e:MouseEvent):void{
me = e.currentTarget;
me.removeEventListener(MouseEvent.MOUSE_DOWN, grabMe);
me.startDrag();
e.target.parent.addChild(e.target)
var tweeny:Tween = new Tween(me, "y", Regular.easeIn, me.y, me.y-75, .04, true);
var scaley:Tween = new Tween(me, "scaleY", Regular.easeIn, me.scaleY, 0.4, 0.05, true);
var scalex:Tween = new Tween(me, "scaleX", Regular.easeIn, me.scaleX, 0.4, 0.05, true);
var my_shadow:DropShadowFilter = new DropShadowFilter();
my_shadow.color = 0x000000;
my_shadow.blurY = 3;
my_shadow.blurX = 3;
my_shadow.angle = 90;
my_shadow.alpha = .2;
my_shadow.quality = 15;
my_shadow.distance = 100;
var filtersArray:Array = new Array(my_shadow);
me.filters = filtersArray;
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragMe);
stage.addEventListener(MouseEvent.MOUSE_UP, dropMe);
function dropMe(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, dropMe);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragMe);
me.stopDrag();
me.filters=undefined;
var tweenydown:Tween = new Tween(me, "y", Regular.easeIn, me.y, me.y+90, .4, true);
var scaley:Tween = new Tween(me, "scaleY", Regular.easeOut, me.scaleY, 0.1, 0.05, true);
var scalex:Tween = new Tween(me, "scaleX", Regular.easeOut, me.scaleX, 0.1, 0.05, true);
me.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
//lockinplace(DisplayObject(e.currentTarget))
//mainclicksound.play();
function dragMe(e:MouseEvent):void {
e.updateAfterEvent();
//nav bar items
function backclick(event:MouseEvent):void{
answermenu.visible=false;
helpmenu.visible=false;
function helpclick(event:MouseEvent):void{
helpmenu.visible=true;
answermenu.visible=false;
setChildIndex(helpmenu,numChildren - 1)
TweenMax.to(helpmenu, 3, {y:350, startAt:{y:600}, ease:Elastic.easeOut});
function xbuttonclick(event:MouseEvent):void{
helpmenu.visible=false;
function answerclick(event:MouseEvent):void{
answermenu.visible=true;
helpmenu.visible=false;
setChildIndex(answermenu,numChildren - 1)
TweenMax.to(answermenu, 3, {y:350, startAt:{y:600}, ease:Elastic.easeOut});
function xanswerbuttonclick(event:MouseEvent):void{
answermenu.visible=false;
helpmenu.visible=false;
//screen button items
function beginbutton1buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase1");
bill1.visible=true;
TweenMax.to(bill1, 0.0, {alpha:0});
TweenMax.to(bill1, 2, {delay:0.5, y:bill1.y+90});
TweenMax.to(bill1, 0.5, {delay:0.5, alpha:1});
function repeatbutton1buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase1");
function bill1click(event:MouseEvent):void{
TweenMax.to(bill1, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
function bill1billxclick(event:MouseEvent):void{
bill1.visible=false;
function checkout1click(event:MouseEvent):void{
function beginbutton2buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase2");
bill2.visible=true;
TweenMax.to(bill2, 0.0, {alpha:0});
TweenMax.to(bill2, 2, {delay:0.5, y:bill2.y+90});
TweenMax.to(bill2, 0.5, {delay:0.5, alpha:1});
function repeatbutton2buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase2");
function bill2click(event:MouseEvent):void{
TweenMax.to(bill2, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
function bill2billxclick(event:MouseEvent):void{
bill2.visible=false;
function beginbutton3buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase3");
bill3.visible=true;
TweenMax.to(bill3, 0.0, {alpha:0});
TweenMax.to(bill3, 2, {delay:0.5, y:bill3.y+90});
TweenMax.to(bill3, 0.5, {delay:0.5, alpha:1});
function repeatbutton3buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase3");
function bill3click(event:MouseEvent):void{
TweenMax.to(bill3, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
function bill3billxclick(event:MouseEvent):void{
bill3.visible=false;
function beginbutton4buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase4");
bill4.visible=true;
TweenMax.to(bill4, 0.0, {alpha:0});
TweenMax.to(bill4, 2, {delay:0.5, y:bill4.y+90});
TweenMax.to(bill4, 0.5, {delay:0.5, alpha:1});
function repeatbutton4buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase4");
function bill4click(event:MouseEvent):void{
TweenMax.to(bill4, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
function bill4billxclick(event:MouseEvent):void{
bill4.visible=false;
function beginbutton5buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase5");
bill5.visible=true;
TweenMax.to(bill5, 0.0, {alpha:0});
TweenMax.to(bill5, 2, {delay:0.5, y:bill5.y+90});
TweenMax.to(bill5, 0.5, {delay:0.5, alpha:1});
function repeatbutton5buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase5");
function bill5click(event:MouseEvent):void{
TweenMax.to(bill5, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
function bill5billxclick(event:MouseEvent):void{
bill5.visible=false;
//function beginbutton2buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase2");
//function repeatbutton2buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase2");
//function beginbutton3buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase3");
//function repeatbutton3buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase3");
//function beginbutton4buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase4");
//function repeatbutton4buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase4");
//function beginbutton5buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase5");
//function repeatbutton5buttonclick(event:MouseEvent):void{
//sc1.gotoAndStop("phase5");ok so i got the trace working when I drop a coin on the hand mc. How would you make it so that when you hit the checkout button, you can see if the myValue items add up to a specific amount? Here's my revised code!
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import com.greensock.*;
import com.greensock.easing.*;
import flash.media.Sound;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.StageDisplayState;
// listeners
helpmenu.xbutton.addEventListener(MouseEvent.CLICK, xbuttonclick);
answermenu.xanswerbutton.addEventListener(MouseEvent.CLICK, xanswerbuttonclick);
backbutton.addEventListener(MouseEvent.CLICK, backclick);
helpbutton.addEventListener(MouseEvent.CLICK, helpclick);
answerbutton.addEventListener(MouseEvent.CLICK, answerclick);
sc1.beginbutton1.addEventListener(MouseEvent.CLICK, beginbutton1buttonclick);
bill1.addEventListener(MouseEvent.CLICK, bill1click);
sc1.checkout1.addEventListener(MouseEvent.CLICK, checkout1click);
sc1.checkout2.addEventListener(MouseEvent.CLICK, checkout2click);
sc1.checkout3.addEventListener(MouseEvent.CLICK, checkout3click);
sc1.checkout4.addEventListener(MouseEvent.CLICK, checkout4click);
sc1.checkout5.addEventListener(MouseEvent.CLICK, checkout5click);
bill2.addEventListener(MouseEvent.CLICK, bill2click);
bill3.addEventListener(MouseEvent.CLICK, bill3click);
bill4.addEventListener(MouseEvent.CLICK, bill4click);
bill5.addEventListener(MouseEvent.CLICK, bill5click);
bill1.billx1.addEventListener(MouseEvent.CLICK, bill1billx1click);
bill2.billx2.addEventListener(MouseEvent.CLICK, bill2billx2click);
bill3.billx3.addEventListener(MouseEvent.CLICK, bill3billx3click);
bill4.billx4.addEventListener(MouseEvent.CLICK, bill4billx4click);
bill5.billx5.addEventListener(MouseEvent.CLICK, bill5billx5click);
five.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
five1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
five2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny5.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny6.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
penny7.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
dime4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel1.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
nickel4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
quarter4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
loonie4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie2.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie3.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
toonie4.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
bill1.visible=false;
sc1.checkout1.visible=false;
sc1.checkout2.visible=false;
sc1.checkout3.visible=false;
sc1.checkout4.visible=false;
sc1.checkout5.visible=false;
bill2.visible=false;
bill3.visible=false;
bill4.visible=false;
bill5.visible=false;
BS.visible=false;
hand.visible=false;
hitbox.mouseEnabled = false;
helpmenu.visible=false;
answermenu.visible=false;
TweenMax.to(five, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(five1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(five2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(dime4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel1, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie4, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie2, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie3, 0.1, {scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie4, 0.1, {scaleX:0.1, scaleY:0.1});
///assigned values
var myValue;
penny1.myValue = .01;
penny2.myValue = .01;
penny3.myValue = .01;
penny4.myValue = .01;
penny5.myValue = .01;
penny6.myValue = .01;
penny7.myValue = .01;
penny.myValue = .01;
dime1.myValue = .10;
dime2.myValue = .10;
dime3.myValue = .10;
dime4.myValue = .10;
dime.myValue = .10;
nickel1.myValue = .05;
nickel2.myValue = .05;
nickel3.myValue = .05;
nickel4.myValue = .05;
nickel.myValue = .05;
quarter2.myValue = .25;
quarter3.myValue = .25;
quarter4.myValue = .25;
quarter.myValue = .25;
toonie2.myValue = 2.0;
toonie3.myValue = 2.0;
toonie4.myValue = 2.0;
toonie.myValue = 2.0;
loonie2.myValue = 1.0;
loonie3.myValue = 1.0;
loonie4.myValue = 1.0;
loonie.myValue = 1.0;
//variable declarations
var pickupsound:pickup=new pickup
var coinonhandsound:coinonhand=new coinonhand
var coinpickupsound:coinpickup=new coinpickup
var coindropsound:coindrop=new coindrop
var droppapersound:droppaper=new droppaper
//var clickssound:clicks=new clicks
var myTween:Tween;
var me:Object;
function grabMe(e:MouseEvent):void{
me = e.currentTarget;
me.removeEventListener(MouseEvent.MOUSE_DOWN, grabMe);
me.startDrag();
e.target.parent.addChild(e.target)
coinpickupsound.play();
var tweeny:Tween = new Tween(me, "y", Regular.easeIn, me.y, me.y-75, .04, true);
var scaley:Tween = new Tween(me, "scaleY", Regular.easeIn, me.scaleY, 0.4, 0.05, true);
var scalex:Tween = new Tween(me, "scaleX", Regular.easeIn, me.scaleX, 0.4, 0.05, true);
var my_shadow:DropShadowFilter = new DropShadowFilter();
my_shadow.color = 0x000000;
my_shadow.blurY = 3;
my_shadow.blurX = 3;
my_shadow.angle = 90;
my_shadow.alpha = .2;
my_shadow.quality = 15;
my_shadow.distance = 100;
var filtersArray:Array = new Array(my_shadow);
me.filters = filtersArray;
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragMe);
stage.addEventListener(MouseEvent.MOUSE_UP, dropMe);
function dropMe(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, dropMe);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragMe);
me.stopDrag();
me.filters=undefined;
var scaley:Tween = new Tween(me, "scaleY", Regular.easeOut, me.scaleY, 0.1, 0.05, true);
var scalex:Tween = new Tween(me, "scaleX", Regular.easeOut, me.scaleX, 0.1, 0.05, true);
me.addEventListener(MouseEvent.MOUSE_DOWN, grabMe);
lockinplace(DisplayObject(e.currentTarget))
function dragMe(e:MouseEvent):void {
e.updateAfterEvent();
function lockinplace(e:DisplayObject):void{
//hand
if(hand.hitTestPoint(mouseX, mouseY, true)){
coinonhandsoundplay();
trace(me.myValue)
TweenMax.to(me,0.5,{x:mouseX,y:700, scaleX:0.2,scaleY:0.2,ease:Bounce.easeOut});
//table
//}else if(hitbox.hitTestPoint(mouseX, mouseY, true)){
//TweenMax.to(me,0.2,{x:700, y:700, scaleX:0.3,scaleY:0.3,ease:Bounce.easeInOut});;
//coinonhandsoundplay();
} else {
coindropsoundplay();
TweenMax.to(me,0.5,{x:mouseX, y:700, scaleX:0.1,scaleY:0.1,ease:Bounce.easeOut});;
//screen button items
function beginbutton1buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase1");
hand.visible=true;
bill1.visible=true;
sc1.checkout1.visible=true;
sc1.checkout2.visible=false;
sc1.checkout3.visible=false;
sc1.checkout4.visible=false;
sc1.checkout5.visible=false;
TweenMax.to(toonie2, 0.1, {x:655, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {x:625, y: 639, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:635, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:655, y: 635, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(bill1, 0.0, {alpha:0});
TweenMax.to(bill1, 2, {delay:0.5, y:bill1.y+90});
TweenMax.to(bill1, 0.5, {delay:0.5, alpha:1});
function bill1click(event:MouseEvent):void{
TweenMax.to(bill1, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
pickupsound.play();
function bill1billx1click(event:MouseEvent):void{
bill1.visible=false;
droppapersound.play();
function checkout1click(event:MouseEvent):void{
sc1.gotoAndStop("phase2begin");
sc1.beginbutton2.addEventListener(MouseEvent.CLICK, beginbutton2buttonclick);
TweenMax.to(penny7, 0.0, {x:497.15, y:586.10, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie2, 0.0, {x:423.15, y: 622.50, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.0, {x:506.70, y: 622.25, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.0, {x:460, y: 587.20, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.0, {x:418.35, y: 589.90, scaleX:0.1, scaleY:0.1});
bill1.visible=false;
hand.visible=false;
sc1.checkout1.visible=false;
function beginbutton2buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase2");
hand.visible=true;
bill2.visible=true;
sc1.checkout2.visible=true;
sc1.checkout1.visible=false;
sc1.checkout3.visible=false;
sc1.checkout4.visible=false;
sc1.checkout5.visible=false;
TweenMax.to(loonie4, 0.1, {x:655, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie2, 0.1, {x:625, y: 639, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie3, 0.1, {x:635, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {x:655, y: 635, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter4, 0.1, {x:655, y: 635, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime1, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(bill2, 0.0, {alpha:0});
TweenMax.to(bill2, 2, {delay:0.5, y:bill2.y+90});
TweenMax.to(bill2, 0.5, {delay:0.5, alpha:1});
function bill2click(event:MouseEvent):void{
TweenMax.to(bill2, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
pickupsound.play();
function bill2billx2click(event:MouseEvent):void{
bill2.visible=false;
droppapersound.play();
function checkout2click(event:MouseEvent):void{
sc1.gotoAndStop("phase3begin");
sc1.beginbutton3.addEventListener(MouseEvent.CLICK, beginbutton3buttonclick);
TweenMax.to(loonie4, 0.1, {x:462.15, y: 623.40, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie2, 0.1, {x:459.15, y: 627.40, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie3, 0.1, {x:463.15, y: 631.75, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {x:506.70, y: 622.25, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter4, 0.1, {x:504.70, y: 625.30, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:497.15, y: 586.10, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:500.15, y: 586.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {x:498.15, y: 588.60, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {x:500.15, y: 589.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny3, 0.1, {x:498.15, y: 591.65, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny2, 0.1, {x:499.15, y: 593.15, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:418.35, y: 589.90, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime1, 0.1, {x:416.35, y: 591.40, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:460, y: 587.20, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {x:457.15, y: 589.75, scaleX:0.1, scaleY:0.1});
bill2.visible=false;
hand.visible=false;
sc1.checkout2.visible=false;
function beginbutton3buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase3");
hand.visible=true;
bill3.visible=true;
sc1.checkout3.visible=true;
sc1.checkout2.visible=false;
sc1.checkout1.visible=false;
sc1.checkout4.visible=false;
sc1.checkout5.visible=false;
TweenMax.to(quarter3, 0.1, {x:655, y: 635, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny1, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime1, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel4, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel1, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(bill3, 0.0, {alpha:0});
TweenMax.to(bill3, 2, {delay:0.5, y:bill3.y+90});
TweenMax.to(bill3, 0.5, {delay:0.5, alpha:1});
function bill3click(event:MouseEvent):void{
TweenMax.to(bill3, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
pickupsound.play();
function bill3billx3click(event:MouseEvent):void{
bill3.visible=false;
droppapersound.play();
function checkout3click(event:MouseEvent):void{
sc1.gotoAndStop("phase4begin");
sc1.beginbutton4.addEventListener(MouseEvent.CLICK, beginbutton4buttonclick);
TweenMax.to(quarter3, 0.1, {x:506.70, y: 622.25, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:497.15, y: 586.10, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:500.15, y: 586.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {x:498.15, y: 588.60, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {x:500.15, y: 589.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny3, 0.1, {x:498.15, y: 591.65, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny2, 0.1, {x:499.15, y: 593.15, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny1, 0.1, {x:497.70, y: 594.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:418.35, y: 589.90, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime1, 0.1, {x:416.35, y: 591.40, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime2, 0.1, {x:417.15, y: 593.25, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:460, y: 587.20, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {x:457.15, y: 589.75, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel4, 0.1, {x:459.15, y: 592.05, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel1, 0.1, {x:458.15, y: 595.20, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel, 0.1, {x:459.15, y: 597.20, scaleX:0.1, scaleY:0.1});
bill3.visible=false;
hand.visible=false;
sc1.checkout3.visible=false;
function beginbutton4buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase4");
hand.visible=true;
bill4.visible=true;
sc1.checkout4.visible=true;
sc1.checkout2.visible=false;
sc1.checkout3.visible=false;
sc1.checkout1.visible=false;
sc1.checkout5.visible=false;
TweenMax.to(five2, 0.1, {x:655, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:654, y: 644, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:645, y: 650, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:662, y: 642, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(bill4, 0.0, {alpha:0});
TweenMax.to(bill4, 2, {delay:0.5, y:bill4.y+90});
TweenMax.to(bill4, 0.5, {delay:0.5, alpha:1});
function bill4click(event:MouseEvent):void{
TweenMax.to(bill4, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
pickupsound.play();
function bill4billx4click(event:MouseEvent):void{
bill4.visible=false;
droppapersound.play();
function checkout4click(event:MouseEvent):void{
sc1.gotoAndStop("phase5begin");
sc1.beginbutton5.addEventListener(MouseEvent.CLICK, beginbutton5buttonclick);
TweenMax.to(five2, 0.1, {x:460.15, y: 553.10, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:497.15, y: 586.10, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:500.15, y: 586.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:418.35, y: 589.90, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:460, y: 587.20, scaleX:0.1, scaleY:0.1});
bill4.visible=false;
hand.visible=false;
sc1.checkout4.visible=false;
function beginbutton5buttonclick(event:MouseEvent):void{
sc1.gotoAndStop("phase5");
hand.visible=true;
bill5.visible=true;
sc1.checkout5.visible=true;
sc1.checkout2.visible=false;
sc1.checkout3.visible=false;
sc1.checkout4.visible=false;
sc1.checkout1.visible=false;
TweenMax.to(five2, 0.1, {x:655, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie2, 0.1, {x:655, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie3, 0.1, {x:622, y: 639, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie4, 0.1, {x:625, y: 639, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie4, 0.1, {x:658, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie2, 0.1, {x:625, y: 639, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie3, 0.1, {x:635, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {x:655, y: 635, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(bill5, 0.0, {alpha:0});
TweenMax.to(bill5, 2, {delay:0.5, y:bill5.y+90});
TweenMax.to(bill5, 0.5, {delay:0.5, alpha:1});
function bill5click(event:MouseEvent):void{
TweenMax.to(bill5, 0.5, {x: 780, y:25, scaleX: 0.6, scaleY: 0.6});
pickupsound.play();
function bill5billx5click(event:MouseEvent):void{
bill5.visible=false;
droppapersound.play();
function checkout5click(event:MouseEvent):void{
BS.visible=true;
hand.visible=false;
bill5.visible=false;
sc1.checkout5.visible=false;
TweenMax.to(five2, 0.1, {x:460.15, y: 553.10, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie2, 0.1, {x:423.15, y: 622.50, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie3, 0.1, {x:415.70, y: 622.70, scaleX:0.1, scaleY:0.1});
TweenMax.to(toonie4, 0.1, {x:420.15, y: 627.70, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie4, 0.1, {x:462.15, y: 623.40, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie2, 0.1, {x:459.15, y: 627.40, scaleX:0.1, scaleY:0.1});
TweenMax.to(loonie3, 0.1, {x:463.15, y: 631.75, scaleX:0.1, scaleY:0.1});
TweenMax.to(quarter3, 0.1, {x:506.70, y: 622.25, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny7, 0.1, {x:497.15, y: 586.10, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny6, 0.1, {x:500.15, y: 586.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny5, 0.1, {x:498.15, y: 588.60, scaleX:0.1, scaleY:0.1});
TweenMax.to(penny4, 0.1, {x:500.15, y: 589.95, scaleX:0.1, scaleY:0.1});
TweenMax.to(dime3, 0.1, {x:660, y: 640, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel2, 0.1, {x:460, y: 587.20, scaleX:0.1, scaleY:0.1});
TweenMax.to(nickel3, 0.1, {x:457.15, y: 589.75, scaleX:0.1, scaleY:0.1});
//sound items
//function bellsoundplay():void{
//bellsound.play();
//sound items
function pickupsoundplay():void{
pickupsound.play();
//sound items
function coinpickupsoundplay():void{
coinpickupsound.play();
//sound items
function coindropsoundplay():void{
coindropsound.play();
function coinonhandsoundplay():void{
coinonhandsound.play();
function droppapersoundplay():void{
droppapersound.play();
//nav bar items
function backclick(event:MouseEvent):void{
answermenu.visible=false;
helpmenu.visible=false;
function helpclick(event:MouseEvent):void{
helpmenu.visible=true;
answermenu.visible=false;
setChildIndex(helpmenu,numChildren - 1)
TweenMax.to(helpmenu, 3, {y:350, startAt:{y:600}, ease:Elastic.easeOut});
function xbuttonclick(event:MouseEvent):void{
helpmenu.visible=false;
function answerclick(event:MouseEvent):void{
answermenu.visible=true;
helpmenu.visible=false;
setChildIndex(answermenu,numChildren - 1)
TweenMax.to(answermenu, 3, {y:350, startAt:{y:600}, ease:Elastic.easeOut});
function xanswerbuttonclick(event:MouseEvent):void{
answermenu.visible=false;
helpmenu.visible=false; -
I want to read lines from file, count it and extract numbers from a first line.
i must do un loop?
HI,
i try to explain how to use to LABVIEW TOOLS...
1. USE a for next loop
2. here you must open the file with the VI. read lines from file.
you can choos how many lines you read at same time.
3. the string you can convert into an number.
4. in the loop is the literal counter... this is you line couter....
iun schrieb:
> i must do un loop? -
Number of 1s or 0s from a boolean array
How to find the number of 1s or 0s from a boolean array. e.g. in 101011, there are four 1s and two 0s.
Solved!
Go to Solution.ABBPAK ha scritto:
Hi,
When you talk about the value change, how to predefine the first value and the last value. e.g. 1100011. here just twice a time value changes but there are four 1s and three 0s.
thanks
Did you focus on the word "sort"?
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
[Solved] Shell script to read unhashed lines from file.
Hello.
I want to write a shell script (it can be bash,sh,ksh,csh or zsh) that will be:
1.Read unhashed lines from file named mirrors.conf.
2.Put them in ~/.profile as PKG_PATH=line catted from mirrors.conf.
Just like as mirrors.conf file for pacman.
Now it can cat lines but how to put them in files as PKG_PATH?
Thanks for answers.
Last edited by SpeedVin (2010-03-01 17:33:20)res wrote:
^ IFS is not necessary here; it won't mess with the white space:
$ echo 'args with formatted spaces ' | while read -r; do echo "$REPLY"; done
args with formatted spaces
It matters for leading/trailing whitespace:
$ echo ' after some ' | while read -r line; do echo "<$line>"; done
<after some>
$ echo ' after some ' | while IFS= read -r line; do echo "<$line>"; done
< after some > -
Delete X number of lines from files
I am trying to find a way (either through an extension or
some other third-party freeware) to remove a number of lines from
the beginning of my files and replace them with alternate code.
I know that in many cases, a Search and Replace would do the
trick. But in my case, the lines that I want replaced do not
exactly match. For example, I might want to remove the first 15
lines from the beginning of each file in question; however, I might
have three lines of code in the files that each set a variable
value, with that value being different in each file. Thus, as far
as I understand it, the DW Search and Replace would not work for
me.
Even if I have can just find some way to first strip the
lines of code out without replacing it with the new code I want,
that would be fine. Adding in the new code afterwards would not be
an issue.
Any help would be very much appreciated. Thank you very much.
JamesOn Mon, 7 May 2007 17:14:52 +0000 (UTC), "MUSC Webmaster"
<[email protected]> wrote:
> Gary: Thanks for the suggestion; however it wasn't quite
working for me.
>After your posting, I played around for a bit with
regular expressions and the
>best that I could do was get an expression (^.*\r) that
grabbed all of the
>first line, with the "r" representing a carriage return
as opposed to a line
>feed. If I try to expand on that expression, the search
results come up with
>nothing.
Actually the linfeed is the \n in my suggestion. The ^
designates the
beginning of the string.
Are you on a Mac? I tested it and it worked correctly on my
windows
machine. Come to think of it, I have my line feeds set to
Unix because
that's what my web server uses. You can try replacing the \n
with \r or
\n\r depending on which line feed you're using:
^.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r.*\r
or:
^.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\n.*\r\ n
One of the three should work.
Gary -
Dear All,
I have an inbound file to PI.
In the file, there are few lines which are not to be used ... those appear in the top, bottom as well as somewhere in the middle of the file.
I know how to take care of undesired lines from the top, but how to take care of those coming in the middle and the bottom? The number of rows for these undesired extra lines in top, middle and bottom of the file will always be fixed.
Example:-
TOP_LINE1 (Extra line)
TOP_LINE2 (Extra line)
DATA_LINE1
MID_LINE1 (Extra line - HELP required)
MID_LINE2 (Extra line - HELP required)
DATA_LINE1
BOTTOM_LINE1 (Extra line - HELP required)
BOTTOM_LINE2 (Extra line - HELP required)
BOTTOM_LINE3 (Extra line - HELP required)
As I mentioned earlier, the number of rows for these extra lines will always be fixed.
Any suggestions / help will be highly appreciated.
Thanks,
--AbhiThanks Michal for your reply.
But my scenario is a little complex. I will explain here.
1. The file is having data for CONSUMERS and PROVIDERS.
2. After the top_line undesired rows, is the section for the CONSUMERS.
3. After the mid_line undesired rows, is the section for the PROVIDERS.
4. In the file CC, if I specify RECORDSET STRUCTURE - CONSUMERS,,PROVIDERS, - it complains for keyfieldname.
What am I supposed to put in keyfieldname? I don't have any ...
A sample of the inbound file:-
,,,,,"Division",,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,Inventory Report,,,,,,,,,,,,,,,,,,,,,,,,,
Consumer Owner : ABC ,,,,
Consumer :,,,,
Name,Contact,ID,Addr1,Addr2
John White,203 111 2222,1234,,
J D Edwards, 732 020 1121,South West Drive,NJ
Number of Consumers : 201,,,,
Providers :,,,,
ProviderName,Location,LicenseNumber,Contact
ABC,NJ,1001,1800 000 0001
DEF,NY,1005,1 888 000 0001
Number of Providers : 102,,,,
,Summary,,,
I just need the data from the bold rows. Rest of the rows should be discarded. I have desinged the structure like this -
<MT>
<rec>
<Consumer><Name> ... </Consumer>
<Provider><ProviderName>...</Provider>
</rec>
</MT>
Hope the requirement is clear. Kindly help.
Thanks a lot,
--Abhi -
Delete some lines from file...
Hi,
I'm using this code
File file = new File(sFile);
if (!file.exists())
file.createNewFile();
fout = new PrintWriter(new OutputStreamWriter(new FileOutputStream(sFile , true)) , true);
PrintWriter fout;
...When file has more then (let's write) 1000 lines, I want to delete last 100 from file.
Can someone help me to do that? Can you posto me a part of code which will done that?
Thanks.If you want to use "standard" (serial) IO, which reads from the beginning of the file, create a line counter, read the file line-by-line, and when the file size limil is reached, close the file - remaining lines will be truncated from the file.
If the file lines are all equal in length, then you can use the RandomAccessFile methods to directly seek to the desired line and delete lines after that point using the class methods - see the seek and setLength methods. -
Getting data from file to array
try
System.out.println("Enter file name: ");
fileName = Object.nextLine();
BufferedReader inputStream =
new BufferedReader(new FileReader(fileName));
String employee = null;
employee = inputStream.readLine();
System.out.println("The first employee in " + fileName + " is");
System.out.println(employee);
inputStream.close();
catch(FileNotFoundException e)
System.out.println("File " + fileName + " not found ");
catch(IOException e)
System.out.println("Error reading from file " + fileName);
}This is just a little example I made. You can look at my other thread to see the other code. I need to put the data in a file into the array. Does it need to be casted somehow?public void getData()
try {
System.out.println("Enter file name to read: ");
File = Object.nextLine();
BufferedReader Object =
new BufferedReader(new FileReader(File));
for(int i = 0; i < people.length && people[i] != null; i++)
String temp = Object.readLine();
people.setLastname(temp);
temp = Object.readLine();
people[i].setFirstname(temp);
temp = Object.readLine();
people[i].setID(temp);
temp = Object.readLine();
people[i].setPhone(temp);
temp = Object.readLine();
people[i].setYearlySalary(Double.parseDouble(temp));
temp = Object.readLine();
people[i].calcBonus(Double.parseDouble(temp));
temp = Object.readLine();
people[i].getMonthlyPay(temp));
} Object.close(); }I know, I got careless with the naming. I'm trying a different route now. I think I can just do it in reverse. lol How would I get the method getMonthlyPay to have no errors. It's a public void() method with monthlyPay = (yearlySalary + bonus) / 12; in its definition.
anyone?
Edited by: Program_1 on Dec 9, 2007 5:42 PM -
Posting idocs in sequence in SAP from file (without BPM)
Hi,
I have a requirement of posting the TWO idocs from the single file. But I need to send the idocs in sequence. Can you anyone explain the process how we can ecomplish from XI without using BPM.Hi,
you can ONLY do that if your <b>ERP,R3 (IDOC receiver system) system
is based on WAS 6.40</b>
the whole scenario is described step by step in my book:
<a href="/people/michal.krawczyk2/blog/2006/10/11/xi-new-book-mastering-idoc-business-scenarios-with-sap-xi"><b>Mastering IDoc Business Scenarios with SAP XI</b></a>
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
How to loop through xml records from file without ROW , /ROW tags?
I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?
I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?
-
Converting string from file to array
I'm new to LabVIEW and have been thrown into the middle of a project, so I need to get some code working fast! Can someone help me understand why the VI I've attached isn't working? I want to have a text file that contains a list of integers that will be used to reference particular elements in arrays within my program. I tried to follow an example I found, but the output that should be an array is coming out as a scaler. Any help would be super appreciated! Thanks!
Solved!
Go to Solution.
Attachments:
string_to_array.vi 9 KB
exp.txt 1 KBFirst, let's explain the reason for your error: The reason why it's happening is that you're trying to do two different things at the same time. You're auto-indexing the array and you're trying to index the array inside the loop. When you wire an array to a for loop it auto-indexes the loop. Meaning LabVIEW knows how many times to run the loop - there is no need to wire to the N terminal. Also, the wire inside the loop will be an instance of the element of the array, not the array. So, the wire inside the loop is a scalar. Thus, the reason for the broken wire - you can't index a scalar.
Also, I'm not sure what you're trying to do with the indexing of the one element of the cluster. The cluster is empty, so there's nothing to index. Presumably the file is there to tell you which elements to pull out from the "Amp2" array from the cluster. If so, remember that auto-indexing works both ways. If you connect an "outbound" wire to the edge of a loop it auto-indexed there as well, meaning the output will be an array.
Please read the LabVIEW Help on auto-indexing.
Now, given all of that, here is what your code should look like:
Note the use of the Read From Spreadsheet File VI. It makes your life easier.
Attachments:
fixed code.png 22 KB -
Hi. I use buffered reader to read from a file. The file contains a line of strings (04/21/2005 some text bla bla here). Each line ends with a \n, to define that its the end of the line. How can i print this out, so each line is printed on a new line? Suggestions?
String filename = "someFile.txt";
BufferedReader infile = new BufferedReader(new FileReader(filename));
String read;
while ((read = infile.readLine()) != null)
//print each line, but how?
infile.close();I was wondering if the \n defines that its "end of
line" so that all strings between the \n is
understood as one line.Yes. It may also be \r\n, depending on the platform. It's one of the System properties. line.delimiter, I think.
Allso, when i print with
System.out.println(infile); only
java.io.BufferedReader@691177 is printed. Do I have
to parse it in any way?No. You normally can't "print" an object. All you'll do is print out the result of the object's toString() method, which usually returns the class name and the object's hash code.
And you should keep in mind that a File object is only a representation of the file's name. It has no access to the file's contents. -
Fire an event automatically after reading line from file
Hi all
I am writing a programe in which i need to fire an event automatically after reading each line (i.e. on every EOL) from the file.
Thanks
jonjonhill wrote:
..I am writing a programe in which i need to fire an event automatically after reading each line (i.e. on every EOL) from the file.Thanks for sharing that with us. Let us know how it goes. If you have any questions, feel free to ask them.
BTW - sounds like a very weird requirement. -
Read from file without space at the end
i want to read some data from a simple text file. when there is a space after the number in the, that number is read successfully. but when there is no space after that number, the code fails. it seems that sun fortran compiler can not read the number when there is the new line sign exactly after the number.
is there any compiler switch of an option in read or open statement to overcome this problem?
i checed the code with other compilers (gfortran and intel fortran compiler) and they work fine.
RegardsI have not been able to reproduce the problem you describe.
Could you provide a small program and a data file that
demonstrates the problem? Also, please let me know which
version of the compiler you are using. You can find which
version you are using by specifying the option -V on the
compiler command line.
Robert Corbett
Maybe you are looking for
-
Please wait while windows configures hp product assistant
To HP and Company 9 Jan 2014 I kept getting the following message in red on my Windows 7 Dell Computer so I did everything the help sites told me to do and nothing helped. I got rid of all HP files and the problem went away. I ordered the CD softwa
-
Help File to Be Integrated with Sap System
Dear sir Please get me how to integrate the help file[ERP 2004 help ] with SAP System. I M Not able to get the help from the system the error it throw is no document available i want the help of .chm file so is there any way to integrate that file wi
-
Is Oracle Form can read bar code scanner ?
Hi everybody, I would like to develop an application for a video club with oracle form. Can anyone tell me how can do or just say if it is possible or not Thanks a lot. Shafique Mahmood
-
Hi, I have a question. Our team was tuning a query where we needed to select a date column based solely on the month. We used between and it was very costly. Then we tried date_column_name = to_date('NOV-2002','MMM-YYYY') That sped it up considerably
-
I've been trying to register for Portal Developer Services (http://portalstudio.oracle.com/servlet/page?_pageid=3237&_dad=ops&_schema=OPSTUDIO&10024.1.15566_SELFREGISTRATION_10024.next_page=signup.jsp) It times out (I've tried many times). Please loo