Saving Numbers

  • Hello, i'm working on a program for my work, as a night auditor at a hotel, and thought making a program do my work was easier than doing it my self - (work smarter, not harder) but the problem I've encountered is, i guess i don't know how to save a number, and manipulate it correctly. for instance. i need to enter many numbers in, save them, and then later throw them out and add,subtract,multiply and divide them. some of them saving as a new variable. i made this easily on an excel spread sheet, but figured it'd be nice if i made it stupid simple for anyone to do this. i originally thought arrays, but then i guess i don't understand them the way i thought i did, here the first page of my project.

    dropbox.com/s/46057oa091lj2qx/NightAudit.capx

  • Looks like it should be pretty straightforward.

    You could almost exactly copy your excell file, just have events to calculate the things that are calculated.

    Example for adding:

    Every tick Set Array.At(6,6): Array.At(3,6)+Array.At(4,6)+Array.At(5,6)

    You could ofcourse add events to only change things when valuea are changed.

  • i think i'm stuck on getting the TEXT BOX to save an amount to the Array. currently, i have When press next - it moves the array counter forward by one, and also saves set value at Array (arraymovement,1) and then resets the text box to ""(auto zero if no text). i have a debugger text box to show the what my number value of (1,1) is, and i think i set my array to be 1 row, with 100 slots. like i said im sure im screwing up the array somewhere.

    re sharing the cap dropbox.com/s/46057oa091lj2qx/NightAudit.capx

  • I'm not quite sure what you are doing with the ArrayMovement variable.

    Also, when ok button clicked you add 1 to arraymovement, but I don't see you setting any values in your array.

  • my text box type was text. rechecking stuff now...

  • line 4 should have been setting a number in my array

  • arraymovement, was a variable that moves the spot im putting a number, so that if a mistake was made ,yo can go back, and it just moves the place holder.

  • To set a value in an array you have to use:

    Array set value at.

    Line 4 just adds one to arraymovement and sets the text to "" and sets the textbox variable to the uid of the textbox. I'm not sure what that is supposed to do?

    You'd probably want to set the array value at (I don't know which coordinate) to int(textbox.text), after that you can reset your textbox and set the textobject you'd like to show the arrayvalue to array.At(which coordinate you've chosen)

  • The array is much like an excell sheet.

    Just imagine A1 to be Array.at(0,0) B1 to be Array.At(1,0) etcetera.

    That means A2 is the same as Array.At(0,1) B2 Array.At(1,1) etcetera.

    Through events you can set these values and create new values based on the values entered, much like adding formulas in excell.

  • i got it working correctly, you've been a huge help! thanks a ton!

  • is there anythign special about letting it hold a number with decimals?

  • By the way, all of your actions checking the variable are run every tick.

    This is unnecessary, so you should probably add a trigger once while true condition or put the checks as subevents of the event where you trigger the change.

  • hmm ok. any word on the decimal?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What do you mean by decimal?

    If the text input is 134.5 and you use set array.at(0,0) : int(textbox.text) that should be no problem.

  • thats what i thought, but its dropping decimal places completely.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)