Author Topic: question for searching  (Read 13572 times)

0 Members and 1 Guest are viewing this topic.

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Re: Axe Programming
« Reply #30 on: May 06, 2013, 02:04:16 pm »
look at my last post:do you  mabey know another code???
« Last Edit: May 06, 2013, 02:04:42 pm by alex99 »
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Axe Programming
« Reply #31 on: May 06, 2013, 02:06:06 pm »
Avoid double posting within 6 hours. Use the edit button instead.
What exactly do you have in Str4 ? Dou you have just "PROGNAME" in it or do you have "prgmPROGNAME" (where PROGNAME is the name of your program) ?
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Axe Programming
« Reply #32 on: May 06, 2013, 02:22:16 pm »
You should do :
If GetCalc("Str1")->A
.The two bytes preceding the pointer are the size of the variable
{A-2}^^r->L
If GetCalc("Str4",L)->B
Copy(A,B,L)
Else
Disp "Creation error"
End
Else
Disp "Str1 does not exist"
End

This will copy Str1 to Str4, overwriting the previous content of Str4.
And note that ^^r is the small radian r in the angle menu.
« Last Edit: May 06, 2013, 02:24:12 pm by Streetwalker »

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Programming
« Reply #33 on: May 06, 2013, 02:24:13 pm »
Just did a little test program.

.TEST

"BLARG"→Str1
.Str1 is data to be copied

"prgmSTORE"→Str2
.Str2 is program to be searched for

GetCalc(Str2)→P
.P is pointer

!If P
Disp "Error"
Return
.handle error etc
End

Length(Str1)→A
Copy(Str1,P,A)


If the program is 10 bytes when you first made it, it should look something like this when viewed in the editor:
« Last Edit: May 06, 2013, 03:34:18 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline alex99

  • LV3 Member (Next: 100)
  • ***
  • Posts: 80
  • Rating: +9/-5
    • View Profile
    • Alexstudious
Re: Axe Programming
« Reply #34 on: May 06, 2013, 02:24:34 pm »
it shall copy to a prog and not to a string
VISIT:

www.atomsoftware.jimdo.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Axe Programming
« Reply #35 on: May 06, 2013, 02:26:58 pm »
Oh then just replace "StrX" with "prgmWHATEVER".

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Axe Programming
« Reply #36 on: May 06, 2013, 02:27:17 pm »
it shall copy to a prog and not to a string
Well his program copied to a program, not a string. But it didn't copy to a program whose name was in an external string.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Programming
« Reply #37 on: May 06, 2013, 03:15:28 pm »
As far as I can understand, you want to create a program with the name stored in the OS variable Str4 and the contents stored in the OS variable Str1? If so, here's what I've come up with. I made two different versions: one is larger and allows you to handle each error that could occur individually, while the other is smaller and doesn't support error handling (errors are still caught and avoided, they just cannot be acted upon). The source for both versions is included as text below and as programs attached at the bottom of this post.


With error handling:
Code: [Select]
!If GetCalc("Str1")→S
 .Str1 not found
Else
 !If GetCalc("Str4")→N
  .Str4 not found
 Else
  .L₁ can be replaced with any section of safe RAM at least 9 bytes large
  'prgm'→{L₁}ʳ
  Fill(L₁+1,8)
  Copy(N,L₁+1,{N-2}ʳ)
  !If GetCalc(L₁,{S-2}ʳ→L)→P
   .Creation error
  Else
   Copy(S,P,L)
  End
 End
End

Without error handling:
Code: [Select]
If GetCalc("Str4")→N
 .L₁ can be replaced with any section of safe RAM at least 9 bytes large
 'prgm'→{L₁}ʳ
 Fill(L₁+1,8)
 Copy(N,L₁+1,{N-2}ʳ)
 If GetCalc("Str1")→S
  Copy(S,GetCalc(L₁,{S-2}ʳ→L),L)
 End
End
« Last Edit: May 06, 2013, 03:17:14 pm by Runer112 »