Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 08:23:44 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Using tokens and strings together -  (Read 310 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Emerov
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 01 April, 2013, 06:14:25
Date Registered: 07 January, 2012, 20:33:05
Location: Phoenix, Arizona
Posts: 11

Topic starter
Total Post Ratings: 0

View Profile
« on: 20 April, 2012, 09:07:40 »
0

I'm attempting to access arbitrary OS vars from the calculator, and subsequently delete them. The code works with programs, groups, appvars, and letters, but whenever I try to access the vars represented by tokens, it does not work properly. Basically, I copy the randomly selected var name over into another string so that I can delete it, but the string doesn't seem to recognize the tokens following the first one. Here is my code (simplified):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.DELSUB2
Fix 5
"var "->Str3
"ABCDEFGHIJKLMNOPQRSTUVWXYZØ"->Str5
"L1L2L3L4L5L6"->Str6
"  "->Str8
sub(LSD)
Return

Lbl LSD                             //This will only ever delete L1. If the randomly selected number is not 0, then nothing will happen
Copy(rand^6*2+Str6,Str8,2)
DelVar Str8
Return

Lbl ABC                             //This works
Copy(rand^27+Str5,Str3+1,1)
DelVar Str3

Is there a way to get around this lack of string support for tokens? Like, can these variables be accessed via hex code or something? Thank you!
« Last Edit: 21 April, 2012, 23:30:23 by Emerov » Logged
Emerov
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 01 April, 2013, 06:14:25
Date Registered: 07 January, 2012, 20:33:05
Location: Phoenix, Arizona
Posts: 11

Topic starter
Total Post Ratings: 0

View Profile
« Reply #1 on: 21 April, 2012, 23:38:52 »
0

*Bump* Can somebody help me out with this?
Logged
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:42:06
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #2 on: 22 April, 2012, 00:00:19 »
0

It seems that you are operating under the assumption that each list name in the string takes up 2 bytes, but they actually take up 3. The tokens themselves are only 2 bytes, but their names in the VAT are 3 bytes. Tricky, I know. But make Str8 one character longer and adjust the Copy() a bit and you should be all set.



On another note, I'll mention a few tips you could use to make this code smaller. Firstly, the letters and list names are sequential values, so there's no need to look them up from a string. You can just add an offset to the base letter/list name. Secondly, if you're only moving 1 or 2 bytes, just use a normal store, no need to use Copy(). Tongue


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.DELSUB2
Fix 5
"var "→Str3
"L₁"→Str8
sub(LSD)
Return

Lbl LSD
rand^6→{2+Str8}ʳ
DelVar Str8
Return

Lbl ABC
rand^27+'A'→{1+Str3}ʳ
DelVar Str3
Return
« Last Edit: 22 April, 2012, 00:47:44 by Runer112 » Logged
Emerov
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 01 April, 2013, 06:14:25
Date Registered: 07 January, 2012, 20:33:05
Location: Phoenix, Arizona
Posts: 11

Topic starter
Total Post Ratings: 0

View Profile
« Reply #3 on: 22 April, 2012, 00:41:59 »
0

Awesome, it works and makes sense now! Smiley
Logged
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:42:06
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #4 on: 22 April, 2012, 00:48:46 »
0

Oops, I just noticed a fatal mistake with my optimization to Lbl ABC; I forgot to add 'A' to the random result to actually make the random result in the range of letters! I fixed it now, so if you already grabbed that code, you should grab the fixed version.
« Last Edit: 22 April, 2012, 00:49:49 by Runer112 » Logged
Emerov
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 01 April, 2013, 06:14:25
Date Registered: 07 January, 2012, 20:33:05
Location: Phoenix, Arizona
Posts: 11

Topic starter
Total Post Ratings: 0

View Profile
« Reply #5 on: 22 April, 2012, 02:30:37 »
0

Oh, I just added E41 and it worked fine. Is the 'A' thing better to use or does it just convert it during parsing?
« Last Edit: 22 April, 2012, 02:33:04 by Emerov » Logged
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:42:06
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #6 on: 22 April, 2012, 06:24:59 »
0

They're the same thing. The 'char' notation is more of a convenience/readability feature. The same applies for token values, which can be inserted with Ttoken.
« Last Edit: 22 April, 2012, 06:26:35 by Runer112 » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.209 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.