DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Rmove characters from basic-cad code

Started by aqua, April 25, 2008, 12:00:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aqua

Designcad 13.13

I have some code that gets a reuslt of:
UPPER LEFT X=405715.480

I only want the:
405715.480

Does anyone know how to reduce/eliminate the first 13 characters?

Regards Frank

'External file is already opened via earlier code and sourcing text from there
Input #1, name$
TopleftX$ = name$
Namelen = len(TopleftX$) ' get number of characters in it

'Not sure what to do after this point

ShortTopleftx$ = MID$(Topleftx$, Namelen+1-13)
topleftx = ShortTopleftx$

prl

'sample code

a$ = "UPPER LEFT X=405715.480"
x=INSTR(a$,"=")
tl=len(a$)
b$=right$(a$,tl-x)
message b$

end

aqua


aqua

PRL

Back Again


I have some code that gets the result of:
PIXEL SIZE X=2.29791 meters / pixel

Only want the:
2.29791

The following code will get me:
2.29791 meters / pixel

What do I need to add to get only the:
2.29791

Regards Frank

'Name$ will be equal to or similar to: PIXEL SIZE X=2.29791 meters / pixel
Input #1, name$
PixelsX$ = name$
Namelen = len(PixelsX$) ' get number of characters in it
X=INSTR(PixelsX$,"=")
tl=len(PixelsX$)
ShortPixelsX$=right$(PixelsX$,tl-X)
PixelsX = ShortPixelsX$

prl

#4
'same code - modified in blue

a$ = "PIXEL SIZE X=2.29791 meters / pixel"

x=instr(a$,"=")
tl=len(a$)
b$=right$(a$,tl-x)

x=instr(b$," meters")
c$=left$(b$,x)


message c$

Rob S


I always like the MID function for things like this.

It can be done as a one-liner:

Quotea$ = "PIXEL SIZE X=2.29791 meters / pixel"

b$ = MID$(a$, INSTR(a$, "=") +1, INSTR(a$, " meter")-INSTR(a$, "=") -1)

message b$

or more conventionally

Quotea$ = "PIXEL SIZE X=2.29791 meters / pixel"

Start = INSTR(a$, "=") +1

Counter = INSTR(a$, " meter") - Start

b$ = MID$(a$, Start, Counter)

message b$
User since forever