Author Topic: String and variable questions  (Read 4997 times)

0 Members and 1 Guest are viewing this topic.

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
String and variable questions
« on: November 11, 2010, 12:44:41 am »
(My activity will be very sporadic this week and the next. If you have any server issues/questions, please direct them to Juju and geekboy.)

I'm making a viral video for a club at my school, and guess what? A calc, and a compiled Axe program will be involved! :D
It'll be a very quick and dirty browser GUI simulation. (Real internet via tethered link/USB will be coming soon via C2I though! :))
I'll post the final program when it's done, as well as a snip of the viral video.
However, I've encountered some problems while writing it.

I have 2 questions - first, I can't seem to change the text in the variable.
I tried this:
Code: [Select]
"text"->Str0
...
"different text"->Str0
It always errors with "ERR: DUPLICATE". After looking back at the manual, it seemed that Str* and some other variables
were static, which meant that you can't change them. However, other variables could be changed.

So, I switched to this:
Code: [Select]
"text"->R
...
"different text"->R
...and then this time, I get another error: "ERR: BAD SYMBOL", and the error scrolls to the first def. line.
Looks like I can't put anything into any variable, eh? :P (Or I might have read the manual wrong)
How can I change the text at any time in a variable? Please provide a simple code example.

My second question: is there any way to print text to the back buffer directly without altering the screen or the 1st buffer?
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: String and variable questions
« Reply #1 on: November 11, 2010, 11:09:43 am »
Quick post bump, since this was posted at midnight. :)

Any solutions? :D
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: String and variable questions
« Reply #2 on: November 11, 2010, 11:22:15 am »
I'm also getting DUPLICATE erros, ALL PROGRAMMING LANGUAGES ALLOW CHANGING VARIABLES but Axe :'(

Maybe DelVar?

I don't know, I get the same error :'(

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: String and variable questions
« Reply #3 on: November 11, 2010, 01:04:22 pm »
Well, for the second question, if what's displayed on the screen is identical to the buffer, you could use
Code: [Select]
Fix 5
RecallPic          //back-buffer to buffer
Text Commands here
StorePic           //buffer to back-buffer
StoreGDB           //screen to buffer
« Last Edit: November 11, 2010, 01:04:56 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: String and variable questions
« Reply #4 on: November 11, 2010, 02:06:15 pm »
You cannot chance Strings or data once you have initialized them unfortunately.  This is not supported in Axe.  A way to get around that would be this:

"0123"->Str1  //Takes up 5 bytes
Zeros(20)      //Add on an extra 20 bytes of empty data just in case the string gets bigger

Then to change it:

Copy("12345",Str1,6)  //Copy new data into the same spot, the length is 6 including the terminating character

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: String and variable questions
« Reply #5 on: November 11, 2010, 04:30:06 pm »
I'm also getting DUPLICATE erros, ALL PROGRAMMING LANGUAGES ALLOW CHANGING VARIABLES but Axe :'(

Maybe DelVar?

I don't know, I get the same error :'(

They're not really variables. They're just data inside the program that's "named" Str1. And so the problem with replacing it would be that anything longer would overwrite what came after the original data (that's why Builderboy's code has the Zeroes( thing).




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: String and variable questions
« Reply #6 on: November 11, 2010, 04:34:25 pm »
I'm also getting DUPLICATE erros, ALL PROGRAMMING LANGUAGES ALLOW CHANGING VARIABLES but Axe :'(

Maybe DelVar?

I don't know, I get the same error :'(

They're not really variables. They're just data inside the program that's "named" Str1. And so the problem with replacing it would be that anything longer would overwrite what came after the original data (that's why Builderboy's code has the Zeroes( thing).

Yeah, I found out how to work it through already :) thanks

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: String and variable questions
« Reply #7 on: November 11, 2010, 10:40:18 pm »
C2I soon?  I'm still working on usb... But, brandonw really helped me on hwcp last night. ;-)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: String and variable questions
« Reply #8 on: November 11, 2010, 11:44:43 pm »
You could always do this:
Code: [Select]
"text"->Str0
...
"different text"->Str1
...
If something
Str0->A
Else
Str1->A
End
...
Text(X,Y,A)

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: String and variable questions
« Reply #9 on: November 14, 2010, 10:28:33 am »
Use a variable pointer to point to the data...
I'm not sure I would have thought of that O_o
That should work, ztrumpet! :)
Now just to see what ScoutDavid thinks.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.